Files
hatchet/examples/python/opentelemetry_instrumentation/langfuse/trigger.py
Matt Kaye 1cd12f24f8 Feat: Streaming Docs + Examples (#1912)
* feat: streaming examples + gen

* feat: more examples

* chore: gen again

* feat: fastapi example

* chore: gen

* feat: callout

* fix: typos

* fix: whoops - how did this work?

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-06-26 17:28:05 -04:00

32 lines
791 B
Python

# type: ignore
import asyncio
from langfuse import get_client # type: ignore
from opentelemetry.trace import StatusCode
from examples.opentelemetry_instrumentation.langfuse.worker import langfuse_task
# > Trigger task
tracer = get_client()
async def main() -> None:
# Traces will send to Langfuse
# Use `_otel_tracer` to access the OpenTelemetry tracer if you need
# to e.g. log statuses or attributes manually.
with tracer._otel_tracer.start_as_current_span(name="trigger") as span:
result = await langfuse_task.aio_run()
location = result.get("location")
if not location:
span.set_status(StatusCode.ERROR)
return
span.set_attribute("location", location)
if __name__ == "__main__":
asyncio.run(main())