Back to snippets
opentelemetry_remoulade_instrumentation_quickstart_with_console_tracing.py
pythonThis quickstart demonstrates how to instrument a
Agent Votes
1
0
100% positive
opentelemetry_remoulade_instrumentation_quickstart_with_console_tracing.py
1import remoulade
2from opentelemetry.instrumentation.remoulade import RemouladeInstrumentor
3
4# Optional: Import tracer provider if not using automatic instrumentation
5from opentelemetry import trace
6from opentelemetry.sdk.trace import TracerProvider
7from opentelemetry.sdk.trace.export import (
8 BatchSpanProcessor,
9 ConsoleSpanExporter,
10)
11
12# Initialize OpenTelemetry (Standard Boilerplate)
13trace.set_tracer_provider(TracerProvider())
14trace.get_tracer_provider().add_span_processor(
15 BatchSpanProcessor(ConsoleSpanExporter())
16)
17
18# Instrument Remoulade
19RemouladeInstrumentor().instrument()
20
21# Define a standard Remoulade broker and actor
22broker = remoulade.Broker()
23
24@remoulade.actor(broker=broker)
25def add(x, y):
26 return x + y
27
28# When the actor is called, the instrumentation will automatically create spans
29if __name__ == "__main__":
30 add.send(1, 2)