Skip to content
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

[prometheus] Support meter-level tags #5837

Merged
merged 5 commits into from
Sep 23, 2024

Conversation

robertcoltheart
Copy link
Contributor

@robertcoltheart robertcoltheart commented Sep 15, 2024

Fixes #
#5836

Changes

Adds meter-level tags to Prometheus exporter. Any tags added to meter are automatically added to scrape output.

Merge requirement checklist

  • CONTRIBUTING guidelines followed (license requirements, nullable enabled, static analysis, etc.)
  • Unit tests added/updated
  • Appropriate CHANGELOG.md files updated for non-trivial changes
  • Changes in public API reviewed (if applicable)

@github-actions github-actions bot added pkg:OpenTelemetry.Exporter.Prometheus.AspNetCore Issues related to OpenTelemetry.Exporter.Prometheus.AspNetCore NuGet package pkg:OpenTelemetry.Exporter.Prometheus.HttpListener Issues related to OpenTelemetry.Exporter.Prometheus.HttpListener NuGet package labels Sep 15, 2024
Copy link

codecov bot commented Sep 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.30%. Comparing base (6250307) to head (45cb7fc).
Report is 322 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #5837      +/-   ##
==========================================
+ Coverage   83.38%   86.30%   +2.91%     
==========================================
  Files         297      257      -40     
  Lines       12531    11172    -1359     
==========================================
- Hits        10449     9642     -807     
+ Misses       2082     1530     -552     
Flag Coverage Δ
unittests ?
unittests-Project-Experimental 86.25% <100.00%> (?)
unittests-Project-Stable 85.92% <100.00%> (?)
unittests-UnstableCoreLibraries-Experimental 85.75% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...heus.HttpListener/Internal/PrometheusSerializer.cs 87.15% <100.00%> (+2.28%) ⬆️

... and 224 files with indirect coverage changes

@robertcoltheart robertcoltheart marked this pull request as ready for review September 16, 2024 00:11
@robertcoltheart robertcoltheart requested a review from a team September 16, 2024 00:11
Copy link

@ProbablePrime ProbablePrime left a comment

Choose a reason for hiding this comment

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

Great job!

Copy link
Contributor

@ysolomchenko ysolomchenko left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -404,6 +404,15 @@ public static int WriteTags(byte[] buffer, int cursor, Metric metric, ReadOnlyTa
buffer[cursor++] = unchecked((byte)',');
}

if (metric.MeterTags != null)
Copy link
Contributor

Choose a reason for hiding this comment

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

I see that the current tests have been updated to validate MeterTags. Is there a test that validates null MeterTags?"

@cijothomas cijothomas requested a review from a team as a code owner September 20, 2024 16:21
@robertcoltheart
Copy link
Contributor Author

I've added some additional tests as requested. I think a follow-up PR is required to refactor these tests a bit, since we have quite a few different combinations of conditions.

@CodeBlanch CodeBlanch changed the title Add meter-level tags to Prometheus exporter [prometheus] Support meter-level tags Sep 23, 2024
@CodeBlanch CodeBlanch added the metrics Metrics signal related label Sep 23, 2024
@CodeBlanch CodeBlanch merged commit 60b7d9b into open-telemetry:main Sep 23, 2024
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
metrics Metrics signal related pkg:OpenTelemetry.Exporter.Prometheus.AspNetCore Issues related to OpenTelemetry.Exporter.Prometheus.AspNetCore NuGet package pkg:OpenTelemetry.Exporter.Prometheus.HttpListener Issues related to OpenTelemetry.Exporter.Prometheus.HttpListener NuGet package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants