-
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// Package internal provides internal functionality for the sdk/metric package. | ||
package internal // import "go.opentelemetry.io/otel/sdk/metric/internal" | ||
|
||
//go:generate gotmpl --body=../../../internal/shared/x/x.go.tmpl "--data={ \"pkg\": \"go.opentelemetry.io/otel/sdk/metric\" }" --out=x/x.go | ||
//go:generate gotmpl --body=../../../internal/shared/x/x_test.go.tmpl "--data={}" --out=x/x_test.go |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package x // import "go.opentelemetry.io/otel/sdk/metric/internal/x" | ||
|
||
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 commentThe reason will be displayed to describe this comment to others. Learn more. Can we keep the original comments? |
||
// Enabled reports whether the instrument will process measurements for the given context. | ||
// | ||
// This function can be used in places where measuring an instrument | ||
// would result in computationally expensive operations. | ||
Enabled(context.Context) bool | ||
} | ||
ternua8 marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package x | ||
MrAlias marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
type testInstrument struct{} | ||
|
||
func (*testInstrument) Enabled(_ context.Context) bool { | ||
return true | ||
} | ||
|
||
func TestEnabledInstrument(t *testing.T) { | ||
var ei EnabledInstrument = &testInstrument{} | ||
|
||
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 commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps using |
||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.