-
Notifications
You must be signed in to change notification settings - Fork 833
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
Being able to specify Resource manually #1454
Comments
That's technically not true: There is |
Yeah as an example I'm doing this Because we have a pattern of generating many different Is there a difference between this issue and #1149? |
Well, there's also the possibility of use reflection to achieve that ;) But in all seriousness, being able to set I honestly cannot imagine users having to extend the SPI part to only override |
Yes, we need to support this IMHO.
Hopefully there's no difference and we can close this issue after initial feedback (and deciding what path to go with). |
Maybe we can repurpose this or a new issue into the resourc merging story? I feel that in most cases, users will be happy adding various artifacts for different resources to their classpath to get the information they need - otel-resource-k8s, otel-resource-gcp, etc. I don't think we've committed to a story for this yet. |
We indeed need to discuss how to achieve this in a nice way (probably through additional SPI). I suggest we keep this issue for the simple case of an user setting |
My case is to use it in custom agent extending In the @anuraaga in his example added dependency on Having system property would solve the issue in one line of code ( I expect any SPI solution will not work with |
Another scenario. follow open-telemetry/opentelemetry-java-instrumentation#864 In spring boot starter |
If a user were to supply a Resource manually, would it get merged with any others, automatically, or should it be considered to be complete? Would we want to enforce the "required" Resource attributes as specified here? https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/resource/semantic_conventions/README.md ? And, if so, what would be the desired behavior if the required attributes weren't supplied? [note: I think this is still an open question for non-manual setting of the Resource, but it would apply to this case as well]. |
I don't think "required" is enforced for spans, so why should it be enforced for resources? Also, open-telemetry/opentelemetry-specification#653 |
oh, I know. :) Just wanted to raise it, since of all the things, not having a |
So as long as no other service attribute is present, it is OK to leave out service.name, even obeying required. |
That may be currently allowable, but I think that will force all the exporters to require it as a field, kind of making any definition of the service.name in the Resource moot. I know this isn't the right place to be having this discussion, btw...I just wanted to highlight how I think the Resource spec is not really fulfilling some basic needs at the moment. |
As open-telemetry/opentelemetry-specification#799 got merged, I need some way for auto insrtumentation agent to provide new resource attribute. I was going to file an issue about adding ResourceProvide SPI when I noticed this issue. Can this one be closed by introducing ResourceProvide SPI or these two approaches are separate? |
@iNikem I'd like to have an SPI-option for specifying the Resource. I'd also like a manual option (I'm not sure that SPI is Spring-friendly?). So, let's keep the 2 options as separate PRs. I'd like to have both. |
+1 |
I will try to submit a ResourceProvider SPI PR during this week. |
With the SPI in place, could we defer this to after GA, or is it still needed pre-GA? |
Not a strong opinion (i.e. I'm not totally clear), but I'd say After GA. |
I'm going to move it after-ga. If anyone disagrees, please yell. |
Just to add my AU$0.02 - being able to programmatically specify things like a service name and IP address is something we could do back in the day of Open Tracing. My situation is that programs read their configuration and determine the service name (for example). Did this end up being too hard, or is it something I can help with? |
I think the issue wasn't really that it is too hard, but that there are potential lifecycle issues to be hammered out. e.g. when is an SDK considered "ready" to accept telemetry. How does the manual method interact with the SPI method? A Resource shouldn't ever be altered on the SDK, so getting the lifecycle right is a little tricky, and we haven't had time to work on it. :) If you'd like to take a run at it, that would be great! |
Happy to have a go at it. I see that the underlying problem here is that we rely on global state. I don’t see a way around this other than to provide a means of not having to rely on global state and therefore have the state passed around. This is much like having to pass around an ActorSystem in Akka. Languages like Scala make this a little more transparent given implicits, but in Java, the OTEL state will have to be passed around. It’s worth pointing out that when using Java and Akka, the actor system is always passed explicitly. Is there an appetite for providing an option to pass the state around, if we could make this a nice experience? I’d not see this precluding the existing global state approach. The local state approach would just be an alternative that the global state approach would build on. |
@huntc I would love to have a non-global option for OpenTelemetry. I think it might be easier just to be able to get access to an instance of an OpenTelemetry class, and then keep everything else the same as it is now. |
Currently the only way to set
Resource
s for the globalOpenTelemetry
is through environment variables - but we need to allow users to set them manually (through code) or through system properties (in a similar fashion to the configuration supported forBatchSpanProcessor
and siblings).I see two possible options to do this:
Resource
in the loadedTracerSdkProvider
and siblings once, and report errors if the user tries to do this again.TracerSdkProvider
and siblings to be set manually, in addition to the SPI path. For this, @Oberon00's PR would help us achieve this purpose (while also allowing global initialization, of course).Option 2) is the most reasonable to me, and can help get it to the finish line, but want to get initial feedback (mostly from @bogdandrutu )
EDIT: Updated the description to specifically address the global case.
The text was updated successfully, but these errors were encountered: