Skip to main content

Respan instrumentation plugin for the Replicate Python SDK

Project description

Respan Replicate Instrumentation

Trace the official replicate Python SDK with Respan.

The instrumentation patches the Replicate client lifecycle and emits canonical Respan spans for run, async_run, stream, async_stream, prediction creation, prediction waiting, and prediction lookup/cancel operations.

Install

pip install respan-ai respan-instrumentation-replicate replicate

Usage

import os

import replicate
from respan import Respan, workflow
from respan_instrumentation_replicate import ReplicateInstrumentor

respan = Respan(
    api_key=os.environ["RESPAN_API_KEY"],
    instrumentations=[ReplicateInstrumentor()],
)


@workflow(name="replicate_quickstart.workflow")
def run_prediction() -> str:
    output = replicate.run(
        "meta/meta-llama-3-8b-instruct",
        input={"prompt": "Reply with one concise sentence about tracing."},
    )
    return "".join(str(chunk) for chunk in output) if not isinstance(output, str) else output


print(run_prediction())
respan.flush()
respan.shutdown()

Use Respan(..., customer_identifier=..., thread_identifier=..., metadata=...) or respan.propagate_attributes(...) to attach Respan attributes to Replicate spans.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

respan_instrumentation_replicate-0.1.0.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file respan_instrumentation_replicate-0.1.0.tar.gz.

File metadata

File hashes

Hashes for respan_instrumentation_replicate-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e4deb44c23cffd2adbc7820c5cd4fc5aef120fb2912b1d838324c8a26d61e4a5
MD5 6607b3e0bb84341075f6ecf40e5fbfe1
BLAKE2b-256 81842afbd35b9d8754214c714fe218f2ebeeb9137f3648b2e97069bff4921794

See more details on using hashes here.

File details

Details for the file respan_instrumentation_replicate-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for respan_instrumentation_replicate-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 143168e4e048892ce8101d82c6cef0c8a12755f93e5ab2498c82fee81089178e
MD5 ba57e5939fa06feb1d57a96653d9d330
BLAKE2b-256 2b4aa1b6fcf40a82a9a059b15e9dd141c5b4fa1c0fd3a35fbe5c26100bb8a6c5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page