Skip to content

Commit

Permalink
[mdatagen] export ScopeName in internal/metadata package
Browse files Browse the repository at this point in the history
This can be used by components that need to set their scope name manually. Will save component owners from having to store a variable, which may diverge from the scope name used by the component for emitting its own telemetry.

Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com>
  • Loading branch information
codeboten committed Aug 8, 2024
1 parent ecbe02e commit 277384b
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 20 deletions.
25 changes: 25 additions & 0 deletions .chloggen/codeboten_mdatagen-expose-scope-name.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
component: mdatagen

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: export ScopeName in internal/metadata package

# One or more tracking issues or pull requests related to the change
issues: []

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext: This can be used by components that need to set their scope name manually. Will save component owners from having to store a variable, which may diverge from the scope name used by the component for emitting its own telemetry.

# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: []

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions cmd/mdatagen/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -546,12 +546,14 @@ import (
"go.opentelemetry.io/collector/config/configtelemetry"
)
const ScopeName = ""
func Meter(settings component.TelemetrySettings) metric.Meter {
return settings.MeterProvider.Meter("")
return settings.MeterProvider.Meter(ScopeName)
}
func Tracer(settings component.TelemetrySettings) trace.Tracer {
return settings.TracerProvider.Tracer("")
return settings.TracerProvider.Tracer(ScopeName)
}
`,
},
Expand Down Expand Up @@ -580,12 +582,14 @@ import (
"go.opentelemetry.io/collector/config/configtelemetry"
)
const ScopeName = ""
func Meter(settings component.TelemetrySettings) metric.Meter {
return settings.MeterProvider.Meter("")
return settings.MeterProvider.Meter(ScopeName)
}
func Tracer(settings component.TelemetrySettings) trace.Tracer {
return settings.TracerProvider.Tracer("")
return settings.TracerProvider.Tracer(ScopeName)
}
`,
},
Expand Down
6 changes: 4 additions & 2 deletions cmd/mdatagen/templates/telemetry.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ import (
"go.opentelemetry.io/collector/config/configtelemetry"
)

const ScopeName = "{{ .ScopeName }}"

func Meter(settings component.TelemetrySettings) metric.Meter {
return settings.MeterProvider.Meter("{{ .ScopeName }}")
return settings.MeterProvider.Meter(ScopeName)
}

func Tracer(settings component.TelemetrySettings) trace.Tracer {
return settings.TracerProvider.Tracer("{{ .ScopeName }}")
return settings.TracerProvider.Tracer(ScopeName)
}
{{- if .Telemetry.Metrics }}

Expand Down

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.

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.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions service/internal/metadata/generated_telemetry.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 277384b

Please sign in to comment.