dex icon indicating copy to clipboard operation
dex copied to clipboard

Replace Prometheus with OpenTelemetry

Open sagikazarmark opened this issue 5 years ago • 11 comments

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.

sagikazarmark avatar Jan 14 '21 13:01 sagikazarmark

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

nabokihms avatar Feb 11 '21 23:02 nabokihms

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 avatar Feb 11 '21 23:02 sagikazarmark

@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.

nabokihms avatar Mar 16 '21 09:03 nabokihms

* 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.

sagikazarmark avatar Mar 16 '21 10:03 sagikazarmark

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

nabokihms avatar May 20 '21 15:05 nabokihms

One possible workaround is to use OpenCensus with the available bridge.

sagikazarmark avatar May 26 '21 12:05 sagikazarmark

Now that the status code label thing is resolved, we should probably revive this topic as well.

sagikazarmark avatar Mar 13 '23 22:03 sagikazarmark

Any news on this front? if not i can try and look into pr?

jensholdgaard avatar Jun 11 '25 16:06 jensholdgaard

@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.

nabokihms avatar Jun 14 '25 05:06 nabokihms

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.

jensholdgaard avatar Jul 03 '25 10:07 jensholdgaard

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

jensholdgaard avatar Jul 14 '25 22:07 jensholdgaard