-
Notifications
You must be signed in to change notification settings - Fork 15
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
feat: return errors from resource.New #59
Conversation
When using detectors with mis-matched Schema URLs, resource.New will return an error. Previously, this was dropped and consequently it looked like configuration worked but many resource attributes would be missing in the resulting telemetry.
Ahhhh this 'ole bucket of fun. I ended up documenting things to fail loudly because of this:
In the docs: https://opentelemetry.io/docs/instrumentation/go/manual/#setup func newTraceProvider(exp sdktrace.SpanExporter) *sdktrace.TracerProvider {
// Ensure default SDK resources and the required service name are set.
r, err := resource.Merge(
resource.Default(),
resource.NewWithAttributes(
semconv.SchemaURL,
semconv.ServiceName("ExampleService"),
),
)
if err != nil {
panic(err)
}
return sdktrace.NewTracerProvider(
sdktrace.WithBatcher(exp),
sdktrace.WithResource(r),
)
} TBH I can't think of a better way to handle this, since there's no other way to actually get the right instrumentation. |
It does look like this is on the minds of the OTel folks: open-telemetry/opentelemetry-go#4364 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this! I'll follow this up with some version updates and a couple more tests to hopefully make this a bit less painful to manage.
…60) ## Which problem is this PR solving? - it's easy to mismatch semantic convention versions (see notes in #59 ) ## Short description of the changes - Drop our version of semantic conventions to 1.17 to match those used in the imported otel-go package - Update the README to clarify versions in use (note old semconv listed because that's in current available release) - Update releasing notes to remember to adjust README if versions change, and some other cleanup for consistency to other repos - Add simple unit test for checking semantic convention version against otel-go imported package semantic convention - Add unit tests for resource detector from core (WithHost) and contrib (lambda) to confirm no schema error ## How to verify that this has the expected result Using a detector on the same version should work. These tests should fail if you change the semantic convention version back to 1.18.0 in the imports.
Which problem is this PR solving?
When using detectors with mis-matched Schema URLs, resource.New will return an error. Previously, this was dropped and consequently it looked like configuration worked but many resource attributes would be missing in the resulting telemetry.
With the recent addition of #48, this error is much easier to hit. For example, the detectors built into opentelemetry-go import semconv
v1.17.0
but this project pulls inv1.18.0
. This means that adding something likeotelconfig.WithResourceOption(resource.WithHost())
results in a mis-configured OTel and no error to warn you what happened.This is all … very bad. This PR is really the bare minimum that needs to be done here. That is, it at least causes a runtime error so that you can tell what's going on — but it doesn't solve the problem that you fundamentally cannot use this library with any other library that doesn't happen to use semconv
v1.18.0
. There are a number of open issues in OTel and adjacent repositories regarding this problem, which probably warrant further investigation into a long-term sustainable solution.Short description of the changes
Return the
err
fromresource.New
up through the stack. Update tests to expect this.How to verify that this has the expected result
There's a new test that specifically uses a detector with a different schema URL.