Skip to content

Add OpenTelemetry support#3275

Merged
cyberw merged 2 commits intolocustio:masterfrom
amadeuppereira:setup-opentelemetry
Nov 18, 2025
Merged

Add OpenTelemetry support#3275
cyberw merged 2 commits intolocustio:masterfrom
amadeuppereira:setup-opentelemetry

Conversation

@amadeuppereira
Copy link
Copy Markdown
Collaborator

This also configures auto instrumentation for HttpUser by instrumenting requests package

from opentelemetry import metrics, trace
from opentelemetry.sdk.resources import Resource
except ImportError:
logger.debug("OpenTelemetry SDK is not installed, opentelemetry not enabled")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

put this first in the function. if sdk isnt even installed there's no reason to talk about no exporters being configured etc

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Maybe mention doing pip install locust[otel] to fix it


_setup_auto_instrumentation()

logger.info("OpenTelemetry configured!")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

debug level

dns = ["dnspython>=2.8.0"]
otel = [
"opentelemetry-sdk>=1.38.0",
"opentelemetry-exporter-otlp-proto-grpc>=1.38.0",
Copy link
Copy Markdown
Collaborator

@cyberw cyberw Nov 17, 2025

Choose a reason for hiding this comment

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

should we also install http? if we do, we can also remove the slightly complicated handling of ImportError.

In general, we dont need to support an incomplete installation (missing urllib3 instrumentation or whatnot). Just crashing is cleaner.

@cyberw cyberw merged commit 11fbbf9 into locustio:master Nov 18, 2025
17 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants