Repository navigation
Fix #3211: Default unset Timestamp to UtcNow in TrackDependency/TrackRequest - #3219
Merged
Matthew Sainsbury (Microsoft) (mattsains-msft) merged 3 commits intoSep 25, 2026
Conversation
) TrackDependency(DependencyTelemetry) and TrackRequest(RequestTelemetry) assigned Timestamp directly to Activity start/end time without checking for default, emitting 0001-01-01T00:00:00Z which ingestion rejects (error 103). Restore 2.x behavior by defaulting an unset Timestamp to DateTimeOffset.UtcNow. Fixes #3211 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot started reviewing on behalf of
Rajkumar Rangaraj (rajkumar-rangaraj)
September 24, 2026 23:57
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
No unresolved review issues were identified.
Review effort: Lite
Findings: None
What changed in this PR
Fixes unset request and dependency timestamps by defaulting them to DateTimeOffset.UtcNow.
Changes:
- Added timestamp fallback in
TrackRequestandTrackDependency. - Added regression tests for default and explicit timestamps.
- Documented the fix in the changelog.
| File | Summary |
|---|---|
CHANGELOG.md |
Documents the timestamp behavior fix. |
BASE/Test/Microsoft.ApplicationInsights.Test/Microsoft.ApplicationInsights.Tests/TelemetryClientTest.cs |
Adds timestamp regression tests. |
BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs |
Applies the UTC timestamp fallback. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
xiang17
approved these changes
Sep 25, 2026
Matthew Sainsbury (Microsoft) (mattsains-msft)
merged commit Sep 25, 2026
07099fc
into
main
18 checks passed
Matthew Sainsbury (Microsoft) (mattsains-msft)
deleted the
rajrang/fixTrackTimestampDefault
branch
September 25, 2026 17:28
This was referenced Oct 12, 2026
Closed
Merged
Closed
This was referenced Oct 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3211
Problem
TelemetryClient.TrackDependency(DependencyTelemetry)andTelemetryClient.TrackRequest(RequestTelemetry)copiedtelemetry.Timestampstraight into the backingActivity's start and end times without checking whether it had been set. Code that builds the telemetry without a timestamp (for examplenew DependencyTelemetry(type, target, name, data)ornew RequestTelemetry { ... }) therefore emittedtime = 0001-01-01T00:00:00Z. Ingestion rejects these items with a 206 partial success (error 103).In 2.x,
TelemetryClientset an unsetTimestampitself (see the CHANGELOG: "Timestamp will be added automatically byTelemetryClient").StartOperation/StopOperationandTrackAvailabilityare not affected.Fix
In both methods, if
Timestamp == default, set it toDateTimeOffset.UtcNowbefore creating the Activity. This restores 2.x behavior, including writing the value back to the telemetry object. Timestamps set explicitly by the caller are unchanged.Tests
TrackDependencyWithoutTimestampDefaultsToUtcNow/TrackRequestWithoutTimestampDefaultsToUtcNow: the start time is the time of the call, the duration is kept, and the timestamp is written back. Both tests fail without the fix.TrackDependencyWithExplicitTimestampPreservesTimestamp/TrackRequestWithExplicitTimestampPreservesTimestamp: an explicit timestamp and duration come through unchanged.TelemetryClient*tests pass on net8.0 and net462 (162 on each).Changes