Add IDs Generator as Configurable Property of Auto Instrumentation#1404
Add IDs Generator as Configurable Property of Auto Instrumentation#1404codeboten merged 6 commits intoopen-telemetry:masterfrom
Conversation
1c7fe9b to
75ff8a6
Compare
75ff8a6 to
fcfcbf1
Compare
62bde4f to
fc1224f
Compare
toumorokoshi
left a comment
There was a problem hiding this comment.
Thanks! This is great.
A couple small changes, but looking really good!
| ) | ||
|
|
||
| parser.add_argument( | ||
| "-g", |
There was a problem hiding this comment.
do we need a shortflag? IMO it's better to keep those to more general configuration, like version, help, etc.
There was a problem hiding this comment.
Sure I agree with you! I had a hard time thinking of a letter, and so I don't think it'll be as easy to use as I had hoped, will use just the long version.
| ids_generator_impl = None | ||
|
|
||
| for id_generator in iter_entry_points("opentelemetry_ids_generator"): | ||
| if id_generator.name == ids_generator_name.strip(): |
There was a problem hiding this comment.
why deviate from the behavior of the exporters and perform a strip on the passed generator name?
Although it helps in a rare handful of cases, I think it's better to just perform no mutation on user input.
Alternatively, exporter and ids_generator should have the same mutation: strip both or strip none. It's minor, but the most confusing thing to a user is inconsistency.
There was a problem hiding this comment.
I was actually under the impression that exporter did strip the value:
Either way I think stripping the value is a good idea, I would expect
opentelemetry-instrument --ids-generator aws_xray
and
opentelemetry-instrument --ids-generator aws_xray
to work the same. But not sure if my second example would have whitespace to begin with 😅
...lemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/components.py
Show resolved
Hide resolved
| @patch.dict( | ||
| environ, {"OTEL_SERVICE_NAME": "my-random-ids-generator-test-service"} | ||
| ) | ||
| def test_trace_init_default_random_ids_generator(self): |
There was a problem hiding this comment.
is it worth testing the environment variable configuring the ids_generator?
If you don't, there's a risk that someone may modify that code to not work, and we'd have no way of validating programmatically.
There was a problem hiding this comment.
Yes it is worth it, I was just unfamiliar with how to do so but I agree it's worth it :) I've spent quite some time learning how to do it and finally figured out how to add it because I also think it's a useful add! Please let me know what you think!
| self.assertIsInstance(provider, Provider) | ||
| self.assertIsInstance(provider.ids_generator, RandomIdsGenerator) | ||
| self.assertIsInstance(provider.processor, Processor) | ||
| self.assertIsInstance(provider.processor.exporter, OTLPExporter) |
There was a problem hiding this comment.
why verify things like the exporter, processor, provider? It's a bit harder to see what this test is trying to verify, when you include assertions for things that aren't related.
I'd argue if you are worried about those, they should be split out into smaller tests. It helps future developers more quickly find what behavior has regressed.
There was a problem hiding this comment.
I can go either way with this, I think it's useful to know that in a test where "I changed only one thing" the other parts of the functionality here still work.
However cleanliness is nice if I remove the rest of the checks, so I have removed them!
9401751 to
70e885f
Compare
70e885f to
2c60b89
Compare
codeboten
left a comment
There was a problem hiding this comment.
Looks good, only question i have is non-blocking
| if args.service_name: | ||
| environ["OTEL_SERVICE_NAME"] = args.service_name | ||
| if args.ids_generator: | ||
| environ["OTEL_IDS_GENERATOR"] = args.ids_generator |
There was a problem hiding this comment.
there should be a proposal to the spec around this env variable
There was a problem hiding this comment.
Will follow up with this soon!
Description
As a follow up to #1036, this PR adds a parameter to the
opentelemetry-instrumentexecutable to allow the IDs Generator to be configurable.This is a necessary part for auto instrumentation with backends which need custom IDs, because once the
opentelemetry-instrumentexecutable sets up theTracerProvider, it is too late for the instrumented downstream application to configure the IDs.Type of change
Please delete options that are not relevant.
Checklist: