Skip to content

Metric SDK label Enricher interface#1421

Closed
jmacd wants to merge 9 commits intoopen-telemetry:masterfrom
jmacd:jmacd/enrich
Closed

Metric SDK label Enricher interface#1421
jmacd wants to merge 9 commits intoopen-telemetry:masterfrom
jmacd:jmacd/enrich

Conversation

@jmacd
Copy link
Copy Markdown
Contributor

@jmacd jmacd commented Dec 23, 2020

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.

@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 23, 2020

Codecov Report

Merging #1421 (1447197) into master (fe9d1f7) will increase coverage by 0.0%.
The diff coverage is 94.7%.

Impacted file tree graph

@@          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           
Impacted Files Coverage Δ
sdk/export/metric/metric.go 97.3% <ø> (ø)
sdk/metric/sdk.go 81.1% <93.7%> (+0.9%) ⬆️
baggage/baggage.go 100.0% <100.0%> (ø)
sdk/metric/controller/pull/pull.go 100.0% <100.0%> (ø)
sdk/metric/controller/push/push.go 96.3% <100.0%> (+<0.1%) ⬆️

@jmacd
Copy link
Copy Markdown
Contributor Author

jmacd commented Dec 23, 2020

@hstan I hope you don't mind that I experimented around the topic of your PR #1271. I ended up writing a few more comments on the behavior of the enricher, see what you think.

@open-telemetry/specs-metrics-approvers This is important for the OpenCensus vision. Please review.

Copy link
Copy Markdown
Member

@punya punya left a 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.

Comment thread sdk/metric/sdk.go
// 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 {
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.

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).

Comment thread sdk/metric/sdk.go
Comment on lines +368 to +372
// Return the enricher result if it is non-nil and no error.
if err == nil && out != nil {
return out
}
otel.Handle(err)
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.

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.

Suggested change
// 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

@punya
Copy link
Copy Markdown
Member

punya commented Dec 28, 2020

@jmacd my apologies, please feel free to disregard my review comments if you wish - I somehow failed to notice that this is a draft.

@jmacd
Copy link
Copy Markdown
Contributor Author

jmacd commented Jan 5, 2021

@bogdandrutu Please review.

@jmacd
Copy link
Copy Markdown
Contributor Author

jmacd commented Jan 14, 2021

I will re-open this later if needed, closing this as we have #1271.

@jmacd jmacd closed this Jan 14, 2021
This was referenced Jan 19, 2021
@jmacd jmacd deleted the jmacd/enrich branch July 7, 2022 15:08
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.

2 participants