Azure Monitor Exporter: consume microsoft.availability.testTimestamp to override envelope time#57550
Merged
rajkumar-rangaraj merged 3 commits intomainfrom Mar 27, 2026
Merged
Conversation
…re Monitor Exporter Agent-Logs-Url: https://github.com/Azure/azure-sdk-for-net/sessions/6086c808-de3e-457a-a15e-96232608c738 Co-authored-by: rajkumar-rangaraj <9479006+rajkumar-rangaraj@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Update Azure Monitor Exporter to consume test timestamp attribute
Azure Monitor Exporter: consume microsoft.availability.testTimestamp to override envelope time
Mar 27, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the Azure Monitor OpenTelemetry Exporter to honor a new microsoft.availability.testTimestamp log attribute by using it as the Availability telemetry envelope timestamp, preserving the original test start time end-to-end.
Changes:
- Consume
microsoft.availability.testTimestampduring availability attribute extraction and prevent it from leaking intoAvailabilityData.Properties. - Add a
TelemetryItemconstructor overload to allow explicitly setting the envelopeTimefor log-based telemetry. - Add E2E validation tests covering both presence and absence of
testTimestamp.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Internals/LogsHelper.cs | Parses and applies testTimestamp for Availability envelope time; consumes the attribute during extraction. |
| sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Customizations/Models/TelemetryItem.cs | Adds constructor overload to set envelope time explicitly for log-based telemetry items. |
| sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Azure.Monitor.OpenTelemetry.Exporter.Tests/E2ETelemetryItemValidation/AvailabilityTests.cs | Adds coverage verifying envelope time override and no property leakage. |
...s/Azure.Monitor.OpenTelemetry.Exporter.Tests/E2ETelemetryItemValidation/AvailabilityTests.cs
Outdated
Show resolved
Hide resolved
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Internals/LogsHelper.cs
Outdated
Show resolved
Hide resolved
rajkumar-rangaraj
approved these changes
Mar 27, 2026
Member
|
@copilot apply changes based on the comments in this thread |
…estTimestamp Agent-Logs-Url: https://github.com/Azure/azure-sdk-for-net/sessions/971c0e48-fb38-4772-a6fe-9636dfc1a589 Co-authored-by: rajkumar-rangaraj <9479006+rajkumar-rangaraj@users.noreply.github.com>
Contributor
Author
Applied both review suggestions in commit 45d3e2c:
|
rajkumar-rangaraj
approved these changes
Mar 27, 2026
harsimar
approved these changes
Mar 27, 2026
Member
|
/check-enforcer override |
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.
Implements support for the new
microsoft.availability.testTimestampattribute introduced in microsoft/ApplicationInsights-dotnet#3153. When this ISO 8601 attribute is present on an availability log record, the exporter now uses it as theTelemetryItemenvelope time instead of the wall-clocklogRecord.Timestamp, preserving the user-specified test start time end-to-end.Changes
LogsHelper.csAvailabilityTestTimestampAttributeNameconstant andTestTimestampproperty toAvailabilityInfostructcasefor the attribute inExtractAvailabilityInfo— prevents it leaking intoAvailabilityData.Propertiesvia thedefault:branchOtelToAzureMonitorLogs: availability branch parsesTestTimestampusingCultureInfo.InvariantCulturefor deterministic culture-independent parsing and normalizes the result to UTC via.ToUniversalTime(); falls back tologRecord.Timestampif absent or unparseableTelemetryItem.csTelemetryItem(string name, DateTimeOffset envelopeTime, LogRecord logRecord, ...)accepting an explicit envelope timeLogRecordconstructor delegates to the new overload (no duplication)AvailabilityTests.csVerifyAvailabilityTelemetryWithTestTimestamp: assertsTelemetryItem.Timeequals the parsed (UTC-normalized, culture-invariant) timestamp and attribute is absent fromAvailabilityData.PropertiesVerifyAvailabilityTelemetryWithoutTestTimestamp: asserts existing behavior (envelope time fromlogRecord.Timestamp) is unchanged when attribute is absentThis checklist is used to make sure that common guidelines for a pull request are followed.
General Guidelines
Testing Guidelines
SDK Generation Guidelines
*.csprojandAssemblyInfo.csfiles have been updated with the new version of the SDK.Original prompt
Background
microsoft/ApplicationInsights-dotnet#3153 adds a new attribute
microsoft.availability.testTimestamp(ISO 8601 string) to the log record properties whenAvailabilityTelemetry.Timestamp != default. This allows the downstream exporter to use the user-specified test start time as the envelope timestamp instead of the wall-clock time of the log record.The Azure Monitor Exporter must be updated to consume this new attribute.
Files to change
1.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Internals/LogsHelper.csa) Add new constant alongside the other availability attribute constants (~line 41):
b) Add a field to
AvailabilityInfostruct (at the bottom of the file, ~line 436):c) In
ExtractAvailabilityInfo, add a local variablestring? availabilityTestTimestamp = null;alongside the others, and handle it in theswitch:Also populate it when constructing the return value:
This ensures the attribute is explicitly consumed and not leaked into
AvailabilityData.Propertiesvia thedefault:branch.2.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Customizations/Models/TelemetryItem.csThe
TelemetryItemconstructor used for log records (line ~139) always derives the envelopeTimefromlogRecord.Timestamp. SinceTimeis aget-only property set in the base constructor, overriding it requires a different approach.Add a new constructor overload that accepts an explicit
DateTimeOffsetfor the time to be used whentestTimestampis available:Or alternatively, modify the existing
OtelToAzureMonitorLogsmethod inLogsHelper.csto overrideTimeafter construction — but sinceTimeis readonly, the constructor overload approach is needed.3.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Internals/LogsHelper.cs—OtelToAzureMonitorLogsIn the
else if (availabilityInfo is not null)branch (~line 111), use thetestTimestampto set the envelope time:Note:
TelemetryItem.FormatUtcTimestampis currentlyinternal static— make sure it remains accessible fromLogsHelper.cs(it's already in the same assembly so this is fine).4. Tests —
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Azure.Monitor.OpenTelemetry.Exporter.Tests/E2ETelemetryItemValidation/AvailabilityTests.csAdd a new test
VerifyAvailabilityTelemetryWithTestTimestampthat:microsoft.availability.testTimestampwith a specific past timestamp (e.g.,"2025-04-19T12:10:59.9930000+00:00").TelemetryItem.Timeequals that parsed timestamp.microsoft.availability.testTimestampdoes not appear inAvailabilityData.Properties.Also add a test
VerifyAvailabilityTelemetryWithoutTestTimestampthat verifies the existing behavior is unchanged when the attribute is absent (envelope time comes fromlogRecord.Timestamp).Key constraint
The
microsoft.availability.testTimestampattribute must be consumed (not passed through toAvailabilityData.Properties). Thedefault:branch inExtractAvailabilityInfoadds any unrecognized attribute toproperties. Adding an explicitcasefor the new attribute name prevents this leakage.The following is the prior conversation context from the user's chat exploration (may be truncated):
User: @microsoft/ApplicationInsights-dotnet/pull/3153 - A new attribute is added to ava...
This pull request was created from Copilot chat.
💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.