prefect icon indicating copy to clipboard operation
prefect copied to clipboard

Add Flow run OTEL instrumentation

Open collincchoy opened this issue 3 months ago • 1 comments

This PR adds OTEL instrumentation into the flow run engine so that if a user were to configure application-level telemetry, the flow run engine will now emit spans for flow runs that capture metadata about the flow run in span attributes and state changes as events on the span. Note: this PR does not include task run instrumentations but will extensibly nest spans (that can/will be emitted from tasks) transparently.

What impact will this have if I do not have telemetry configured? https://opentelemetry.io/docs/concepts/instrumentation/libraries/#performance

Performance OpenTelemetry API is no-op and very performant when there is no SDK in the application

This PR also sets up some testing infrastructure for testing otel instrumentation - heavily borrowing from opentelemetry.test.test_base import TestBase which many instrumentation libs in opentelemetry-python-contrib seem to use (i.e. httpx) but moved over in a more pytest-friendly interface here.

Closes CLOUD-564

Checklist

  • [x] This pull request references any related issue by including "closes <link to issue>"
    • If no issue exists and your change is not a small fix, please create an issue first.
  • [x] If this pull request adds new functionality, it includes unit tests that cover the changes
  • [x] If this pull request removes docs files, it includes redirect settings in mint.json.
  • [x] If this pull request adds functions or classes, it includes helpful docstrings.

collincchoy avatar Nov 13 '24 22:11 collincchoy