-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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 OpenCensus reader Bridge, and Prometheus Bridge option #3207
Conversation
5d3b242
to
8dccde6
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #3207 +/- ##
=======================================
+ Coverage 77.3% 77.6% +0.3%
=======================================
Files 159 159
Lines 11184 11222 +38
=======================================
+ Hits 8651 8719 +68
+ Misses 2335 2303 -32
- Partials 198 200 +2
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good! Only one small comment.
8dccde6
to
becf42b
Compare
Notes from the SIG meeting:
|
5bae1e9
to
251a124
Compare
I implemented the idea I had at the end of the sig meeting, which is to have prometheus define an interface without the rest of the Reader functions. It makes it much less bad IMO. It is now prometheus-specific, but that could be changed if we put the Bridge interface somewhere else. |
exporters/prometheus/exporter.go
Outdated
// Bridge is a source of metrics other than the OpenTelemetry SDK. | ||
type Bridge interface { | ||
// Collect gathers and returns all metric data from the Bridge. | ||
Collect(context.Context) (metricdata.ScopeMetrics, error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that this provides a ScopeMetrics, rather than a ResourceMetrics. This ensures we only get the resource from the SDK.
251a124
to
16b5178
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
5dd1ca1
to
977ccf6
Compare
} | ||
|
||
// ExportMetrics implements the OpenCensus metric Exporter interface by sending | ||
// to an OpenTelemetry exporter. | ||
func (e *exporter) ExportMetrics(ctx context.Context, ocmetrics []*ocmetricdata.Metric) error { | ||
otelmetrics, err := internal.ConvertMetrics(ocmetrics) | ||
if err != nil { | ||
return err | ||
otel.Handle(err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was a bug I found while adding unit tests. This allows the bridge to have partial success sending metrics, and keeps the behavior of the previous OC bridge implementation.
977ccf6
to
e07b2e5
Compare
This is ready for review now. |
3777f81
to
e9512d0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @dashpole!
As part of planning the migration of the otel collector instrumentation from OpenCensus to Otel Go, this would help us being able to have an incremental and hopefully smoother migration of the existing instrumentation in the collector core and contrib project.
Without the bridge our option would be to migrate the whole project (and contrib) at once, or migrate it incrementally to otel go losing some metrics in the first moment until everything gets migrated.
c9f8dde
to
e86b040
Compare
e86b040
to
91e170f
Compare
This is a way to unblock the collectors' use of the opencensus bridge + prometheus exporter. It adds a WithBridge option to the prometheus exporter. It only works for prometheus, and not other pull exporters.
Example usage:
This does not align with what is currently being discussed in the specification PR, but will solve the problem for the collector while we work on that.