-
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
Metric SDK label Enricher interface #1421
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1421 +/- ##
======================================
Coverage 78.6% 78.7%
======================================
Files 126 126
Lines 6367 6384 +17
======================================
+ Hits 5009 5025 +16
- Misses 1114 1115 +1
Partials 244 244
|
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.
A few small localized comments, I am still learning about the overall codebase.
@@ -301,11 +307,12 @@ func (s *syncInstrument) RecordOne(ctx context.Context, num number.Number, kvs [ | |||
// processor will call Collect() when it receives a request to scrape | |||
// current metric values. A push-based processor should configure its | |||
// own periodic collection. | |||
func NewAccumulator(processor export.Processor, resource *resource.Resource) *Accumulator { | |||
func NewAccumulator(processor export.Processor, resource *resource.Resource, enricher export.Enricher) *Accumulator { |
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.
Is it worth using a functional option varargs parameter instead of adding enricher
as a required parameter? It would make the call sites more readable, and preserve compatibility for existing calls (in particular, this diff would be shorter).
// Return the enricher result if it is non-nil and no error. | ||
if err == nil && out != nil { | ||
return out | ||
} | ||
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.
If out == nil
, we will invoke otel.Handle(nil)
. I couldn't find any documentation for what otel.Handle
is supposed to do in that case.
// Return the enricher result if it is non-nil and no error. | |
if err == nil && out != nil { | |
return out | |
} | |
otel.Handle(err) | |
if err != nil { | |
otel.Handle(err) | |
return kvs | |
} | |
if out == nil { | |
return kvs | |
} | |
return out |
@jmacd my apologies, please feel free to disregard my review comments if you wish - I somehow failed to notice that this is a draft. |
@bogdandrutu Please review. |
I will re-open this later if needed, closing this as we have #1271. |
This adds an
Enricher
API that supports attaching baggage attributes as metric labels.This was a core feature of OpenCensus that OTel metrics hasn't implemented here, and we think this support will be specified for the default SDK.
Inspired by #1271 (@hstan) and my comments there.
This PR is a draft until #1378 merges, after which I'll add a setting to the controller and an example.