Load Generator

The load generator is based on the Python load testing framework Locust. By default it will simulate users requesting several different routes from the frontend.

Load generator source

Traces

Initializing Tracing

Since this service is a locustfile, the OpenTelemetry SDK is initialized after the import statements. This code will create a tracer provider, and establish a Span Processor to use. Export endpoints, resource attributes, and service name are automatically set using OpenTelemetry environment variables.

tracer_provider = TracerProvider()
trace.set_tracer_provider(tracer_provider)
tracer_provider.add_span_processor(BatchSpanProcessor(OTLPSpanExporter()))

Adding instrumentation libraries

To add instrumentation libraries you need to import the Instrumentors for each library in your Python code. Locust uses the Requests andURLLib3 libraries, so we will import their Instrumentors.

from opentelemetry.instrumentation.requests import RequestsInstrumentor
from opentelemetry.instrumentation.urllib3 import URLLib3Instrumentor

In your code before the library is leveraged, the Instrumentor needs to be initialized by calling instrument().

RequestsInstrumentor().instrument()
URLLib3Instrumentor().instrument()

Once initialized, every Locust requests for this load generator will have their own trace with a span for each of the Requests and URLLib3 libraries.

Metrics

TBD

Logs

TBD

Baggage

OpenTelemetry Baggage is used by the load generator to indicate that the traces are synthetically generated. This is done in the on_start function by creating a context object containing the baggage item, and associating that context for all tasks by the load generator.

ctx = baggage.set_baggage("synthetic_request", "true")
context.attach(ctx)
Last modified October 19, 2023: Support page-relative aliases (#3417) (7f46ec2d)