Open fiadliel opened 6 years ago
I think I might have had a similar issue when creating support for prometheus with http4s. My idea there to avoid high cardinality and not need custom extraction or adding of a name was to initialise the middleware with a whitelist of supported prefix paths. (code) But I never finished it somehow ;)
Opencensus supports a local store with samples of calls to various endpoints. It can be enabled with a request like
This can be viewed with https://github.com/census-instrumentation/opencensus-java/tree/master/contrib/zpages
I've looked at the issue of implementing this for http4s, where the problem is that the underlying model is that the route selection and calculation of response are bound together. So when you want to start timing a span, you already have to give it a span name, before you know anything about how that path was converted to a result.
You can't just use the path itself as the name, because you want the cardinality to be low for this store (if, for example, a UUID is encoded in the path, you don't want an entry per UUID).
I've tried implementing this by passing a function
Request[F] => String
when creating server middleware, to create a "HTTP route" that's used as the span name. The problem is the lack of guarantee that this in any way matches how theHttpService[F]
is actually implemented, and that it matches how the matching is done.I suspect that similar issues are present for akka-http (I'm not that familiar with its API).
Opening this issue so people can offer opinions (perhaps the answer is not to do this).