From 8a245725f31fb0f09bb6513f223fe7c406cc1d77 Mon Sep 17 00:00:00 2001 From: Marty Tippin <120425148+tippmar-nr@users.noreply.github.com> Date: Tue, 7 Jan 2025 10:22:53 -0600 Subject: [PATCH] Consistency --- .../Agent/Core/DistributedTracing/TracingState.cs | 2 +- .../DistributedTracing/TracingStateTests.cs | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Agent/NewRelic/Agent/Core/DistributedTracing/TracingState.cs b/src/Agent/NewRelic/Agent/Core/DistributedTracing/TracingState.cs index a851a55bc7..c101474a70 100644 --- a/src/Agent/NewRelic/Agent/Core/DistributedTracing/TracingState.cs +++ b/src/Agent/NewRelic/Agent/Core/DistributedTracing/TracingState.cs @@ -109,7 +109,7 @@ public DateTime Timestamp return _timestamp = _newRelicPayload.Timestamp; } - return _timestamp = (DateTime)default; // default is same as new. + return _timestamp = default(DateTime); // default is same as new. } } diff --git a/tests/Agent/UnitTests/Core.UnitTest/DistributedTracing/TracingStateTests.cs b/tests/Agent/UnitTests/Core.UnitTest/DistributedTracing/TracingStateTests.cs index 04fde3c5c8..bd9b45c31d 100644 --- a/tests/Agent/UnitTests/Core.UnitTest/DistributedTracing/TracingStateTests.cs +++ b/tests/Agent/UnitTests/Core.UnitTest/DistributedTracing/TracingStateTests.cs @@ -64,7 +64,7 @@ public void AcceptDistributedTraceHeadersHydratesValidNewRelicPayload(string hea Assert.That(tracingState.Priority, Is.EqualTo(Priority)); Assert.That(tracingState.Sampled, Is.EqualTo(Sampled)); Assert.That(tracingState.TransactionId, Is.EqualTo(TransactionId)); - Assert.That(tracingState.Timestamp, Is.Not.EqualTo(default(DateTime)), $"Timestamp should not be {(DateTime)default}"); + Assert.That(tracingState.Timestamp, Is.Not.EqualTo(default(DateTime)), $"Timestamp should not be {default(DateTime)}"); Assert.That(tracingState.TransportDuration, Is.GreaterThan(TimeSpan.Zero), $"TransportDuration should not be Zero"); }); } @@ -92,7 +92,7 @@ public void AcceptDistributedTraceHeadersPopulatesErrorsIfNull(string headerName Assert.That(tracingState.TransactionId, Is.Null); Assert.That(tracingState.Sampled, Is.Null); Assert.That(tracingState.Priority, Is.Null); - Assert.That(tracingState.Timestamp, Is.EqualTo((DateTime)default), $"Timestamp: expected {(DateTime)default}, actual: {tracingState.Timestamp}"); + Assert.That(tracingState.Timestamp, Is.EqualTo(default(DateTime)), $"Timestamp: expected {default(DateTime)}, actual: {tracingState.Timestamp}"); Assert.That(tracingState.TransportDuration, Is.EqualTo(TimeSpan.Zero), $"TransportDuration: expected {TimeSpan.Zero}, actual: {tracingState.TransportDuration}"); Assert.That(tracingState.IngestErrors, Does.Contain(IngestErrorType.NullPayload), "TracingState IngestErrors should contain NullPayload"); @@ -124,7 +124,7 @@ public void AcceptDistributedTraceHeadersPopulatesErrorsIfUnsupportedVersion(str Assert.That(tracingState.TransactionId, Is.Null); Assert.That(tracingState.Sampled, Is.Null); Assert.That(tracingState.Priority, Is.Null); - Assert.That(tracingState.Timestamp, Is.EqualTo((DateTime)default), $"Timestamp: expected {(DateTime)default}, actual: {tracingState.Timestamp}"); + Assert.That(tracingState.Timestamp, Is.EqualTo(default(DateTime)), $"Timestamp: expected {default(DateTime)}, actual: {tracingState.Timestamp}"); Assert.That(tracingState.TransportDuration, Is.EqualTo(TimeSpan.Zero), $"TransportDuration: expected {TimeSpan.Zero}, actual: {tracingState.TransportDuration}"); Assert.That(tracingState.IngestErrors, Does.Contain(IngestErrorType.Version), "TracingState IngestErrors should contain Version error."); @@ -156,7 +156,7 @@ public void AcceptDistributedTraceHeadersPopulatesErrorsIfInvalidTimestamp(strin Assert.That(tracingState.TransactionId, Is.Null); Assert.That(tracingState.Sampled, Is.Null); Assert.That(tracingState.Priority, Is.Null); - Assert.That(tracingState.Timestamp, Is.EqualTo((DateTime)default), $"Timestamp: expected {(DateTime)default}, actual: {tracingState.Timestamp}"); + Assert.That(tracingState.Timestamp, Is.EqualTo(default(DateTime)), $"Timestamp: expected {default(DateTime)}, actual: {tracingState.Timestamp}"); Assert.That(tracingState.TransportDuration, Is.EqualTo(TimeSpan.Zero), $"TransportDuration: expected {TimeSpan.Zero}, actual: {tracingState.TransportDuration}"); Assert.That(tracingState.IngestErrors, Does.Contain(IngestErrorType.ParseException), "TracingState IngestErrors should contain ParseException."); @@ -188,7 +188,7 @@ public void AcceptDistributedTraceHeadersPopulatesErrorsIfNotTraceable(string he Assert.That(tracingState.TransactionId, Is.Null); Assert.That(tracingState.Sampled, Is.Null); Assert.That(tracingState.Priority, Is.Null); - Assert.That(tracingState.Timestamp, Is.EqualTo((DateTime)default), $"Timestamp: expected {(DateTime)default}, actual: {tracingState.Timestamp}"); + Assert.That(tracingState.Timestamp, Is.EqualTo(default(DateTime)), $"Timestamp: expected {default(DateTime)}, actual: {tracingState.Timestamp}"); Assert.That(tracingState.TransportDuration, Is.EqualTo(TimeSpan.Zero), $"TransportDuration: expected {TimeSpan.Zero}, actual: {tracingState.TransportDuration}"); Assert.That(tracingState.IngestErrors, Does.Contain(IngestErrorType.ParseException), "TracingState IngestErrors should contain ParseException."); @@ -222,7 +222,7 @@ public void AcceptDistributedTraceHeadersHydratesValidW3CTraceContext() Assert.That(tracingState.Sampled, Is.EqualTo(Sampled)); Assert.That(tracingState.TransactionId, Is.EqualTo(TransactionId)); Assert.That(tracingState.ParentId, Is.EqualTo(ParentId)); - Assert.That(tracingState.Timestamp, Is.Not.EqualTo(default(DateTime)), $"Timestamp should not be {(DateTime)default}"); + Assert.That(tracingState.Timestamp, Is.Not.EqualTo(default(DateTime)), $"Timestamp should not be {default(DateTime)}"); Assert.That(tracingState.TransportDuration, Is.GreaterThan(TimeSpan.Zero), $"TransportDuration should not be Zero"); }); } @@ -251,7 +251,7 @@ public void AcceptDistributedTraceHeadersHydratesValidW3CTraceContext_WithoutAVa Assert.That(tracingState.TraceId, Is.EqualTo(TraceId)); Assert.That(tracingState.ParentId, Is.EqualTo(ParentId)); Assert.That(tracingState.Type, Is.EqualTo(DistributedTracingParentType.Unknown)); - Assert.That(tracingState.Timestamp, Is.EqualTo((DateTime)default), $"Timestamp: expected {(DateTime)default}, actual: {tracingState.Timestamp}"); + Assert.That(tracingState.Timestamp, Is.EqualTo(default(DateTime)), $"Timestamp: expected {default(DateTime)}, actual: {tracingState.Timestamp}"); Assert.That(tracingState.TransportDuration, Is.EqualTo(TimeSpan.Zero), $"TransportDuration: expected {TimeSpan.Zero}, actual: {tracingState.TransportDuration}"); }); }