traceAI Temporal
Send Temporal's native workflow and activity spans to Future AGI, with model and tool spans nested inside the activities that run them. The package configures Temporal's replay-safe OpenTelemetry provider; it does not replace Temporal's instrumentation or create duplicate workflow spans.
Install
Use Python 3.10–3.13 and Temporal Python SDK 1.34 or 1.35.
pip install "traceAI-temporal==0.1.0"
Temporal marks its OpenTelemetry plugin and replay-safe provider as experimental. This package restricts the SDK range to the supported minor versions.
Configure
Set the same project in the starter and worker processes. Supply your keys through your deployment's environment or secret manager.
export FI_PROJECT_NAME=temporal-orders
export FI_API_KEY='<your-api-key>'
export FI_SECRET_KEY='<your-secret-key>'
# Optional, for a self-hosted deployment:
# export FI_BASE_URL=https://your-futureagi-host
Call configure() once in each process, before connecting the client. Do not also call fi_instrumentation.register() or install another global tracer provider.
from temporalio.client import Client
from traceai_temporal import configure
telemetry = configure()
client = await Client.connect("localhost:7233", plugins=[telemetry.plugin])
Workers created from this client inherit the native plugin. Do not add it to the worker again. The plugin enables Temporal's workflow and activity spans by default.
Run a workflow
Start your Temporal cluster or a local Temporal dev server:
temporal server start-dev
Keep workflow code deterministic. Save this ordinary workflow as workflows.py; it must not import the exporter, this package, or a model SDK.
from datetime import timedelta
from temporalio import workflow
@workflow.defn
class OrderWorkflow:
@workflow.run
async def run(self, quantity: int) -> str:
return await workflow.execute_activity(
"price_order",
quantity,
start_to_close_timeout=timedelta(seconds=10),
)
Save the worker and starter as app.py. This example runs them in one process; separate deployments use the same configure() and client setup in each process.
import asyncio
import uuid
from opentelemetry import trace
from temporalio import activity
from temporalio.client import Client
from temporalio.worker import Worker
from traceai_temporal import configure
from workflows import OrderWorkflow
@activity.defn
async def price_order(quantity: int) -> str:
with trace.get_tracer("orders").start_as_current_span(
"calculate-price", attributes={"gen_ai.span.kind": "tool"}
):
return f"EUR {quantity * 21}"
async def main():
telemetry = configure()
try:
client = await Client.connect("localhost:7233", plugins=[telemetry.plugin])
async with Worker(
client,
task_queue="orders",
workflows=[OrderWorkflow],
activities=[price_order],
):
result = await client.execute_workflow(
OrderWorkflow.run,
2,
id=f"order-{uuid.uuid4().hex}",
task_queue="orders",
)
print(result)
finally:
# Stop workers first. These methods return False if the time budget expires.
if not telemetry.shutdown(timeout_millis=3000):
print("Tracing shutdown timed out; the final batch may be lost")
asyncio.run(main())
python app.py
In Future AGI, open Observe, select temporal-orders, and open the latest StartWorkflow:OrderWorkflow trace. It contains RunWorkflow, StartActivity, RunActivity, and calculate-price. The workflow ID is the session ID, including on nested tool/model spans and signal handlers.
Add model tracing inside activities
Temporal's plugin does not trace model requests. Install the traceAI package for your model SDK and instrument it once, using telemetry.provider. For example, with traceAI-openai installed:
from traceai_openai import OpenAIInstrumentor
OpenAIInstrumentor().instrument(tracer_provider=telemetry.provider)
Make model calls only inside activities, not replayed workflow code. Provider spans keep their model, token usage, and span kind; the adapter does not copy token totals onto workflow or activity parents. Do not instrument the same model call through two packages.
Privacy
The default is metadata only: workflow/run/activity IDs, span names and timing, status, model/tool identifiers, token counts, and explicit session/user IDs. Unknown attributes, content, arbitrary events, status text, and exception messages are removed before this destination exports. Exception types remain. Exception stack attributes are always removed, including with content enabled. Resource and scope attributes are filtered, and link attributes and trace state are removed.
Use opaque workflow IDs and user IDs. Span names, instrumentation-scope names, and allowed metadata values are not secret scanners; do not put prompts, emails, paths, or credentials in them.
To include supported input/output and message attributes, opt in in both processes as needed:
telemetry = configure(capture_content=True)
Error text needs a second explicit opt-in, keep_error_text=True, together with capture_content=True. The core FI_HIDE_* settings remain privacy ceilings; FI_HIDE_ERROR_DETAILS=true still removes error text. Content values are capped at 16,384 characters by default. The adapter cannot recover content that your instrumentor did not record, and opt-in content can contain sensitive data.
The policy applies to this exporter only. It does not redact Temporal history, application logs, or other exporters you attach. It does not propagate user identity across Temporal's process boundary: attach explicit user IDs in activities if needed. Application-supplied session.id takes precedence over the workflow ID.
Configuration and lifecycle
project_name,api_key,secret_key,base_urloverride the correspondingFI_*environment values.base_urlis the origin (optionally with a deployment prefix), not the traces URL; the package appends/tracer/v1/traces.- The destination uses upstream OTLP/HTTP protobuf with no compression. Set
compression="gzip"for Future AGI Cloud or self-hosted v1.56.0 and later. Remote endpoints require HTTPS; plain HTTP is allowed only for loopback collectors. exporter=accepts an application-supplied OpenTelemetrySpanExporterin place of endpoint/auth settings. It still receives filtered spans and is shut down by the handle.- The batch queue holds at most 2,048 spans, with batches of at most 512 and a 1-second schedule. Set
max_queue_size,max_export_batch_size, andschedule_delay_millisto tune them. A full queue drops spans rather than blocking an activity. export_timeoutdefaults to 3 seconds per HTTP export.telemetry.force_flush(timeout_millis=3000)andtelemetry.shutdown(timeout_millis=3000)bound the caller's wait and return a boolean. On timeout, an in-flight daemon export can finish later; delivery is not guaranteed. Neither method ends unfinished workflow spans.- Normal interpreter exit has a bounded shutdown fallback. Explicitly shut down after stopping the worker. Crashes, forced exits, and container freezes can lose buffered spans. In an async server, use
await asyncio.to_thread(telemetry.shutdown)to avoid blocking its event loop while waiting. - Do not configure again after shutdown: OpenTelemetry does not allow replacing its process-global provider. Construct worker processes after forking, then configure each process.
Troubleshooting
The worker rejects the global tracer provider. Call this package's configure() before Client.connect(). Do not use the ordinary register() provider with Temporal's replay-safe plugin.
Model spans start separate traces. Configure the plugin on both clients and pass telemetry.provider to the model instrumentor. Keep calls inside activities.
A workflow fails sandbox validation. Move tracing setup and model imports into the worker/activity module. The workflow module should import only deterministic workflow dependencies and refer to activities by name.
No spans appear, or the trace splits across projects. Check both key headers, the base URL, and that starter and worker use the same FI_PROJECT_NAME. Flush short-lived starters before exit. A running workflow's RunWorkflow span is exported only when it ends.
Limits
This integration covers the Python native plugin's workflow/activity hierarchy, activity retries, signal sessions, and history replay. It does not configure Temporal metrics/logs, cluster authentication, or model instrumentation. Native Temporal spans remain runtime spans rather than being relabeled as model calls. Each activity attempt is a distinct span; no attempt number is synthesized. Temporal owns deterministic IDs and replay suppression, not exactly-once delivery to Future AGI. Child workflows, continue-as-new, Nexus, and standalone activities are not additional compatibility guarantees of this package.
Metadata
Release files for traceAI-temporal 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| traceai_temporal-0.1.0.tar.gz | 24.5 kB | Without provenance | Details for traceai_temporal-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| traceai_temporal-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for traceai_temporal-0.1.0-py3-none-any.whl |
Total release size: 42.7 kB
Release files / traceai_temporal-0.1.0.tar.gz
| Download URL | traceai_temporal-0.1.0.tar.gz |
|---|---|
| Size | 24.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c47b9391e19b016af10e1bd68c6aaab8c021e7e2e89b9288ba3c6e436800e073
|
|
BLAKE2b-256 checksum How to use checksums |
f11ce090662be803e0e38a2256352e8f8303db8329e75578dc227f3d122381e8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / traceai_temporal-0.1.0-py3-none-any.whl
| Download URL | traceai_temporal-0.1.0-py3-none-any.whl |
|---|---|
| Size | 18.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4cc9cd697e80f85a12a63ff8419e4f599e19390726c925c489977b18631eaa5a
|
|
BLAKE2b-256 checksum How to use checksums |
44fdff3eaefb35307e2a13502b8c88ad64d3c1910374a0fc594d2183a0a17169
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Security for traceAI-temporal 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.