mirror of
https://github.com/hatchet-dev/hatchet.git
synced 2026-02-18 06:09:24 -06:00
* 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>
32 lines
791 B
Python
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())
|