Skip to content
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

Read resource settings from environment variables #8

Merged
merged 6 commits into from Apr 14, 2022

Conversation

cjs
Copy link
Contributor

@cjs cjs commented Apr 13, 2022

Settings such as OTEL_RESOURCE_ATTRIBUTES were not being read in from environment variables. Having this available is important for some automated environments where OTEL_RESOURCE_ATTRIBUTES is auto-generated from deployment tooling.

Note that setting service.name in OTEL_RESOURCE_ATTRIBUTES or via OTEL_SERVICE_NAME will still be a no-op because there is a default value set from the command line flags.

This also bumps the https://github.com/open-telemetry/opentelemetry-go libraries to the latest stable release. This was required to get it to work with our LightStep environment, although I'm not entirely sure what in the changelog was breaking.

Finally, the https://pkg.go.dev/go.opentelemetry.io/otel/sdk@v1.6.3/resource#WithTelemetrySDK detector was added to inject version information about the OpenTelemetry SDK libraries into span attributes. This is to aid administration of observability services.

cjs added 4 commits April 13, 2022 09:58
This brings makes the OTel resource effectively the same as resource.Default()
with the addition of explicitly setting the service.name
@cjs cjs marked this pull request as ready for review April 14, 2022 18:20
@jzelinskie jzelinskie self-requested a review April 14, 2022 18:51
otel.go Outdated
@@ -124,7 +124,7 @@ func OpenTelemetryRunE(flagPrefix string, prerunLevel zerolog.Level) CobraRunFun
}

func initOtelTracer(exporter trace.SpanExporter, serviceName string, propagators []string) error {
res, _ := resource.New(context.Background(), resource.WithAttributes(semconv.ServiceNameKey.String(serviceName)))
res, _ := setResource(serviceName)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function does return an error. Any reason why we shouldn't propagate it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved in b9a185a

otel_test.go Show resolved Hide resolved
otel.go Outdated
@@ -124,7 +124,11 @@ func OpenTelemetryRunE(flagPrefix string, prerunLevel zerolog.Level) CobraRunFun
}

func initOtelTracer(exporter trace.SpanExporter, serviceName string, propagators []string) error {
res, _ := resource.New(context.Background(), resource.WithAttributes(semconv.ServiceNameKey.String(serviceName)))
res, err := setResource(serviceName)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tiny nitpick: drop this new line

@jzelinskie jzelinskie merged commit 1025940 into jzelinskie:main Apr 14, 2022
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.

None yet

2 participants