Skip to content
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

[opentelemetry] add ability to contextualize span name #5171

Closed
cdaguerre opened this issue Oct 26, 2022 · 5 comments · Fixed by #5329
Closed

[opentelemetry] add ability to contextualize span name #5171

cdaguerre opened this issue Oct 26, 2022 · 5 comments · Fixed by #5329
Labels
feature ⚙️ New feature or request

Comments

@cdaguerre
Copy link

cdaguerre commented Oct 26, 2022

Since caddy is often the entry point to an application, it's generally the root span and it's name becomes the operation name of the entire trace. As a result, tools like Jaeger show a list of various operations that all have the same name.

It would be great if the span name could be customized on a "per request" basis with string interpolation in the span name, eg.

tracing {
  span '{request>uri}'
}

or even get the operation name from the upstream like this:

tracing {
  span '{response>headers>X-Trace-Operation-Name}'
}
@francislavoie
Copy link
Member

francislavoie commented Oct 26, 2022

/cc @andriikushch @cedricziel

Sounds like we just need placeholder support for the span name. Is it possible to run the replacer at runtime, or must the span name be known at provision-time?

FYI @cdaguerre the syntax would be more like this:

tracing {
	span {uri}
}

Where {uri} is a Caddyfile shortcut for {http.request.uri} as per https://caddyserver.com/docs/caddyfile/concepts#placeholders

For response header values, that's trickier because AFAIK the trace is set up at the start of the request, before handling, not after, on the way out. Definitely possible to wire up with a request header though, I think. But I might be wrong here.

@francislavoie francislavoie added the feature ⚙️ New feature or request label Oct 26, 2022
@cdaguerre
Copy link
Author

Thanks for clarifying the syntax!

I don't know the first thing about Go but this looks "provision-time".
Since the trace handler is the very first to be setup in the stack, it's probably also the last to handle the response, right?
It should take all other handler processing times into account and so on so my guess is yes...

For most frameworks operation naming in line with OpenTelemetry's semantic conventions can not be achieved through mere request manipulation and is probably much easier to handle at framework level then with request info manipulation on caddy level, hence the suggestion, although I'm not sure it's very clean ;)

@davidfrickert
Copy link
Contributor

Any news on the implementation of this feature? Sounds quite interesting.

@francislavoie
Copy link
Member

The Caddy maintainers don't use tracing or metrics ourselves, so we have very little incentive to spend time working on it. So we're asking for the community to help maintain those parts.

@davidfrickert
Copy link
Contributor

davidfrickert commented Jan 23, 2023

Understandable.
I have a working solution for this, I can submit a PR.
(as in, supporting placeholders in the span name, for http request only)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature ⚙️ New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants