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

feat(prometheus): serialize resource as target_info gauge #3300

Conversation

pichlermarc
Copy link
Member

Which problem is this PR solving?

This PR updates the PrometheusExporter to export Resource as a gauge-typed target_info metric according to the specification here.

  • When serializing resources, service.name and service.namespace are dropped from the resource attributes and used to construct the job label.
    • If job is already present in the resource, it is dropped instead.
  • When serializing resources service.instance.id is dropped from the resource attributes, and its contents are added to the instance label.
    • If job is already present in the resource, it is dropped instead.

Fixes #867

Short description of the changes

Export Resource as a single gauge-typed target_info metric.

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

  • Added Unit tests
  • Adapted existing tests.

Checklist:

  • Followed the style guidelines of this project
  • Unit tests have been added
  • Documentation has been updated

@pichlermarc pichlermarc force-pushed the feature/prometheus-serializer-resources branch from fc1e5d6 to ccc1899 Compare October 7, 2022 07:55
@codecov
Copy link

codecov bot commented Oct 7, 2022

Codecov Report

Merging #3300 (ea81f11) into main (92f2359) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3300   +/-   ##
=======================================
  Coverage   93.04%   93.05%           
=======================================
  Files         226      226           
  Lines        6517     6522    +5     
  Branches     1360     1360           
=======================================
+ Hits         6064     6069    +5     
  Misses        453      453           
Impacted Files Coverage Δ
...etry-exporter-prometheus/src/PrometheusExporter.ts 92.00% <100.00%> (-0.41%) ⬇️
...ry-exporter-prometheus/src/PrometheusSerializer.ts 95.65% <100.00%> (+0.30%) ⬆️

@pichlermarc pichlermarc marked this pull request as ready for review October 7, 2022 08:54
@pichlermarc pichlermarc requested a review from a team October 7, 2022 08:54
@dyladan
Copy link
Member

dyladan commented Oct 12, 2022

I think the lint failure was intermittent

@dyladan dyladan merged commit 3ab8bfc into open-telemetry:main Oct 17, 2022
@dyladan dyladan deleted the feature/prometheus-serializer-resources branch October 17, 2022 12:16
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.

Support Resource in the Prometheus Exporter
5 participants