Skip to content

[EXPORTER] Prometheus exporter: fix attribute serialization, label collision, and empty point guards - #4738

Open
dashpole wants to merge 1 commit into
open-telemetry:mainfrom
dashpole:prom-exporter-bugfixes
Open

dashpole wants to merge 1 commit into
open-telemetry:mainfrom
dashpole:prom-exporter-bugfixes

Conversation

@dashpole

Copy link
Copy Markdown
Contributor

Changes

Fix pre-existing bugs in PrometheusExporterUtils split out from #4735 and #4736:

  • Serialize array-valued OwnedAttributeValue alternatives (std::vector<bool>, std::vector<int>, std::vector<int64_t>, std::vector<unsigned int>, std::vector<uint64_t>, std::vector<double>, std::vector<std::string>) as JSON arrays in PrometheusExporterUtils::AttributeValueToString per the OpenTelemetry Common Attribute Specification.
  • Merge generated otel_scope_name and otel_scope_version labels with colliding point attributes in PrometheusExporterUtils::SetMetricBasic using ; concatenation in lexicographical order of original keys.
  • Fix the early return in PrometheusExporterUtils::SetMetricBasic so metrics with empty point attributes and a null resource pointer still receive otel_scope_* labels when scope is non-null.
  • Guard against empty point_data_attr_ in PrometheusExporterUtils::TranslateToPrometheus before accessing front().

For full trivial changes below, please confirm you have:

  • Formatted the code using clang-format
  • Updated CHANGELOG.md if applicable

…llision, and empty point guards

Fix pre-existing bugs in PrometheusExporterUtils:
- Serialize array-valued OwnedAttributeValue alternatives as JSON arrays in AttributeValueToString per the OpenTelemetry attribute specification.
- Merge generated otel_scope_name and otel_scope_version labels with colliding point attributes in SetMetricBasic using ';' concatenation ordered by original key.
- Fix SetMetricBasic early return so metrics with empty point attributes and null resource still receive scope labels when scope is non-null.
- Guard against empty point_data_attr_ in TranslateToPrometheus before accessing front().

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@dashpole
dashpole marked this pull request as ready for review October 26, 2026 18:36
@dashpole
dashpole requested a review from a team as a code owner October 26, 2026 18:36
@codecov

codecov Bot commented Oct 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 68.85246% with 38 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.58%. Comparing base (e854d29) to head (b5ef319).

Files with missing lines Patch % Lines
exporters/prometheus/src/exporter_utils.cc 68.86% 38 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4738      +/-   ##
==========================================
- Coverage   86.69%   86.58%   -0.10%     
==========================================
  Files         527      527              
  Lines       20902    21014     +112     
==========================================
+ Hits        18119    18193      +74     
- Misses       2783     2821      +38     
Files with missing lines Coverage Δ
exporters/prometheus/src/exporter_utils.cc 83.14% <68.86%> (-6.06%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants