Skip to content

Conversation

@JamesNK
Copy link
Member

@JamesNK JamesNK commented Dec 15, 2025

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:

  • There are some differences between gRPC JSON transcoding and what OTLP uses (notably, traceId and spanId fields are hex instead of base64)
  • The JSON types here will eventually be reused for more features:
    • Export telemetry button in the dashboard to download telemetry as JSON
    • API to get telemetry from the dashboard
    • Getting telemetry from the dashboard using the CLI (don't want to force the CLI to have a dependency on Goolge.Protobuf)

Fixes #6947

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?

Copilot AI review requested due to automatic review settings December 15, 2025 06:45
@github-actions
Copy link
Contributor

github-actions bot commented Dec 15, 2025

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 13557

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 13557"

Copy link
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 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

@davidfowl
Copy link
Member

Where's the playground sample that uses this?

@JamesNK JamesNK requested a review from mitchdenny as a code owner December 15, 2025 23:56
@JamesNK
Copy link
Member Author

JamesNK commented Dec 16, 2025

BrowserTelemetry app now uses OTLP/JSON. Add it can be configured using WithOtlpExporter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support Receiving OTLP/JSON (over HTTP) in the Aspire Dashboard

3 participants