Skip to content

Include AvailabilityTelemetry.Timestamp as microsoft.availability.testTimestamp attribute#3153

Merged
rajkumar-rangaraj merged 4 commits intomainfrom
copilot/fix-timestamp-on-availability-telemetry
Mar 27, 2026
Merged

Include AvailabilityTelemetry.Timestamp as microsoft.availability.testTimestamp attribute#3153
rajkumar-rangaraj merged 4 commits intomainfrom
copilot/fix-timestamp-on-availability-telemetry

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 27, 2026

TrackAvailability drops the user-provided Timestamp from AvailabilityTelemetry. The log record is emitted with the current wall-clock time, breaking end-to-end transaction timelines where the availability test start time precedes dependent HTTP calls.

Changes

  • TelemetryClient.cs — Emit microsoft.availability.testTimestamp (ISO 8601 UTC) in the properties dictionary when Timestamp != default, using Timestamp.UtcDateTime to normalize to UTC. Consistent with the existing microsoft.availability.* attribute contract. Downstream exporters can use this to set the correct event time.
  • TelemetryClientTest.cs — Added timestamp assertion to two existing tests; added TrackAvailabilityPreservesUserSpecifiedTimestamp and TrackAvailabilityOmitsTimestampWhenDefault.
  • CHANGELOG.md — Added entry under Unreleased.
// Before: timestamp silently ignored
var avail = new AvailabilityTelemetry("Test", startTime, duration, "Sweden Central", true);
client.TrackAvailability(avail); // log record gets DateTimeOffset.UtcNow

// After: timestamp propagated as UTC attribute
// properties["microsoft.availability.testTimestamp"] = "2025-04-19T12:10:59.9930000Z"

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…tTimestamp attribute

When TrackAvailability is called, the Timestamp property from
AvailabilityTelemetry is now included as a microsoft.availability.testTimestamp
attribute in ISO 8601 format. This allows downstream exporters (e.g. Azure
Monitor) to use the user-specified timestamp as the event time instead of the
log record creation time. The attribute is omitted when Timestamp is default.

Fixes #3152

Agent-Logs-Url: https://github.com/microsoft/ApplicationInsights-dotnet/sessions/a2c48a2d-4b7c-4088-8fa0-901d9226ea88

Co-authored-by: rajkumar-rangaraj <9479006+rajkumar-rangaraj@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix timestamp on AvailabilityTelemetry in TelemetryClient Include AvailabilityTelemetry.Timestamp as microsoft.availability.testTimestamp attribute Mar 27, 2026
Copilot AI requested a review from rajkumar-rangaraj March 27, 2026 16:51
@rajkumar-rangaraj rajkumar-rangaraj marked this pull request as ready for review March 27, 2026 17:30
Copilot AI review requested due to automatic review settings March 27, 2026 17:30
@rajkumar-rangaraj
Copy link
Copy Markdown
Member

@copilot Add changelog update

Agent-Logs-Url: https://github.com/microsoft/ApplicationInsights-dotnet/sessions/75a63958-f27f-48e5-bade-7bbeb08ea0b7

Co-authored-by: rajkumar-rangaraj <9479006+rajkumar-rangaraj@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 27, 2026

@copilot Add changelog update

Added in 95d2745.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR ensures TrackAvailability preserves a user-provided AvailabilityTelemetry.Timestamp by emitting it as a microsoft.availability.testTimestamp log attribute (ISO 8601), enabling downstream exporters to reconstruct the correct event time for availability tests.

Changes:

  • Add microsoft.availability.testTimestamp attribute when AvailabilityTelemetry.Timestamp != default.
  • Extend existing availability tests to assert timestamp propagation.
  • Add new tests to validate timestamp presence/absence for explicit vs default timestamps.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs Adds emission of microsoft.availability.testTimestamp from AvailabilityTelemetry.Timestamp when set.
BASE/Test/Microsoft.ApplicationInsights.Test/Microsoft.ApplicationInsights.Tests/TelemetryClientTest.cs Adds/extends tests to verify timestamp is included when provided and omitted when default.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 27, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • rt.services.visualstudio.com
    • Triggering command: /usr/share/dotnet/dotnet /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/work/ApplicationInsights-dotnet/ApplicationInsights-dotnet/bin/Release/test/Microsoft.ApplicationInsights.Tests/net8.0/Microsoft.ApplicationInsights.Tests.runtimeconfig.json --depsfile /home/REDACTED/work/ApplicationInsights-dotnet/ApplicationInsights-dotnet/bin/Release/test/Microsoft.ApplicationInsights.Tests/net8.0/Microsoft.ApplicationInsights.Tests.deps.json /home/REDACTED/work/ApplicationInsights-dotnet/ApplicationInsights-dotnet/bin/Release/test/Microsoft.ApplicationInsights.Tests/net8.0/testhost.dll --port 42863 --endpoint 127.0.0.1:042863 --role client --parentprocessid 4147 --telemetryoptedin false (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@rajkumar-rangaraj rajkumar-rangaraj merged commit 497e042 into main Mar 27, 2026
18 checks passed
@rajkumar-rangaraj rajkumar-rangaraj deleted the copilot/fix-timestamp-on-availability-telemetry branch March 27, 2026 19:12
This was referenced Apr 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Timestamp on AvailabilityTelemetry ignored by TelemetryClient.TrackAvailability

4 participants