Skip to content

[receiver/prometheusremotewritereceiver] accept unspecified histograms#44091

Merged
songy23 merged 3 commits into
open-telemetry:mainfrom
jelly-afk:support-unspecified-histogram
Nov 13, 2025
Merged

[receiver/prometheusremotewritereceiver] accept unspecified histograms#44091
songy23 merged 3 commits into
open-telemetry:mainfrom
jelly-afk:support-unspecified-histogram

Conversation

@jelly-afk

Copy link
Copy Markdown
Contributor

Description

prometheusremote write receiver now accepts histogram with unspecified metric type.

Link to tracking issue

Fixes #41840

Testing

Added two test cases in the TestTranslateV2 test function to test unspecified histograms.

switch ts.Metadata.Type {
case writev2.Metadata_METRIC_TYPE_HISTOGRAM:
histMetric.Metadata().PutStr(prometheus.MetricMetadataTypeKey, "histogram")
default:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

isn't not missing this case -> writev2.Metadata_METRIC_TYPE_UNSPECIFIED

@jelly-afk jelly-afk force-pushed the support-unspecified-histogram branch from c6d7120 to 27a2adf Compare November 7, 2025 14:20
@VihasMakwana

Copy link
Copy Markdown
Contributor

@jelly-afk Could you please fix the CI?

@jelly-afk jelly-afk force-pushed the support-unspecified-histogram branch from 27a2adf to 0028929 Compare November 12, 2025 15:28

@VihasMakwana VihasMakwana left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good. Needs a codeowner review to be ready-to-merge

@perebaj perebaj left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just some nits. But many thanks for that effort!

Comment on lines +522 to +523
default:
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe the default case should return an error? This because we are talking about a not listed case/

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@ArthurSens or @dashpole do you have a different opinion about it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We shouldn't encounter any other metric types here, as we have already validated the types here

if ts.Metadata.Type == writev2.Metadata_METRIC_TYPE_HISTOGRAM || ts.Metadata.Type == writev2.Metadata_METRIC_TYPE_UNSPECIFIED && len(ts.Histograms) > 0

So it can only be either a histogram or an unspecified histogram.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What do you think if we add a comment under the default option with this info? Saying that as we are only dealing with histograms inside the processHistogramTimeSeries we don't need to define a behavior for this option.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sounds good.

},
Timeseries: []writev2.TimeSeries{
{
LabelsRefs: []uint32{1, 2, 3, 4, 5, 6}, // __name__=test_hncb_histogram, job=test, instance=localhost:8080

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think that this comment doesn't help us a lot. WDYT?

Suggested change
LabelsRefs: []uint32{1, 2, 3, 4, 5, 6}, // __name__=test_hncb_histogram, job=test, instance=localhost:8080
LabelsRefs: []uint32{1, 2, 3, 4, 5, 6},
instance=localhost:8080

Comment on lines +1504 to +1512
"",
"__name__",
"test_hncb_histogram",
"job",
"test",
"instance",
"localhost:8080",
"seconds",
"Test NHCB histogram",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we follow the same pattern as the other test cases?

Suggested change
"",
"__name__",
"test_hncb_histogram",
"job",
"test",
"instance",
"localhost:8080",
"seconds",
"Test NHCB histogram",
"",
"__name__", "test_hncb_histogram", // 1, 2
"job", "test", // 3, 4
"instance", "localhost:8080", // 5, 6
"seconds", "Test NHCB histogram", // 7, 8

Maybe accepting this change, the linter will break.

@jelly-afk jelly-afk force-pushed the support-unspecified-histogram branch from a024087 to f43b1bf Compare November 13, 2025 13:27

@ArthurSens ArthurSens left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thank you :)

@ArthurSens ArthurSens added the ready to merge Code review completed; ready to merge by maintainers label Nov 13, 2025
@songy23 songy23 merged commit bae9d36 into open-telemetry:main Nov 13, 2025
189 checks passed
@github-actions github-actions Bot added this to the next release milestone Nov 13, 2025
@otelbot

otelbot Bot commented Nov 13, 2025

Copy link
Copy Markdown
Contributor

Thank you for your contribution @jelly-afk! 🎉 We would like to hear from you about your experience contributing to OpenTelemetry by taking a few minutes to fill out this survey. If you are getting started contributing, you can also join the CNCF Slack channel #opentelemetry-new-contributors to ask for guidance and get help.

aureleoules pushed a commit to DataDog/opentelemetry-collector-contrib that referenced this pull request Nov 14, 2025
open-telemetry#44091)

<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
prometheusremote write receiver now accepts histogram with unspecified
metric type.

<!-- Issue number (e.g. #1234) or full URL to issue, if applicable. -->
#### Link to tracking issue
Fixes open-telemetry#41840 

<!--Describe what testing was performed and which tests were added.-->
#### Testing
Added two test cases in the TestTranslateV2 test function to test
unspecified histograms.

---------

Co-authored-by: Yang Song <songy23@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready to merge Code review completed; ready to merge by maintainers receiver/prometheusremotewrite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[receiver/prometheusremotewrite] Support METRIC_TYPE_UNSPECIFIED

6 participants