Skip to content

Prometheus label conversion refactored to align with spec #7291

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

onurkybsi
Copy link
Contributor

Resolves the issue #5987.

Copy link

codecov bot commented Apr 22, 2025

Codecov Report

Attention: Patch coverage is 56.86275% with 22 lines in your changes missing coverage. Please review.

Project coverage is 89.94%. Comparing base (29523e6) to head (3a8324b).

Files with missing lines Patch % Lines
.../exporter/prometheus/Otel2PrometheusConverter.java 56.86% 18 Missing and 4 partials ⚠️

❌ Your patch check has failed because the patch coverage (56.86%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #7291      +/-   ##
============================================
- Coverage     90.03%   89.94%   -0.09%     
- Complexity     6915     6925      +10     
============================================
  Files           787      787              
  Lines         20864    20914      +50     
  Branches       2023     2034      +11     
============================================
+ Hits          18784    18812      +28     
- Misses         1441     1459      +18     
- Partials        639      643       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@onurkybsi onurkybsi marked this pull request as ready for review April 22, 2025 06:25
@onurkybsi onurkybsi requested a review from a team as a code owner April 22, 2025 06:25
*
* @return {@code true} if primitive, otherwise {@code false}
*/
public boolean isPrimitive() {
Copy link
Member

Choose a reason for hiding this comment

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

I'd recommend avoiding adding any new public API since that has to meet a pretty high bar for us

Copy link
Member

Choose a reason for hiding this comment

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

Yup - let's just keep this as a utility method in Otel2PrometheusConverter.

*
* @return {@code true} if primitive, otherwise {@code false}
*/
public boolean isPrimitive() {
Copy link
Contributor

Choose a reason for hiding this comment

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

This could be implemented as an EnumSet#contains, it would save some lines and could be slightly more efficient


private static String maybeToJson(Object attributeValue) {
try {
return OBJECT_MAPPER.writeValueAsString(attributeValue);
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we only need to serialize non-primitive types in AttributeType, maybe this could be done "by hand", with a simple StringBuilder and a loop? This PR seems to be the only reason to have Jackson in the classpath, so maybe it's worth considering at least

Copy link
Member

Choose a reason for hiding this comment

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

I agree.

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.

4 participants