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

Instrument task runs #15955

Open
wants to merge 34 commits into
base: main
Choose a base branch
from
Open

Conversation

jeanluciano
Copy link
Contributor

@jeanluciano jeanluciano commented Nov 8, 2024

Adds OTEL instrumentation into the task engine so that if a user were to configure application-level telemetry, the task run engine will now emit spans for runs that capture metadata about the task run in span attributes and state changes as events on the span.

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 implemented by @collincchoy in #16010

Checklist

  • 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.
  • If this pull request adds new functionality, it includes unit tests that cover the changes
  • If this pull request removes docs files, it includes redirect settings in mint.json.
  • If this pull request adds functions or classes, it includes helpful docstrings.

@github-actions github-actions bot added the upstream dependency An upstream issue caused by a bug in one of our dependencies label Nov 8, 2024
Copy link

codspeed-hq bot commented Nov 8, 2024

CodSpeed Performance Report

Merging #15955 will not alter performance

Comparing jean/cloud-565-task-run-instrumentation (8fa6939) with main (23a1bc0)

Summary

✅ 3 untouched benchmarks

@jeanluciano jeanluciano changed the title WIP:instrument task runs Instrument task runs Nov 14, 2024
@jeanluciano jeanluciano marked this pull request as ready for review November 14, 2024 17:45
Copy link
Member

@cicdw cicdw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a few changes that stood out to me; still need to review more closely

requirements-client.txt Outdated Show resolved Hide resolved
src/prefect/client/schemas/objects.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@zzstoatzz zzstoatzz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this lgtm! cc @desertaxle for a second look

Copy link
Member

@desertaxle desertaxle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall, but I think we can clean up the code a little by moving most of the new otel functionality to the base class and using it in the separate sync and async engines. Also, we'll want some coverage on the SyncTaskRunEngine.

src/prefect/task_engine.py Outdated Show resolved Hide resolved
src/prefect/task_engine.py Outdated Show resolved Hide resolved
src/prefect/task_engine.py Outdated Show resolved Hide resolved
src/prefect/task_engine.py Outdated Show resolved Hide resolved
src/prefect/task_engine.py Outdated Show resolved Hide resolved
tests/telemetry/test_instrumentation.py Outdated Show resolved Hide resolved
tests/telemetry/test_instrumentation.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@zzstoatzz zzstoatzz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking pretty good! a couple comments

src/prefect/task_engine.py Outdated Show resolved Hide resolved
src/prefect/telemetry/run_telemetry.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@zzstoatzz zzstoatzz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥 lgtm


def start_span(
self,
task_run: TaskRun,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like how this is all encapsulated in a class. Could this be extended to work with flow runs too?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
upstream dependency An upstream issue caused by a bug in one of our dependencies
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants