Skip to content

OpenTelemetry template: use the interface name without the package as the default span name prefix #108

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

Merged
merged 4 commits into from
May 23, 2025

Conversation

mlaflamm
Copy link
Contributor

This PR take care of #101.

Take for example this interface :

package mypackage

type MyInterface interface {
	MyMethod()
}

When the interface and the generated file are in the same package, the span names start with the interface name like this MyInterface.MyMethod. This PR doesn't change that.

When the interface and the generated file are NOT in the same package, the span name had an additional prefix that include the interface package. It used to be mypackage.MyInterface.MyMethod but after #92 it became _sourceMypackage.MyInterface.MyMethod.

With this PR, the default span name is always the same whether the interface and the generated file are in the same package or not i.e. MyInterface.MyMethod.

This is also possible to change default span name prefix with the SpanNamePrefix variable. For SpanNamePrefix=NewInterface, the generated span name would be NewInterface.MyMethod. If you want to include the package name, include it in the variable: SpanNamePrefix="mypackage.MyInterface".

mlaflamm added 3 commits May 22, 2025 09:00
… the span name prefix by default.

The span name prefix can be overridden with the "SpanNamePrefix" variable
@mlaflamm
Copy link
Contributor Author

I forgot to mention that I also added the span status on error.

@hexdigest hexdigest merged commit 418804c into hexdigest:master May 23, 2025
1 check passed
@hexdigest
Copy link
Owner

Thanks for the fixes @mlaflamm!

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