OpenTelemetry Remoulade Instrumentation

0.61b0 · active · verified Sat Apr 11

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

Install

Imports

Quickstart

This quickstart demonstrates how to initialize the OpenTelemetry SDK with a console exporter and then apply the `RemouladeInstrumentor` to automatically trace Remoulade operations. It includes a simple Remoulade actor example to show tracing in action.

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.

view raw JSON →