-
Notifications
You must be signed in to change notification settings - Fork 754
Add support for OTLP/JSON #13557
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add support for OTLP/JSON #13557
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 13557Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 13557" |
There was a problem hiding this 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 adds support for receiving OTLP telemetry data in JSON format (application/json) in addition to the existing Protobuf format (application/x-protobuf). The implementation deserializes JSON to custom C# types, then converts them to Protobuf types for processing through the existing pipeline.
Key changes:
- Created JSON representation types for OTLP traces, logs, metrics, and common structures
- Implemented bidirectional converters between JSON and Protobuf formats
- Updated HTTP endpoints to accept and respond with JSON based on content-type negotiation
- Added comprehensive integration tests covering all telemetry signal types
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 |
|---|---|
| tests/Aspire.Dashboard.Tests/Integration/OtlpHttpServiceTests.cs | Updated unsupported content type tests from application/json to application/xml now that JSON is supported |
| tests/Aspire.Dashboard.Tests/Integration/OtlpHttpJsonTests.cs | New comprehensive test suite with 9 tests validating JSON format for traces, logs, events, metrics, auth, and error handling |
| src/Aspire.Dashboard/Otlp/opentelemetry/proto/trace/v1/trace.proto | Updated to OTLP spec v1.9.0 - added flags field, SpanFlags enum, enhanced documentation |
| src/Aspire.Dashboard/Otlp/opentelemetry/proto/resource/v1/resource.proto | Added entity_refs field and improved documentation per spec updates |
| src/Aspire.Dashboard/Otlp/opentelemetry/proto/metrics/v1/metrics.proto | Added metadata field, enhanced documentation, corrected URLs from OpenObservability to prometheus organization |
| src/Aspire.Dashboard/Otlp/opentelemetry/proto/logs/v1/logs.proto | Added event_name field for event logs, enhanced documentation per spec updates |
| src/Aspire.Dashboard/Otlp/opentelemetry/proto/common/v1/common.proto | Added EntityRef message type, improved documentation for all common types |
| src/Aspire.Dashboard/Otlp/opentelemetry/proto/collector//*_service.proto | Removed outdated RPC lifecycle comments from service definitions |
| src/Aspire.Dashboard/Otlp/Model/Serialization/OtlpTraceJson.cs | New file defining JSON types for trace data with proper serialization attributes |
| src/Aspire.Dashboard/Otlp/Model/Serialization/OtlpResourceJson.cs | New file defining JSON types for resource data |
| src/Aspire.Dashboard/Otlp/Model/Serialization/OtlpMetricsJson.cs | New file defining JSON types for metrics data (631 lines) |
| src/Aspire.Dashboard/Otlp/Model/Serialization/OtlpLogsJson.cs | New file defining JSON types for logs/events data |
| src/Aspire.Dashboard/Otlp/Model/Serialization/OtlpCommonJson.cs | New file defining shared JSON types (AnyValue, KeyValue, InstrumentationScope, EntityRef) |
| src/Aspire.Dashboard/Otlp/Model/Serialization/OtlpJsonSerializerContext.cs | Source-generated JSON serializer context for AOT compatibility |
| src/Aspire.Dashboard/Otlp/Model/Serialization/OtlpJsonProtobufConverter.cs | Bidirectional conversion logic between JSON and Protobuf formats (929 lines) |
| src/Aspire.Dashboard/Otlp/Http/OtlpHttpEndpointsBuilder.cs | Enhanced to handle JSON content-type, deserialize JSON requests, serialize JSON responses |
src/Aspire.Dashboard/Otlp/Model/Serialization/OtlpJsonProtobufConverter.cs
Outdated
Show resolved
Hide resolved
src/Aspire.Dashboard/Otlp/Model/Serialization/OtlpJsonProtobufConverter.cs
Show resolved
Hide resolved
|
Where's the playground sample that uses this? |
|
BrowserTelemetry app now uses OTLP/JSON. Add it can be configured using |
Description
PR adds support for receiving OTLP/JSON data. This data follows the spec at https://protobuf.dev/programming-guides/json/ and https://opentelemetry.io/docs/specs/otlp/#json-protobuf-encoding
The implementation adds new C# types, deserializes to them, then creates types generated from Protobuf. All logic from that point on only works with the Protobuf types.
It doesn't use gRPC JSON transcoding for a couple of reasons:
Fixes #6947
Checklist
<remarks />and<code />elements on your triple slash comments?doc-ideatemplatebreaking-changetemplatediagnostictemplate