Skip to content
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

Support Open Telemetry for metrics #776

Closed
samsp-msft opened this issue Feb 22, 2021 · 13 comments
Closed

Support Open Telemetry for metrics #776

samsp-msft opened this issue Feb 22, 2021 · 13 comments
Labels
samsp_list Personal tag used when reviewing issues for further discussion Type: Enhancement New feature or request
Milestone

Comments

@samsp-msft
Copy link
Contributor

As part of being a good CNCF citizen, we need to make sure we interoperate well out of the box for Open Telemetry.

dotnet/runtime#44445

@Tratcher
Copy link
Member

Here's a demo we can borrow and insert ourselves into:
https://github.com/shirhatti/trivia

Note: the way we bypass HttpClient and go directly to SocketHttpHandler bypasses the DiagnosticsHandler and may break some of the open telemetry integration. See #292

@samsp-msft
Copy link
Contributor Author

Does @MihaZupan 's last comment on #292 imply that it should work?

@Tratcher
Copy link
Member

I think we only ported a subset of the functionality, enough to add headers, but not enough to track the outbound request as a separate child activity.

@Kahbazi
Copy link
Collaborator

Kahbazi commented Feb 23, 2021

How the users are going to consume the open telemetry? Are we going to add the rest of DiagnosticHandler to the http request and let users use OpenTelemetry.Instrumentation.AspNetCore and OpenTelemetry.Instrumentation.Http or we are going to create a new Activity for YARP and create a OpenTelemetry.Instrumentation.YARP package?

@MihaZupan
Copy link
Member

Distributed tracing works with YARP, but as Chris mentioned, we will appear as a single node (there is no separation for incoming and outgoing requests, it's seen as a single operation).

Do we know what is the use-case for YARP to have a separate activity for the outgoing request?

@Tratcher
Copy link
Member

Tratcher commented Feb 23, 2021

Having a separate activity would get you more granular timings, right? Or do you rely on the destination to start its own activity?

I'd also expect a separate activity to be useful in retry scenarios.

@Kahbazi I would expect to re-use the OpenTelemetry.Instrumentation.AspNetCore package. I don't know if we'll be able to re-use the http package or not. I'd prefer to re-use it if possible.

@MihaZupan
Copy link
Member

Having a separate activity would get you more granular timings, right?

Yes, but only slightly - in YARP the outgoing request starts at about the same time as the incoming one (there are no network delays etc. in between). Retries would be a good scenario tho.

do you rely on the destination to start its own activity

Yes, every part of the system contributes its information.

I would expect to re-use the OpenTelemetry.Instrumentation.AspNetCore package. I don't know if we'll be able to re-use the http package or not.

The AspNetCore part can be reused.

For Http, it could be reused if we mirror the DiagnosticListener events currently used by DiagnosticHandler (same names, same arguments).

@Kahbazi
Copy link
Collaborator

Kahbazi commented Feb 23, 2021

Having a separate activity would get you more granular timings, right?

Yes, but only slightly - in YARP the outgoing request starts at about the same time as the incoming one (there are no network delays etc. in between). Retries would be a good scenario tho.

There might be scenarios where there's delay between the incoming request and outgoing requests, like when there is authentication involved, or when there's a ConcurrencyMiddleware for routes.

@samsp-msft
Copy link
Contributor Author

If the outbound request is queued, in theory there could also be a delay there while it waits for an available connection (eg H2 concurrency limit).

@MihaZupan
Copy link
Member

ToDo: Distributed tracing & logging

  • Update the ActivityPropagationHandler to create its own child Activity (so that outgoing requests are separated from the incoming request) and log events matching those of Runtime's DiagnosticsHandler
  • Test YARP behavior with OpenTelemetry & App insights on 5.0 and 3.1
  • Test compatibility of above HTTP instrumentations with a DiagnosticListener/ActivitySource implementation of our handler
  • Test ILogger integration behavior with the OpenTelemetry SDK
    • Do we need extra config to get ILogger to capture Span IDs
    • Are logs exported and correlated
  • Create samples for wiring up telemetry egress. There shouldn't be any difference here to any other AspNetCore app so pointing to existing docs might be sufficient

Runtime work (dotnet/runtime#31261):

  • Updating DiagnosticsHandler to use ActivitySource
  • Exposing the type?

Future: Metrics

  • Specs yet to finalize
  • .NET 6.0 APIs yet to become available
  • Do we need different instrumentation / flowing EventCounter data (dimensions?)

@Kahbazi
Copy link
Collaborator

Kahbazi commented Mar 1, 2021

Update the ActivityPropagationHandler to create its own child Activity (so that outgoing requests are separated from the incoming request) and log events matching those of Runtime's DiagnosticsHandler

YARP could be used as part of an ASP.NET Core application, and although having matching events as DiagnosticsHandler is necessary, I think having the exact same events but with different name is useful in order to monitor only YARP requests.

@karelz
Copy link
Member

karelz commented Mar 22, 2021

Triage: Let's scope it to "just" Metrics (will be in .NET 6.0, hence Backlog here for YARP) -- @MihaZupan can you please file a new issue with leftovers for Logging and Telemetry we should address in YARP 1.0?

@karelz karelz added this to the Backlog milestone Mar 22, 2021
@karelz karelz added the Type: Enhancement New feature or request label Mar 22, 2021
@samsp-msft samsp-msft added the samsp_list Personal tag used when reviewing issues for further discussion label Dec 8, 2021
@karelz
Copy link
Member

karelz commented Aug 22, 2023

Triage: We believe that work done in 8.0 Runtime and in Kestrel covers everything that might be needed for OpenTelemetry to work well.
If we add more, then we would be mirroring those in Runtime/Kestrel.

Closing

@davidfowl did you miss anything else which you would find valuable in YARP?

@karelz karelz closed this as completed Aug 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
samsp_list Personal tag used when reviewing issues for further discussion Type: Enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants