OpenTelemetry Remoulade Instrumentation
This library provides OpenTelemetry instrumentation for the 'Remoulade' Python framework, enabling automatic tracing of requests and operations within Remoulade applications. It is part of the `opentelemetry-python-contrib` repository, with the current version being 0.61b0. As a contrib package, its release cadence aligns with the broader OpenTelemetry Python Contrib project, which typically sees new beta releases every few weeks to months.
Warnings
- gotcha This library, as part of the `opentelemetry-python-contrib` project, is currently in a beta development stage. While functional, it may introduce breaking changes in future releases before reaching a stable 1.0 version.
- gotcha The `RemouladeInstrumentor` must be explicitly called with `.instrument()` to enable tracing. Automatic instrumentation via `opentelemetry-bootstrap` or environment variables may not always cover all specific use cases or might require specific configurations.
- gotcha This instrumentation requires the `remoulade` library to be installed in your environment. It is a peer dependency and not automatically installed with `opentelemetry-instrumentation-remoulade`.
Install
-
pip install opentelemetry-instrumentation-remoulade -
pip install opentelemetry-contrib-instrumentations
Imports
- RemouladeInstrumentor
from opentelemetry.instrumentation.remoulade import RemouladeInstrumentor
Quickstart
import os
from opentelemetry import trace
from opentelemetry.sdk.resources import Resource
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import ConsoleSpanExporter, SimpleSpanProcessor
from opentelemetry.instrumentation.remoulade import RemouladeInstrumentor
# Assuming 'remoulade' and a broker like 'remoulade.brokers.rabbitmq' are installed
try:
from remoulade.brokers.rabbitmq import RabbitmqBroker
import remoulade
except ImportError:
print("Please install 'remoulade' and a broker, e.g., 'pip install remoulade remoulade-rabbitmq'")
exit()
# Configure OpenTelemetry Tracer
resource = Resource.create({"service.name": "remoulade-app"})
provider = TracerProvider(resource=resource)
processor = SimpleSpanProcessor(ConsoleSpanExporter())
provider.add_span_processor(processor)
trace.set_tracer_provider(provider)
# Instrument Remoulade
RemouladeInstrumentor().instrument()
# Remoulade application example
broker = RabbitmqBroker()
remoulade.set_broker(broker)
@remoulade.actor
def multiply(x, y):
print(f"Multiplying {x} * {y}")
return x * y
broker.declare_actor(multiply)
print("Sending Remoulade task...")
result = multiply.send(43, 51)
print(f"Task sent, check console for traces. Result (if synchronous): {result}")
# In a real async app, you'd typically wait for the result or use a consumer.
# For this quickstart, we just show the instrumentation setup and task dispatch.