-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[mdatagen] move telemetry into its own file (#10037)
This is in preparation for using mdatagen for component telemetry. --------- Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com>
- Loading branch information
Showing
48 changed files
with
1,301 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 0 additions & 11 deletions
11
cmd/mdatagen/internal/samplereceiver/internal/metadata/generated_status.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
cmd/mdatagen/internal/samplereceiver/internal/metadata/generated_telemetry.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
63 changes: 63 additions & 0 deletions
63
cmd/mdatagen/internal/samplereceiver/internal/metadata/generated_telemetry_test.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Code generated by mdatagen. DO NOT EDIT. | ||
|
||
package {{ .Package }} | ||
|
||
import ( | ||
"go.opentelemetry.io/collector/component" | ||
"go.opentelemetry.io/otel/metric" | ||
"go.opentelemetry.io/otel/trace" | ||
) | ||
|
||
func Meter(settings component.TelemetrySettings) metric.Meter { | ||
return settings.MeterProvider.Meter("{{ .ScopeName }}") | ||
} | ||
|
||
func Tracer(settings component.TelemetrySettings) trace.Tracer { | ||
return settings.TracerProvider.Tracer("{{ .ScopeName }}") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Code generated by mdatagen. DO NOT EDIT. | ||
|
||
package {{ .Package }} | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
"go.opentelemetry.io/otel/metric" | ||
embeddedmetric "go.opentelemetry.io/otel/metric/embedded" | ||
noopmetric "go.opentelemetry.io/otel/metric/noop" | ||
"go.opentelemetry.io/otel/trace" | ||
embeddedtrace "go.opentelemetry.io/otel/trace/embedded" | ||
nooptrace "go.opentelemetry.io/otel/trace/noop" | ||
|
||
"go.opentelemetry.io/collector/component" | ||
) | ||
|
||
type mockMeter struct { | ||
noopmetric.Meter | ||
name string | ||
} | ||
type mockMeterProvider struct { | ||
embeddedmetric.MeterProvider | ||
} | ||
|
||
func (m mockMeterProvider) Meter(name string, opts ...metric.MeterOption) metric.Meter { | ||
return mockMeter{name: name} | ||
} | ||
|
||
type mockTracer struct { | ||
nooptrace.Tracer | ||
name string | ||
} | ||
|
||
type mockTracerProvider struct { | ||
embeddedtrace.TracerProvider | ||
} | ||
|
||
func (m mockTracerProvider) Tracer(name string, opts ...trace.TracerOption) trace.Tracer { | ||
return mockTracer{name: name} | ||
} | ||
|
||
func TestProviders(t *testing.T) { | ||
set := component.TelemetrySettings{ | ||
MeterProvider: mockMeterProvider{}, | ||
TracerProvider: mockTracerProvider{}, | ||
} | ||
|
||
meter := Meter(set) | ||
if m, ok := meter.(mockMeter); ok { | ||
require.Equal(t, "{{ .ScopeName }}", m.name) | ||
} else { | ||
require.Fail(t, "returned Meter not mockMeter") | ||
} | ||
|
||
tracer := Tracer(set) | ||
if m, ok := tracer.(mockTracer); ok { | ||
require.Equal(t, "{{ .ScopeName }}", m.name) | ||
} else { | ||
require.Fail(t, "returned Meter not mockTracer") | ||
} | ||
} |
11 changes: 0 additions & 11 deletions
11
connector/forwardconnector/internal/metadata/generated_status.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
connector/forwardconnector/internal/metadata/generated_telemetry.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.