8000 otlp: Migrating translator packages by ArthurSens · Pull Request #16089 · prometheus/prometheus · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

otlp: Migrating translator packages #16089

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

Closed
wants to merge 3 commits into from
Closed

Conversation

ArthurSens
Copy link
Member
@ArthurSens ArthurSens commented Feb 28, 2025

As discussed with multiple peers in the last couple of quarters(yes, quarters 😅), @ywwg and I started experiments to avoid duplicated code between Prometheus and OpenTelemetry-Collector for translating OTel to Prometheus metric and label names.

The experiments led to https://github.com/ArthurSens/otlp-prometheus-translator, but I'm very happy to move it somewhere else, like prometheus/common, or into a separate repository in the Prometheus org, where we can make other folks maintainers.

EDIT: Package moved to https://github.com/prometheus/common/tree/main/otlptranslator

Motivation for the new module

  • Avoid code variance between Prometheus and Collector.

Goals

  • Dependency-free, so it can be re-used by both Prometheus and OpenTelemetry-Collector
  • Efficient: we can't bring regressions compared to the existing codebase.

Opening as a draft to continue discussions! I think we want to ask/answer questions before committing

@ArthurSens ArthurSens changed the title WIP: Migrating translator packages WIP/otlp: Migrating translator packages Feb 28, 2025
go.mod Outdated
@@ -5,6 +5,7 @@ go 1.22.7
toolchain go1.23.4

require (
github.com/ArthurSens/otlp-prometheus-translator v0.0.0-20250228115610-6db8fa672349
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for splitting this into new module! Would be super useful for downstream callers that support otlp ingestion like Thanos.

I wonder if a good place for this module might be in https://github.com/prometheus/client_golang/tree/main/exp? As this is zero dep already, will probably be treated as experimental for some time and will have several downstream callers. Wdyt? cc: @bwplotka

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it sounds very out of scope for client golang🤔, but super happy to move elsewhere in the Prometheus org

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, I didn't fully clarify my thinking there. client_golang scope to me is "instrumentation lib + clients/utilities to interact with Prometheus and its APIs". otlp (like remote write) is an accepted way of interacting with Prometheus, so code for otlp translation, can probably live there as a submodule (near some of the remote write API handling code that is in exp). 🙂

However, not blocking anything, prometheus/common would be good too.

Copy link
Member

Choose a reason for hiding this comment

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

Yea, I would recommend separate repo for now, so it can have more external maintainers e.g. in prom org, no harm in that vs it might overload client_golang.

@ArthurSens ArthurSens force-pushed the migrate-translator-pkgs branch from bbc7321 to 0d0db32 Compare March 13, 2025 16:52
@ArthurSens ArthurSens marked this pull request as ready for review March 13, 2025 16:52
@ArthurSens ArthurSens marked this pull request as draft March 13, 2025 17:45
Signed-off-by: Arthur Silva Sens <arthursens2005@gmail.com>
Signed-off-by: Arthur Silva Sens <arthursens2005@gmail.com>
Signed-off-by: Arthur Silva Sens <arthursens2005@gmail.com>
@ArthurSens ArthurSens force-pushed the migrate-translator-pkgs branch from 0d0db32 to a767f14 Compare March 13, 2025 20:06
@ArthurSens ArthurSens changed the title WIP/otlp: Migrating translator packages otlp: Migrating translator packages Mar 13, 2025
@ArthurSens ArthurSens marked this pull request as ready for review March 13, 2025 20:07
@aknuds1
Copy link
Contributor
aknuds1 commented Mar 14, 2025

I'm testing whether this will work with Grafana Mimir.

Copy link
Contributor
@aknuds1 aknuds1 left a comment

Choose a reason for hiding this comment

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

Please see my question.

@@ -762,7 +762,7 @@ func TestPrometheusConverter_addExponentialHistogramDataPoints(t *testing.T) {
Settings{
ExportCreatedMetric: true,
},
prometheustranslator.BuildCompliantMetricName(metric, "", true),
translator.BuildCompliantMetricName(metric.Name(), metric.Unit(), getTranslatorMetricType(metric), true),
Copy link
Contributor
@aknuds1 aknuds1 Mar 14, 2025

Choose a reason for hiding this comment

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

Why does the translator operate with its own metric types, instead of using metric.Type? That looks like a bad duplication to me. Also, why can't translator.BuildCompliantMetricName just take metric as before? The new API looks like a change for the worse for me.

Copy link
Contributor
@aknuds1 aknuds1 Mar 14, 2025

Choose a reason for hiding this comment

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

Basically, I'd like rationale for the changes made in common versus the corresponding code in storage/remote/otlptranslator/prometheus. They don't look like an improvement, but I'm open to the possibility that I'm missing something.

Copy link
Member Author

Choose a reason for hiding this comment

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

We wanted to be dependency free so it's easy to import anywhere.

Making the library dependent on Otel, and then Otel dependent on the library would be super hard to work with.

Is the signature change that bad in your opinion? We're not passing a giant object anymore, so it might even have better performance...? (I haven't done benchmarks about this specifically)

Copy link
Contributor
@aknuds1 aknuds1 Mar 14, 2025

Choose a reason for hiding this comment

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

We wanted to be dependency free so it's easy to import anywhere.

Making the library dependent on Otel, and then Otel dependent on the library would be super hard to work with.

I will try myself, to see what the dependency problem looks like. Thanks for the explanation.

Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure if I explained it well, the problem is circular dependency

https://en.wikipedia.org/wiki/Circular_dependency

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I understood you meant a circular dependency. I just have to try for myself, to see whether it can be avoided.

Copy link
Contributor
@aknuds1 aknuds1 Mar 17, 2025

Choose a reason for hiding this comment

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

@ArthurSens See my attempt at using the OTel SDK instead. There's no circular dependency when combining prometheus/common and prometheus/prometheus. Does it somehow happen when combining with OTel? If so, please provide a demonstration.

Copy link
Contributor

Choose a reason for hiding this comment

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

From our discussion in Slack, it was established that depending on OTel SDK metric types, as in my prototype, most likely doesn't cause any circular dependencies after all.

Copy link
Contributor
@aknuds1 aknuds1 left a comment

Choose a reason for hiding this comment

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

Truly sorry, but I can't review this PR in its current state because it's too painful due to how much changes in prometheus/common/otlptranslator versus the current code base.

To enable me to review the PR, please do the following:

  1. Please revert the prometheus/common/otlptranslator package to using the OTel SDK (go.opentelemetry.io/collector/pdata) as in my branch (as no cyclical dependencies can be established as was originally claimed).
  2. Please revert the prometheus/common/otlptranslator package code to be as similar as possible to the code being moved from the prometheus/prometheus repo. Diffing is currently impossible, due to code changing around so much.

After an initial PR with the sole goal of moving code from prometheus/prometheus to prometheus/common, we can think about other improvements. Let's not do everything at once, since it puts too much burden on the reviewer and I don't feel safe about the changes. As a rule of thumb, PRs should in any case be single topic.

@ArthurSens
Copy link
Member Author
ArthurSens < 9E88 /strong> commented Mar 20, 2025

superseeded by #16240

@ArthurSens ArthurSens closed this Mar 20, 2025
@ArthurSens ArthurSens deleted the migrate-translator-pkgs branch March 20, 2025 22:45
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.

5 participants
0