opentelemetry.io
opentelemetry.io copied to clipboard
Document how to test that you're instrumenting traces correctly
Something I've seen come up a few times is: "How do I unit test that I'm adding the right attributes to a span?"
You can't test this with the tracing API because it doesn't give you access to this data. But you can depend on the "SDK trace API" in a language to get access to a read/write span.
This should probably be documented with an example in all the languages with stable tracing:
- [ ] JS
- [ ] Java
- [ ] Go
- [ ] .NET
- [ ] Python
- [x] Elixir
- [ ] Ruby
- [ ] C++
Some specific things that would be covered:
- How to establish a test harness with an in-memory exporter
- Which packages to pull in to do this testing
- Example of a simple bit of code that does a thing with otel tracing
- Example of a test that tests that function that does the tracing
@cartermp and I have been discussing this on the pollinators slack - I'm happy to write up some docs for Go if someone would be kind enough to point me to where they should live :)
Put it in a subpage of https://opentelemetry.io/docs/instrumentation/go/, we can then still decide to move it somewhere else.
I wrote a rough draft of I think what this issue is asking for in https://temporaryhack.com/blog/opentelemetry-testing, for elixir.
Happy to take some feedback on it, polish it, and submit it -- if it's what y'all are looking for.
I wrote a rough draft of I think what this issue is asking for in https://temporaryhack.com/blog/opentelemetry-testing, for elixir.
Happy to take some feedback on it, polish it, and submit it -- if it's what y'all are looking for.
Can you put it as a (draft) PR here? makes the review easier for us.
I wrote a rough draft of I think what this issue is asking for in https://temporaryhack.com/blog/opentelemetry-testing, for elixir. Happy to take some feedback on it, polish it, and submit it -- if it's what y'all are looking for.
Can you put it as a (draft) PR here? makes the review easier for us.
Done, submitted rough draft here
Thanks @akasprzok - your doc is live!
@cartermp: can we copy some of the content from elixir/erlang over to the other languages or is it too specific?
The content can probably be copied over easily and tweaked as needed, but the code samples will be different since setting up a test harness can vary so wildly from language to language.
Thank you all for making my first contribution such a fantastic experience!