Skip to content

Commit a17f7b5

Browse files
AbhiPrasadNova (SFK)claude
authored
feat(temporal): add temporal integrations auto instrumentation (#367)
Temporal is now available as a first-class integration via braintrust.auto_instrument(), which patches Temporal client and worker setup to install BraintrustPlugin automatically when temporalio is installed. New applications can enable Temporal tracing with: ```python import braintrust braintrust.auto_instrument() ``` For explicit setup without global auto-instrumentation, users can call setup_temporal(): ```python from braintrust.integrations.temporal import setup_temporal setup_temporal(project_name="my-project") ``` If an application manually constructs Temporal plugin lists, use BraintrustPlugin directly: ```python from braintrust.integrations.temporal import BraintrustPlugin plugins = [BraintrustPlugin(), *existing_plugins] ``` Migration guide: replace old contrib imports with integrations imports for new code: ```python # Before from braintrust.contrib.temporal import BraintrustPlugin, BraintrustInterceptor # After from braintrust.integrations.temporal import BraintrustPlugin, BraintrustInterceptor ``` Prefer braintrust.auto_instrument() for new applications. The braintrust.contrib.temporal module remains as a deprecated compatibility re-export for its previous public API: BraintrustPlugin and BraintrustInterceptor. --------- Co-authored-by: Nova (SFK) <nova@starfolk.ai> Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 4b0ec7f commit a17f7b5

12 files changed

Lines changed: 613 additions & 434 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ BRAINTRUST_API_KEY=<YOUR_API_KEY> braintrust eval tutorial_eval.py
7272
| [Strands](py/src/braintrust/integrations/strands/) | Yes | `strands-agents>=1.20.0` |
7373
| [Agno](py/src/braintrust/integrations/agno/) | Yes | `agno>=2.1.0` |
7474
| [AgentScope](py/src/braintrust/integrations/agentscope/) | Yes | `agentscope>=1.0.0` |
75+
| [Temporal](py/src/braintrust/integrations/temporal/) | Yes | `temporalio>=1.19.0` |
7576
| [pytest plugin](py/src/braintrust/wrappers/pytest_plugin/README.md) | No | `pytest>=8` |
7677

7778
## Documentation

py/noxfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ def test_mistral(session, version):
452452
def test_temporal(session, version):
453453
_install_test_deps(session)
454454
_install_matrix_dep(session, "temporalio", version)
455-
_run_tests(session, "braintrust/contrib/temporal")
455+
_run_tests(session, f"{INTEGRATION_DIR}/temporal")
456456

457457

458458
PYTEST_VERSIONS = _get_matrix_versions("pytest-matrix")

py/pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ otel = [
5555
performance = [
5656
"orjson; platform_python_implementation != 'PyPy'",
5757
]
58+
# Deprecated: Temporal is now available via braintrust.auto_instrument();
59+
# keep this extra as a compatibility alias until a future major release.
5860
temporal = [
5961
"temporalio>=1.19.0; python_version>='3.10'",
6062
]

py/src/braintrust/auto.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
OpenRouterIntegration,
2828
PydanticAIIntegration,
2929
StrandsIntegration,
30+
TemporalIntegration,
3031
)
3132
from braintrust.integrations.base import BaseIntegration
3233

@@ -68,6 +69,7 @@ def auto_instrument(
6869
autogen: bool = True,
6970
crewai: bool = True,
7071
strands: bool = True,
72+
temporal: bool = True,
7173
) -> dict[str, bool]:
7274
"""
7375
Auto-instrument supported AI/ML libraries for Braintrust tracing.
@@ -98,6 +100,7 @@ def auto_instrument(
98100
autogen: Enable AutoGen instrumentation (default: True)
99101
crewai: Enable CrewAI instrumentation (default: True)
100102
strands: Enable Strands Agents instrumentation (default: True)
103+
temporal: Enable Temporal instrumentation (default: True)
101104
102105
Returns:
103106
Dict mapping integration name to whether it was successfully instrumented.
@@ -183,6 +186,8 @@ def auto_instrument(
183186
results["crewai"] = _instrument_integration(CrewAIIntegration)
184187
if strands:
185188
results["strands"] = _instrument_integration(StrandsIntegration)
189+
if temporal:
190+
results["temporal"] = _instrument_integration(TemporalIntegration)
186191

187192
return results
188193

0 commit comments

Comments
 (0)