mirascope.integrations.otel | Mirascope
MirascopeLilypad

mirascope.integrations.otel

configure

Alias configure

Configures the OpenTelemetry tracer, this function should only be called once.

Parameters

NameTypeDescription
processors= NoneSequence[SpanProcessor] | NoneOptional[Sequence[SpanProcessor]] The span processors to use, if None, a console exporter will be used.

Returns

TypeDescription
TracerThe configured tracer.

Alias to: mirascope.integrations.otel._utils.configure

with_otel

Alias with_otel

Wraps a Mirascope function with OpenTelemetry.

Example:

from mirascope.core import anthropic, prompt_template
from mirascope.integrations.otel import with_otel, configure

configure()


def format_book(title: str, author: str) -> str:
    return f"{title} by {author}"


@with_otel()
@anthropic.call(model="claude-3-5-sonnet-20240620", tools=[format_book])
def recommend_book(genre: str) -> str:
    return f"Recommend a {genre} book"


print(recommend_book("fantasy"))

Returns

TypeDescription
(() => _R) => () => _R-

Alias to: mirascope.integrations.otel._with_otel.with_otel

with_hyperdx

Alias with_hyperdx

Decorator to wrap a function with hyperdx.

Example:

import os

from mirascope.core import anthropic, prompt_template
from mirascope.integrations.otel import with_hyperdx

os.environ["HYPERDX_API_KEY"] = "YOUR_API_KEY"


def format_book(title: str, author: str):
    return f"{title} by {author}"


@with_hyperdx()
@anthropic.call(model="claude-3-5-sonnet-20240620", tools=[format_book])
def recommend_book(genre: str) -> str:
    return f"Recommend a {genre} book"


print(recommend_book("fantasy"))

Returns

TypeDescription
(() => _R) => () => _R-

Alias to: mirascope.integrations.otel._with_hyperdx.with_hyperdx