Replace Prometheus with OpenTelemetry
Is your feature request related to a problem?
OpenTelemetry will be ready soon (it's already in RC).
Describe the solution you'd like to see
We should replace the Prometheus lib with OpenTelemetry.
We should probably keep the OpenMetrics export, but we should add an (configurable) OpenTelemetry agent target as well.
There are a few words about OpenTelemetry Prometheus compatible exporter.
I managed to replace our current implementation of metrics endpoint with the combination of an otel-prometheus-exporter and a handler wrapper. It seems like both metrics exporter and traces exporter works fine. During my test, I looked through traces via stdout exporter.
@sagikazarmark If it is ok for you, I would like to be in charge of this issue.
The plan is:
- [ ] Replace prometheus with otel without losing observability
- [ ] Write a (design?) doc about traces exporting
- [ ] Add ability to export traces to jaeger
- [ ] Add ability to export traces to otl-collector
Sure, feel free to take it. A couple thoughts:
- I think the otel collector protocol for traces should be enough. AFAIK Jaeger will support it natively.
- I would also implement metrics for the otel collector, meaning that metrics should be collected by both a pull and a push collector. See open-telemetry/opentelemetry-go#1378 for details.
Honestly, I'd start with a minimum replacement of the prometheus lib with open telemetry and go from there.
@sagikazarmark played with it a little last weekend.
Some concerns/problems I have faced:
- GRPC version in dex is v1.26.0, but for otel instrumentation, it is required to be around v1.35.0
- It looks impossible to count errors with otel net/http instrumentation. This method's code shows that we can propagate a "labeler" to add custom labels. We can extract info from the request (such as method name) and add it to labels, but unfortunately, we can't add status code or other things from the response.
* GRPC version in dex is v1.26.0, but for otel instrumentation, it is required to be around [v1.35.0](https://github.com/open-telemetry/opentelemetry-go-contrib/blob/v0.18.0/instrumentation/google.golang.org/grpc/otelgrpc/go.mod#L15)
Once we can upgrade etcd to 3.5, we can upgrade gRPC as well.
* It looks impossible to count errors with otel net/http instrumentation. [This method's code](https://github.com/open-telemetry/opentelemetry-go-contrib/blob/v0.18.0/instrumentation/net/http/otelhttp/handler.go#L164) shows that we can propagate a "labeler" to add custom labels. We can extract info from the request (such as method name) and add it to labels, but unfortunately, we can't add status code or other things from the response.
Metrics is probably not yet fully ready.
I opened the draft, but there are still some problems.
- No metrics for grpc
- New metric names (breaking change)
- I opened a PR to add total request counters with error codes, but there is no feedback yethttps://github.com/open-telemetry/opentelemetry-go-contrib/pull/771
One possible workaround is to use OpenCensus with the available bridge.
Now that the status code label thing is resolved, we should probably revive this topic as well.
Any news on this front? if not i can try and look into pr?
@jensholdgaard Yeah, sure. Feel free to take it.
I think with development of OpenTelemetry we can not only substitute our metrics instrumentation, but also add tracing.
bare with me, this is one of my first pr to an open-source project under CNCF.
Though here is my initial thought how we could start the instrumentation for traces: https://github.com/dexidp/dex/pull/4207/files
This is more or less a poc and draft then anything else.
I put the pr now in ready, once you guys are home from vacations, it is fairly big since all functions and methods have instrumentation around the context.context