Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Use UtcDateTime for microsoft.availability.testTimestamp attribute
Agent-Logs-Url: https://github.com/microsoft/ApplicationInsights-dotnet/sessions/2847601f-8eaf-42ea-9083-9933f8230ab3

Co-authored-by: rajkumar-rangaraj <9479006+rajkumar-rangaraj@users.noreply.github.com>
  • Loading branch information
Copilot and rajkumar-rangaraj authored Mar 27, 2026
commit 596b32a4022b6f8b48b42728fcaf167fb3143272
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ public void TrackAvailabilitySendsAvailabilityTelemetryWithAllParameters()
Assert.Contains(logRecord.Attributes, a => a.Key == "microsoft.availability.success" && a.Value?.ToString() == success.ToString());
Assert.Contains(logRecord.Attributes, a => a.Key == "microsoft.availability.runLocation" && a.Value?.ToString() == runLocation);
Assert.Contains(logRecord.Attributes, a => a.Key == "microsoft.availability.message" && a.Value?.ToString() == message);
Assert.Contains(logRecord.Attributes, a => a.Key == "microsoft.availability.testTimestamp" && a.Value?.ToString() == timeStamp.ToString("o"));
Assert.Contains(logRecord.Attributes, a => a.Key == "microsoft.availability.testTimestamp" && a.Value?.ToString() == timeStamp.UtcDateTime.ToString("o"));
Assert.Contains(logRecord.Attributes, a => a.Key == "Environment" && a.Value?.ToString() == "Production");
}

Expand Down Expand Up @@ -304,7 +304,7 @@ public void TrackAvailabilityWithAvailabilityTelemetryObject()
Assert.Contains(logRecord.Attributes, a => a.Key == "CustomProp" && a.Value?.ToString() == "CustomValue");

// Verify timestamp is preserved
Assert.Contains(logRecord.Attributes, a => a.Key == "microsoft.availability.testTimestamp" && a.Value?.ToString() == timeStamp.ToString("o"));
Assert.Contains(logRecord.Attributes, a => a.Key == "microsoft.availability.testTimestamp" && a.Value?.ToString() == timeStamp.UtcDateTime.ToString("o"));
}

[Fact]
Expand Down Expand Up @@ -381,7 +381,7 @@ public void TrackAvailabilityPreservesUserSpecifiedTimestamp()
// Verify the user-specified timestamp is included as a property
var timestampAttr = logRecord.Attributes.FirstOrDefault(a => a.Key == "microsoft.availability.testTimestamp");
Assert.NotNull(timestampAttr.Value);
Assert.Equal(specificTimestamp.ToString("o"), timestampAttr.Value?.ToString());
Assert.Equal(specificTimestamp.UtcDateTime.ToString("o"), timestampAttr.Value?.ToString());
}

[Fact]
Expand Down
2 changes: 1 addition & 1 deletion BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ public void TrackAvailability(AvailabilityTelemetry telemetry)

if (telemetry.Timestamp != default)
{
properties.Add("microsoft.availability.testTimestamp", telemetry.Timestamp.ToString("o"));
properties.Add("microsoft.availability.testTimestamp", telemetry.Timestamp.UtcDateTime.ToString("o"));
}

// Add custom properties from telemetry
Expand Down
Loading