-
Notifications
You must be signed in to change notification settings - Fork 7
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
Http4s MetricsOps #46
Conversation
Whether they should be separate middleware is an interesting question, as combining them (having a |
honestly, I don't know enough to review this PR well. thoughts, @rossabaker ? |
3e72bbd
to
15f4ffe
Compare
939036b
to
b450daa
Compare
I wonder if it will work in the current state. OpenTelemetry Java uses However, we can propagate the context manually (changes to otel4s required). For example, a def add(
value: A,
attributes: immutable.Iterable[Attribute[_]]
): F[Unit] =
Ask[F, Context].ask.flatMap { ctx =>
Sync[F].delay {
val scope = ctx.underlying.makeCurrent() // make the current context active
counter.add(cast(value), attributes.toJavaAttributes)
scope.close() // release the context
}
} |
Here are the recommended names and dimensions: https://opentelemetry.io/docs/specs/semconv/http/http-metrics/. I'm unsure whether the spec should be followed 1-to-1 though. |
If we follow OpenTelemetry suggestions (i.e. attribute/dimension names) there would be major differences with the http4s-prometheus. So it wouldn't work as a drop-in replacement (from the visualization standpoint, e.g. Grafana dashboard). On the other hand, if we follow the suggestions, metrics provided by the http4s-otel4s should be compatible with any OpenTelemetry http dashboard (e.g. https://grafana.com/grafana/dashboards/18860-http-metrics-opentelemetry/). This is a plus when you monitor various services written in different languages/stacks. |
I am pretty sold on otel and I think the most future proof thing would be to rely on their semconv. The naming already differs a bit from the prometheus impl because of the dots in the metric names. If we want to link traces and metrics they should probably follow the same naming conventions. |
I now changed the metric names and attributes to use otel semantic naming where applicable. A few exceptions are:
|
7657c15
to
f9a8552
Compare
rebased on #65 |
f4f0ee0
to
b81555a
Compare
sorry for renaming and breaking everything >.> |
0de3182
to
18c713f
Compare
18c713f
to
046fdd7
Compare
I added the Metrics middleware to Http4sExample and created a small test. GH Actions seem to run fine on my fork. |
@rossabaker just wanted to let you know that the PR should be ready for review. :) |
Apologies for the git conflicts. Since otel4s Here is the branch with resolved conflicts: https://github.com/iRevive/http4s-otel4s-middleware/pull/1/files. |
# Conflicts: # build.sbt # core/src/test/scala/org/http4s/otel4s/middleware/ClientMiddlewareTests.scala
the latest |
…e/otel-metrics # Conflicts: # build.sbt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks again @lhns! |
release tagged as |
Hi, I implemented the http4s MetricsOps trait for otel4s.
Related: http4s/http4s#7448