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

Allow configuring resource detectors #328

Open
wolverian opened this issue Nov 9, 2022 · 0 comments
Open

Allow configuring resource detectors #328

wolverian opened this issue Nov 9, 2022 · 0 comments

Comments

@wolverian
Copy link

I'd like my traces to contain OS and process info. I'd like to add basically all the detectors available in https://pkg.go.dev/go.opentelemetry.io/otel/sdk/resource. I don't see a way to do that currently.

One option would be to add launcher.WithDetectors(detectors ...Detector) Option to launcher, so you could say:

otelShutdown, err := launcher.ConfigureOpenTelemetry(launcher.WithDetectors(resource.WithHost(), resource.WithOS()))

This might need the launcher.Config type to be changed to carry detectors in it.

Another option would be to allow adding the resource explicitly:

res, err := resource.New(context.Background(), resource.WithOS(), resource.WithProcess())
if err != nil {
    log.Fatalf("could not detect opentelemetry resources: %s", err)
}
otelShutdown, err := launcher.ConfigureOpenTelemetry(launcher.WithResource(res))

I think for now it's possible to work around the issue by serialising the resource into an attribute map:

res, err := resource.New(context.Background(), resource.WithOS(), resource.WithProcess())
if err != nil {
    log.Fatalf("could not detect opentelemetry resources: %s", err)
}
attribs := res.Attributes()
attribMap := make(map[string]string)
for _, attrib := range attribs {
    attribMap[string(attrib.Key)] = attrib.Value.AsString()
}
otelShutdown, err := launcher.ConfigureOpenTelemetry(launcher.WithResourceAttributes(attribMap))

The issue is that this is highly unintuitive.

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

No branches or pull requests

1 participant