open-telemetry / opentelemetry-cpp

The OpenTelemetry C++ Client
https://opentelemetry.io/
Apache License 2.0
851 stars 403 forks source link

Schema URL inconsistently exported #2569

Closed samin36 closed 6 months ago

samin36 commented 7 months ago

Describe your environment Opentelemetry-cpp v1.12.0 on Ubuntu 18

Steps to reproduce Specify schema_url to the GetMeter, GetTracer, and Resource::Create functions and set up Tracer/Meter providers to export using the OTLP HTTP exporters.

What is the expected behavior? The exported metrics and traces should contain the schema_url.

What is the actual behavior? Only the exported traces contain the schema_url. The exported metric data does not contain the schema_url.

Additional context I verified this by using the logging exporter in the Opentelemetry-Collector, which prints the metric/tracing data. I also set up a dummy HTTP server to log all incoming data at /v1/metrics and /v1/traces endpoint and only saw the schema_url for the tracing data.

lalitb commented 7 months ago

Thanks for the issue. The schema_url is not getting populated for metrics here: OtlpMetricUtils::PopulateResourceMetrics().

Need to add

resource_metrics->set_schema_url(scope_metrics.scope_->GetSchemaUrl());

in above-mentioned method.

github-actions[bot] commented 7 months ago

This issue is available for anyone to work on. Make sure to reference this issue in your pull request. :sparkles: Thank you for your contribution! :sparkles: