Skip to content

Prometheus exporter sanitize info metric#3572

Merged
ocelotl merged 5 commits intoopen-telemetry:mainfrom
kornerc:prometheus_sanitize_info
Dec 15, 2023
Merged

Prometheus exporter sanitize info metric#3572
ocelotl merged 5 commits intoopen-telemetry:mainfrom
kornerc:prometheus_sanitize_info

Conversation

@kornerc
Copy link
Copy Markdown
Contributor

@kornerc kornerc commented Dec 7, 2023

Description

The Prometheus Exporter did not sanitize the info metric.
This might prevent successful scraping from Prometheus when having, for example, dots in an attribute.

Fixes #3571 and #3563

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • Unit test test_target_info_sanitize which checks if a character like a dot . in an attribute name is translated to an underscore _.

Does This PR Require a Contrib Repo Change?

  • No.

Checklist:

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

@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla bot commented Dec 7, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

@kornerc kornerc marked this pull request as ready for review December 10, 2023 09:43
@kornerc kornerc requested a review from a team December 10, 2023 09:43
@kornerc
Copy link
Copy Markdown
Contributor Author

kornerc commented Dec 10, 2023

PR is ready for review.

I think there is no need to update the documentation, nonetheless, I left in the checklist Documentation has been updated unchecked.

During the fix I found another issue in a test:


Parts of the test are not executed because result[:0] returns an empty list, instead it should be something like prometheus_metric = result[0].
But I guess it is better to make a separate issue and PR for this (I can do that).

@Jdsleppy
Copy link
Copy Markdown

@kornerc It looks like linting failed because black formatting was not applied. You can check this locally using

pip install tox==3.27.1
tox -e lint

To fix, you can use

pip install -r dev-requirements.txt
python -m black .

I'm now looking into the other CI failure to see how to fix it.

@Jdsleppy
Copy link
Copy Markdown

@kornerc It seems like the only other error was unrelated:

ERROR:   py37-test-instrumentation-falcon3: commands failed

So we can probably get this reviewed after linting is fixed.

@aabmass
Copy link
Copy Markdown
Member

aabmass commented Dec 14, 2023

Thanks for the PR!

@kornerc
Copy link
Copy Markdown
Contributor Author

kornerc commented Dec 14, 2023

@kornerc It looks like linting failed because black formatting was not applied. You can check this locally using

pip install tox==3.27.1
tox -e lint

To fix, you can use

pip install -r dev-requirements.txt
python -m black .

I'm now looking into the other CI failure to see how to fix it.

@Jdsleppy thanks for the feedback and the info!

In 170647e I reformattet the code and tox -e lint does not complain anymore about the formatting.

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.

Prometheus metric target_info with SERVICE_NAME contains a dot

4 participants