Add OTel-compliant span status to ETW DTO logging path#127
Merged
Conversation
Records an OTel-spec-compliant span status (and error.type) on the ETW
DTO logging path (Path B), which previously dropped status entirely.
Brings it to parity with the Activity-based path (FormatSingle).
- New SpanStatusCode enum, SpanStatus struct, and SpanStatusBuilder
(central Exception -> status + error.type mapping, mirroring
OpenTelemetryScope.RecordError).
- BaseData: adds StatusCode/StatusMessage; ToDictionary emits Status.
- Optional Exception? error threaded through all 5 *DataBuilder.Build
methods (via shared ApplyStatus on BaseDataBuilder), A365EtwLogger,
and IA365EtwLogger.
- ExportFormatter.FormatLogData emits the Status object (defaults to
{ code: 0, message: "" } when absent).
Ports microsoft/Agent365-dotnet#259 into the distro repo.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR brings the Agent365 ETW DTO logging path (Path B) up to parity with the Activity-based path by emitting an OpenTelemetry-compliant span Status (and error.type when applicable) for exported log payloads, ensuring errored operations carry status information instead of dropping it.
Changes:
- Adds DTO types for span status (
SpanStatusCode,SpanStatus) and a centralizedSpanStatusBuilderto mapException→ status +error.type. - Threads an optional
Exception? error = nullthrough ETW logger APIs and all*DataBuilder.Buildmethods, applying status intoBaseData. - Ensures
BaseData.ToDictionary()andExportFormatter.FormatLogData()include aStatusobject (defaulting to{ code: 0, message: "" }).
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| test/Microsoft.OpenTelemetry.Agent365.Tests/Runtime/DTOs/Builders/SpanStatusBuilderTests.cs | Adds unit tests for exception→status mapping and error.type behavior. |
| test/Microsoft.OpenTelemetry.Agent365.Tests/Runtime/DTOs/Builders/InvokeAgentDataBuilderTests.cs | Extends builder tests to cover status/error propagation. |
| test/Microsoft.OpenTelemetry.Agent365.Tests/Runtime/DTOs/BaseDataTests.cs | Verifies BaseData default status and ToDictionary() status shape. |
| test/Microsoft.OpenTelemetry.Agent365.Tests/Runtime/Common/ExportFormatterStatusTests.cs | Adds formatter tests to ensure Status is emitted and defaults correctly. |
| src/Microsoft.OpenTelemetry/Agent365/Runtime/Etw/IA365EtwLogger.cs | Adds optional error parameter to ETW logging interface methods. |
| src/Microsoft.OpenTelemetry/Agent365/Runtime/Etw/A365EtwLogger.cs | Wires error through implementation into DTO builders. |
| src/Microsoft.OpenTelemetry/Agent365/Runtime/DTOs/SpanStatusCode.cs | Introduces OTLP-aligned numeric status code enum. |
| src/Microsoft.OpenTelemetry/Agent365/Runtime/DTOs/SpanStatus.cs | Adds status value type carrying code + optional message. |
| src/Microsoft.OpenTelemetry/Agent365/Runtime/DTOs/Builders/SpanStatusBuilder.cs | Centralizes exception→status + error.type mapping for DTO path. |
| src/Microsoft.OpenTelemetry/Agent365/Runtime/DTOs/Builders/OutputDataBuilder.cs | Threads error into builder and applies status to output telemetry. |
| src/Microsoft.OpenTelemetry/Agent365/Runtime/DTOs/Builders/InvokeAgentDataBuilder.cs | Threads error into builder and applies status to invoke_agent telemetry. |
| src/Microsoft.OpenTelemetry/Agent365/Runtime/DTOs/Builders/ExecuteToolDataBuilder.cs | Threads error into builder and applies status to execute_tool telemetry. |
| src/Microsoft.OpenTelemetry/Agent365/Runtime/DTOs/Builders/ExecuteInferenceDataBuilder.cs | Threads error into builder and applies status to inference telemetry. |
| src/Microsoft.OpenTelemetry/Agent365/Runtime/DTOs/Builders/BaseDataBuilder.cs | Adds ApplyStatus helper to set status and write error.type. |
| src/Microsoft.OpenTelemetry/Agent365/Runtime/DTOs/Builders/ApplyGuardrailDataBuilder.cs | Threads error into builder and applies status to guardrail telemetry. |
| src/Microsoft.OpenTelemetry/Agent365/Runtime/DTOs/BaseData.cs | Adds status fields and emits Status {code,message} in ToDictionary(). |
| src/Microsoft.OpenTelemetry/Agent365/Runtime/Common/ExportFormatter.cs | Emits Status in formatted log payload with sensible defaults. |
| src/Microsoft.OpenTelemetry/.publicApi/PublicAPI.Unshipped.txt | Records new public surface area and signature changes for analyzers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Addresses PR feedback: error.type is not part of the reserved-key filter for extraAttributes, so a caller could pass it through and have it emitted while status stayed Unset. FromError now removes any pre-existing error.type attribute on the no-error path, ensuring error.type is never present without an accompanying error status. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
juliomenendez
approved these changes
Jun 25, 2026
harsimar
approved these changes
Jun 26, 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.
Summary
Records an OTel-spec-compliant span status (and
error.type) on the ETW DTO logging path (Path B), which previously dropped status entirely. The Activity-based path (Path A) already emits status viaExportFormatter.FormatSingle; this brings Path B (A365EtwLogger->*DataBuilder->BaseData->ExportFormatter.FormatLogData) to parity.Ports microsoft/Agent365-dotnet#259 into this distro repo (paths mapped from
src/Observability/Runtime/...tosrc/Microsoft.OpenTelemetry/Agent365/Runtime/...).What changed
DTOs/) -SpanStatusCodeenum (Unset=0/Ok=1/Error=2, mapping onto OTLPStatus.StatusCode),SpanStatusstruct, andSpanStatusBuilder(centralException-> status +error.typemapping, mirroringOpenTelemetryScope.RecordError).BaseData- addsStatusCode/StatusMessage;ToDictionary()now emitsStatus { code, message }.Exception? error = nullthreaded through all 5*DataBuilder.Buildmethods (via a sharedApplyStatushelper onBaseDataBuilder), plusA365EtwLoggerandIA365EtwLogger.ExportFormatter.FormatLogData- emits theStatusobject (defaults to{ code: 0, message: "" }when absent).PublicAPI.Unshipped.txt- new public types/members plus*REMOVED*markers for the modified shipped signatures (PublicApiAnalyzers compliance).Emitted shape (errored span)
With no error,
Statusdefaults toUnset(code: 0) anderror.typeis absent. The optionalerrorparameter keeps all existing call sites source-compatible.Testing
dotnet build src/Microsoft.OpenTelemetry/Microsoft.OpenTelemetry.csproj- succeeds (0 errors across net8.0/net10.0/netstandard2.0).dotnet test(Agent365 tests) - 461 passed, 3 skipped, 0 failed, including newSpanStatusBuilderTests,ExportFormatterStatusTests, and addedBaseData/InvokeAgentDataBuilderstatus cases.Note
The source PR's
.github/copilot-instructions.mdchange is specific to the Agent365-dotnet repo and was intentionally not ported.