openiddict / openiddict-core

Flexible and versatile OAuth 2.0/OpenID Connect stack for .NET
https://openiddict.com/
Apache License 2.0
4.45k stars 526 forks source link

Add telemetry support #1345

Open vaspop opened 3 years ago

vaspop commented 3 years ago

Is your feature request related to a problem?

Not really a problem but a difficulty in primarly understanding performance behaviour but also lack of tracing ability of middleware.

Describe the solution you'd like

Hi, have there been any thoughts on adding some kind of telemetry support? If so are there any technical reasons for not wanting to add such support from your point of view? Do you see a future need for such a thing? If one would at some point try to add such a thing would it be taken into considerstion?

Additional context

SebastianStehle commented 3 years ago

I think it is a great idea but I would wait until events in Open Telemetry are stable. Should be this year.

vaspop commented 3 years ago

I think it is a great idea but I would wait until events in Open Telemetry are stable. Should be this year.

Just curious, what do you mean by stable? What issues would hinder this and in what way? @SebastianStehle

kevinchalet commented 3 years ago

If so are there any technical reasons for not wanting to add such support from your point of view?

Like most things, the reason is actually simpler: because you're the first one asking for it 😄 It's a good idea but I'm not super familiar with the new diagnostics/telemetry APIs introduced in recent .NET versions so it's not going to be a quick thing to implement.

vaspop commented 3 years ago

If so are there any technical reasons for not wanting to add such support from your point of view?

Like most things, the reason is actually simpler: because you're the first one asking for it 😄

It's a good idea but I'm not super familiar with the new diagnostics/telemetry APIs introduced in recent .NET versions so it's not going to be a quick thing to implement.

Im learning as much as i can on those APIs so im not any expert by any means but i just mainly wanted to see whether or not it would be a waste of time to contribute something or atleast a naive prototype on this topic 🙂

But it sounds like its an not that farfetched idea then 👍

SebastianStehle commented 3 years ago

Just curious, what do you mean by stable? What issues would hinder this and in what way? @SebastianStehle

Open Telemetry has several components:

Only tracing is ready, but when you go over the code it makes sense to introduce a few events as well. Therefore I would implement it in one step.

vaspop commented 3 years ago

Just curious, what do you mean by stable? What issues would hinder this and in what way? @SebastianStehle

Open Telemetry has several components:

  • Tracing

  • Metrics / Events

  • Logs

Only tracing is ready, but when you go over the code it makes sense to introduce a few events as well. Therefore I would implement it in one step.

Thank you for the clarification. Sounds like a reasonsble approach 👍

jbonnett92 commented 2 years ago

Honestly I would also like this, my traces are missing a couple of jumps showing for introspection... image

jmsvl commented 9 months ago

Any updates on the possibility of implementing opentelemetry traces and metrics?

oguzhancagliyan commented 8 months ago

Hi, any updates on implementing opentelemetry ?

kevinchalet commented 8 months ago

No immediate plans (since no one offered to fund that). That said, there's a demand, so maybe in the future.

JeffBarnard commented 6 months ago

It's already there, to a degree, .net8 introduces the aspnet System.Diagnostics.Metrics, so my company is currently using the opentelemetry.net sdk to export and observe our openiddict endpoint activity. If openiddict were to do anything natively, it would be to add custom meters/metrics to measure certain things that occur within the API itself. What's important to see?

The aspnet http requests themselves are already covered. e.g.

"MetricType": "Histogram",
      "Temporality": "Delta",
      "Name": "http.server.request.duration",
      "Description": "Duration of HTTP server requests.",
      "Unit": "s",
      "MeterName": "Microsoft.AspNetCore.Hosting",
      "MeterVersion": "",
      "MetricPoints": [
        {
          "StartTime": "2024-04-30T14:46:57.243366+00:00",
          "EndTime": "2024-04-30T14:47:27.291515+00:00",
          "Value": "Sum: 0.0790335 Count: 1 Min: 0.0790335 Max: 0.0790335 \r\n(-Infinity,0.005]:0\r\n(0.005,0.01]:0\r\n(0.01,0.025]:0\r\n(0.025,0.05]:0\r\n(0.05,0.075]:0\r\n(0.075,0.1]:1\r\n(0.1,0.25]:0\r\n(0.25,0.5]:0\r\n(0.5,0.75]:0\r\n(0.75,1]:0\r\n(1,2.5]:0\r\n(2.5,5]:0\r\n(5,7.5]:0\r\n(7.5,10]:0\r\n(10,+Infinity]:0\r\n",
          "Tags": [
            {
              "Key": "http.request.method",
              "Value": "GET"
            },
            {
              "Key": "http.response.status_code",
              "Value": 302
            },
            {
              "Key": "http.route",
              "Value": "Connect/Authorize"
            },           
            {
              "Key": "url.scheme",
              "Value": "https"
            }
          ]
        },