Skip to content

Commit df890eb

Browse files
committed
fix: google_genai and pydantic init_logger unconditionally called during auto_instrument
1 parent 4267bde commit df890eb

5 files changed

Lines changed: 10 additions & 10 deletions

File tree

py/src/braintrust/integrations/adk/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import logging
44
import warnings
55

6-
from braintrust.logger import NOOP_SPAN, current_span, init_logger
6+
from braintrust.logger import NOOP_SPAN, current_logger, current_span, init_logger
77

88
from .integration import ADKIntegration
99
from .patchers import (
@@ -56,7 +56,7 @@ def setup_adk(
5656
warnings.warn("SpanProcessor parameter is deprecated and will be ignored", DeprecationWarning, stacklevel=2)
5757

5858
span = current_span()
59-
if span == NOOP_SPAN:
59+
if span == NOOP_SPAN and current_logger() is None:
6060
init_logger(project=project_name, api_key=api_key, project_id=project_id)
6161

6262
return ADKIntegration.setup()

py/src/braintrust/integrations/agno/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import logging
44

5-
from braintrust.logger import NOOP_SPAN, current_span, init_logger
5+
from braintrust.logger import NOOP_SPAN, current_logger, current_span, init_logger
66

77
from .integration import AgnoIntegration
88
from .patchers import (
@@ -44,7 +44,7 @@ def setup_agno(
4444
True if setup was successful, False otherwise
4545
"""
4646
span = current_span()
47-
if span == NOOP_SPAN:
47+
if span == NOOP_SPAN and current_logger() is None:
4848
init_logger(project=project_name, api_key=api_key, project_id=project_id)
4949

5050
return AgnoIntegration.setup()

py/src/braintrust/integrations/claude_agent_sdk/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import logging
1818

19-
from braintrust.logger import NOOP_SPAN, current_span, init_logger
19+
from braintrust.logger import NOOP_SPAN, current_logger, current_span, init_logger
2020

2121
from .integration import ClaudeAgentSDKIntegration
2222

@@ -58,7 +58,7 @@ def setup_claude_agent_sdk(
5858
```
5959
"""
6060
span = current_span()
61-
if span == NOOP_SPAN:
61+
if span == NOOP_SPAN and current_logger() is None:
6262
init_logger(project=project, api_key=api_key, project_id=project_id)
6363

6464
return ClaudeAgentSDKIntegration.setup()

py/src/braintrust/integrations/google_genai/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import logging
44

5-
from braintrust.logger import NOOP_SPAN, current_span, init_logger
5+
from braintrust.logger import NOOP_SPAN, current_logger, current_span, init_logger
66

77
from .integration import GoogleGenAIIntegration
88

@@ -33,7 +33,7 @@ def setup_genai(
3333
True if setup was successful, False if google-genai is not installed.
3434
"""
3535
span = current_span()
36-
if span == NOOP_SPAN:
36+
if span == NOOP_SPAN and current_logger() is None:
3737
init_logger(project=project_name, api_key=api_key, project_id=project_id)
3838

3939
return GoogleGenAIIntegration.setup()

py/src/braintrust/wrappers/pydantic_ai.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from typing import Any
88

99
from braintrust.bt_json import bt_safe_deep_copy
10-
from braintrust.logger import NOOP_SPAN, Attachment, current_span, init_logger, start_span
10+
from braintrust.logger import NOOP_SPAN, Attachment, current_logger, current_span, init_logger, start_span
1111
from braintrust.span_types import SpanTypeAttribute
1212
from wrapt import wrap_function_wrapper
1313

@@ -34,7 +34,7 @@ def setup_pydantic_ai(
3434
bool: True if setup was successful, False otherwise.
3535
"""
3636
span = current_span()
37-
if span == NOOP_SPAN:
37+
if span == NOOP_SPAN and current_logger() is None:
3838
init_logger(project=project_name, api_key=api_key, project_id=project_id)
3939

4040
try:

0 commit comments

Comments
 (0)