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

Add prometheus bridge #4351

Closed
wants to merge 1 commit into from

Conversation

dashpole
Copy link
Contributor

@dashpole dashpole commented Jul 22, 2023

This allows applications instrumented with the prometheus client library to use OpenTelemetry exporters (e.g. OTLP).

Limitations:

  • Summary metrics are dropped by the bridge. This could be fixed if we added the summary types to our data model (which I am personally against), or we could convert the summary to individual gauge and counter series.
  • Start times for histograms and counters are set to the process start time. This would only not be correct when using custom collectors, which is relatively uncommon. That will be fixed when the prometheus client allows recording start times for their instruments.

Despite the limitations, I think this still has a lot of value to users.

@dashpole dashpole force-pushed the prometheus_bridge branch 8 times, most recently from 06bb868 to de01c0f Compare July 24, 2023 13:08
@codecov
Copy link

codecov bot commented Jul 24, 2023

Codecov Report

Merging #4351 (663ff6c) into main (830fae8) will increase coverage by 0.0%.
The diff coverage is 84.9%.

Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff           @@
##            main   #4351    +/-   ##
======================================
  Coverage   83.4%   83.4%            
======================================
  Files        184     186     +2     
  Lines      14383   14569   +186     
======================================
+ Hits       12002   12162   +160     
- Misses      2153    2172    +19     
- Partials     228     235     +7     
Files Changed Coverage Δ
bridge/prometheus/producer.go 83.5% <83.5%> (ø)
bridge/prometheus/config.go 100.0% <100.0%> (ø)

... and 1 file with indirect coverage changes

@dashpole dashpole changed the title Add prometheus bridge Prototype: Add prometheus bridge Jul 24, 2023
@dashpole dashpole force-pushed the prometheus_bridge branch 2 times, most recently from c9dff79 to ab50b0f Compare July 24, 2023 14:01
@dashpole dashpole force-pushed the prometheus_bridge branch 3 times, most recently from c528092 to 36b45cf Compare July 26, 2023 16:25
@dashpole dashpole changed the title Prototype: Add prometheus bridge Add prometheus bridge Jul 26, 2023
@dashpole dashpole marked this pull request as ready for review July 26, 2023 16:33
@bwplotka
Copy link

bwplotka commented Aug 1, 2023

Epic work!

We were actually discussing similar with Prometheus client maintainers. Not sure what form we all prefer and what's better for community, but perhaps it would make sense to either host or at least document such option on https://github.com/prometheus/client_golang (client_golang maintainer here). I think it would need to be a separate Go module given Otel deps, but generally seamless extension of client_golang instrumentation to push with OTLP metrics, maintained in collaboration and available to users would be nice. cc @beorn7 @kakkoyun We are open for suggestions.

As per created timestamp, we are working on it (feedback welcome):

return otelCounter
}

func convertHistogram(metrics []*dto.Metric, now time.Time) metricdata.Histogram[float64] {
Copy link

Choose a reason for hiding this comment

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

I think this does not support Native Histograms (exponential ones): https://github.com/prometheus/client_model/blob/master/io/prometheus/client/metrics.proto#L82

That's fine, but let's provide clean error/warning and TODO (:

otelMetrics := make([]metricdata.Metrics, 0)
for _, pm := range promMetrics {
newMetric := metricdata.Metrics{
Name: pm.GetName(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this necessary to convert prometheus metric name to otlp metrics name?
For example convert http_request_duration_count to http.request.duration.count?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately, it isn't feasible to do that, as otel can have underscores in names as well (e.g. my.very_special.metric)

)

// config contains options for the exporter.
type config struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

small nit: I think you mean "config contains options for the producer", not exporter

}

// Option sets exporter option values.
type Option interface {
Copy link
Contributor

Choose a reason for hiding this comment

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

same here, exporter -> producer

@dashpole dashpole marked this pull request as draft August 15, 2023 13:41
@dashpole
Copy link
Contributor Author

@open-telemetry/proto-go-approvers I was thinking maybe this makes more sense in contrib? It isn't really a "core" part of what OTel requires from SDKs.

@MrAlias
Copy link
Contributor

MrAlias commented Aug 21, 2023

@open-telemetry/proto-go-approvers I was thinking maybe this makes more sense in contrib? It isn't really a "core" part of what OTel requires from SDKs.

I'm not opposed. What are your thoughts on hosting this in a personal/3rd party repository?

@dashpole
Copy link
Contributor Author

I'm not a huge fan of personal repos, as it makes ownership changes harder on users. The other option would be for me to ask the prometheus maintainers to host this in a Prometheus-owned repository. When I last spoke with them, they were OK with that. If i'm initially maintaining the bridge, it is probably easiest for me to do so in an OTel repository, as i'm an approver.

@MrAlias
Copy link
Contributor

MrAlias commented Aug 21, 2023

I'm not a huge fan of personal repos, as it makes ownership changes harder on users. The other option would be for me to ask the prometheus maintainers to host this in a Prometheus-owned repository. When I last spoke with them, they were OK with that. If i'm initially maintaining the bridge, it is probably easiest for me to do so in an OTel repository, as i'm an approver.

Yeah, contrib sounds good to me then if you plan to act as a maintainer for it 👍

@dashpole
Copy link
Contributor Author

Superseded by open-telemetry/opentelemetry-go-contrib#4227

@dashpole dashpole closed this Aug 21, 2023
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.

None yet

4 participants