spandex-project/spandex

Support Service Versions

kamilkowalski opened this issue · 4 comments

Note: Initially, I wanted to open this issue in spandex_datadog, but for reasons I'll describe in a second I'm opening it here.

Most Datadog tracing libraries support specifying the version of the service being traced, in order to track deployments. Usually, this is done with an environment variable like DD_VERSION, where the version is a string like "2.21" or "a7b91d". The feature allows us to track regressions in performance, monitor canary releases - neat stuff. We at Fresha would definitely use it, so I had the thought of implementing it in spandex_datadog - until I checked how others do it.

When I looked at other tracing standards like OpenTelemetry - it appears there's also a notion of a service.version in them. That's when I thought that it would actually make sense to specify the service version around the same time when specifying the service name - either during spandex tracer configuration or when tracing.

My suggestion is to extend the tracer config and the options allowed in tracer functions so that we can pass a service version along with the service name. We could then propagate those in Span.t() until they reach spandex_datadog, where they would get converted to span metadata.

If the idea makes sense, I'll be happy to implement it.

Out of curiosity, have you tried just specifying it as a tag? Most "special" metadata we send to dd is just done with specific tag names.

Yeah I think this idea is a really good one and we should definitely support that. If you want to try to implement it, I will help get it merged! I'd suggest perusing the code for their first-party dd-trace-* libraries in whatever other language you're most familiar with, and try to see how they're sending the version up. As Zach mentioned, I'd bet that it's just a special tag on the trace.

In a pinch, I bet you can also set the version on the DD Agent itself, if you only have one app sending traces to a given Agent. That wouldn't work if you have multiple containers sharing the same Agent, though. They also have various complicated ways to integrate the Agent with Docker / Kubernetes to infer the version from environment variables or Docker tags on the container, too, but I don't fully understand how those work myself and I agree it would be simplest to just have the app pass it along via config.

@zachdaniel @GregMefford You're right, the version is specified as a tag sent to the tracing agent - seems setting tags: [version: "v1.0"] in the Spandex tracer config works. I'd still rather have a configuration option in the tracer since setting the service version seems like a general use case in tracing libraries, it's just that Datadog uses a tag as a medium. I'll send a PR your way and we'll see how it looks. Thanks for your input!

Closing this, since there is a decent way to do it now, but will happily review a PR to simplify that configuraiton.