-
Notifications
You must be signed in to change notification settings - Fork 1.2k
chore: sdk/metric/internal/x - generate x package from x component template (#7386) #7430
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
base: main
Are you sure you want to change the base?
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7430 +/- ##
=====================================
Coverage 86.1% 86.2%
=====================================
Files 291 291
Lines 25615 25620 +5
=====================================
+ Hits 22059 22086 +27
+ Misses 3183 3162 -21
+ Partials 373 372 -1
🚀 New features to boost your workflow:
|
Is there a tracking issue for EnabledInstrument? |
@ternua8 it looks like the linter is failing. Please run |
@@ -0,0 +1,12 @@ | |||
package x |
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.
package x | |
// Copyright The OpenTelemetry Authors | |
// SPDX-License-Identifier: Apache-2.0 | |
package x |
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.
ok!
@ternua8 are you still able to work on this? |
Hey, just returned from vacation — I can pick this up again! |
a48c48e
to
0afbbf1
Compare
0afbbf1
to
d9451fb
Compare
d9451fb
to
071f8c8
Compare
import "context" | ||
|
||
// EnabledInstrument interface is implemented by synchronous instruments. | ||
type EnabledInstrument interface { |
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.
Can we keep the original comments?
ctx := t.Context() | ||
enabled := ei.Enabled(ctx) | ||
|
||
require.True(t, enabled, "Enabled() should return true") |
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.
Perhaps using assert.Implements(....)
would be more appropriate.
|
||
import "context" | ||
|
||
// EnabledInstrument interface is implemented by synchronous instruments. |
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.
// EnabledInstrument interface is implemented by synchronous instruments. | |
// EnabledInstrument informs whether the instrument is enabled. | |
// | |
// EnabledInstrument interface is implemented by synchronous instruments. |
Summary
Switch the metric
x
package to template-based generation, similar to trace.Add the
EnabledInstrument
interface in a separate file for synchronous instruments.Details
sdk/metric/internal/x/gen.go
uses the sharedx.go.tmpl
to generatex.go
andx_test.go
.EnabledInstrument
interface is added inenabled_instrument.go
to allow instruments to report if they are enabled.enabled_instrument_test.go
.Notes
newFeature
function generated by the template is currently unused in metric, but it is kept for consistency with trace.