Skip to content

Commit 52da802

Browse files
authored
Update deps, fix openai-agents (#1602)
1 parent 6df12d2 commit 52da802

File tree

7 files changed

+643
-570
lines changed

7 files changed

+643
-570
lines changed

logfire/_internal/integrations/openai_agents.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,10 @@ def trace_id(self) -> str:
262262
def name(self) -> str:
263263
return self.wrapped.name
264264

265+
@property
266+
def tracing_api_key(self) -> str | None:
267+
return self.wrapped.tracing_api_key
268+
265269
def export(self) -> dict[str, Any] | None:
266270
return self.wrapped.export()
267271

@@ -340,6 +344,10 @@ def started_at(self) -> str | None:
340344
def ended_at(self) -> str | None:
341345
return self.wrapped.ended_at
342346

347+
@property
348+
def tracing_api_key(self) -> str | None:
349+
return self.wrapped.tracing_api_key
350+
343351

344352
def attributes_from_span_data(span_data: SpanData, msg_template: str) -> dict[str, Any]:
345353
try:

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,8 @@ dev = [
167167
"uvicorn>=0.30.6",
168168
"logfire-api",
169169
"setuptools>=75.3.0",
170-
"aiosqlite!=0.22.0",
170+
# https://github.com/omnilib/aiosqlite/issues/369
171+
"aiosqlite!=0.22.*",
171172
"boto3 >= 1.28.57",
172173
"botocore >= 1.31.57",
173174
"greenlet >= 3.1.1",

tests/otel_integrations/test_openai_agents.py

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,11 @@ def test_openai_agent_tracing(exporter: TestExporter):
133133
'name': 'trace_name',
134134
'agent_trace_id': IsStr(),
135135
'metadata': 'null',
136+
'tracing': 'null',
136137
'group_id': 'null',
137138
'logfire.msg_template': 'OpenAI Agents trace: {name}',
138139
'logfire.span_type': 'span',
139-
'logfire.json_schema': '{"type":"object","properties":{"name":{},"agent_trace_id":{},"group_id":{"type":"null"},"metadata":{"type":"null"}}}',
140+
'logfire.json_schema': '{"type":"object","properties":{"name":{},"agent_trace_id":{},"group_id":{"type":"null"},"metadata":{"type":"null"},"tracing":{"type":"null"}}}',
140141
'logfire.msg': 'OpenAI Agents trace: trace_name',
141142
},
142143
},
@@ -282,10 +283,11 @@ def test_openai_agent_tracing_manual_start_end(exporter: TestExporter):
282283
'name': 'trace_name',
283284
'agent_trace_id': IsStr(),
284285
'metadata': 'null',
286+
'tracing': 'null',
285287
'group_id': 'null',
286288
'logfire.msg_template': 'OpenAI Agents trace: {name}',
287289
'logfire.span_type': 'span',
288-
'logfire.json_schema': '{"type":"object","properties":{"name":{},"agent_trace_id":{},"group_id":{"type":"null"},"metadata":{"type":"null"}}}',
290+
'logfire.json_schema': '{"type":"object","properties":{"name":{},"agent_trace_id":{},"group_id":{"type":"null"},"metadata":{"type":"null"},"tracing":{"type":"null"}}}',
289291
'logfire.msg': 'OpenAI Agents trace: trace_name',
290292
},
291293
},
@@ -375,11 +377,12 @@ def test_manual_parents(exporter: TestExporter):
375377
'name': 'my_trace',
376378
'group_id': 'null',
377379
'metadata': 'null',
380+
'tracing': 'null',
378381
'logfire.msg_template': 'OpenAI Agents trace: {name}',
379382
'logfire.msg': 'OpenAI Agents trace: my_trace',
380383
'logfire.span_type': 'span',
381384
'agent_trace_id': 'trace_123',
382-
'logfire.json_schema': '{"type":"object","properties":{"name":{},"agent_trace_id":{},"group_id":{"type":"null"},"metadata":{"type":"null"}}}',
385+
'logfire.json_schema': '{"type":"object","properties":{"name":{},"agent_trace_id":{},"group_id":{"type":"null"},"metadata":{"type":"null"},"tracing":{"type":"null"}}}',
383386
},
384387
},
385388
]
@@ -671,6 +674,7 @@ def random_number() -> int:
671674
'name': 'Agent workflow',
672675
'group_id': 'null',
673676
'metadata': 'null',
677+
'tracing': 'null',
674678
'logfire.msg_template': 'OpenAI Agents trace: {name}',
675679
'logfire.msg': 'OpenAI Agents trace: Agent workflow',
676680
'logfire.span_type': 'span',
@@ -779,6 +783,7 @@ async def zero_guardrail(_context: Any, _agent: Agent[Any], inp: Any) -> Guardra
779783
'name': 'Agent workflow',
780784
'group_id': 'null',
781785
'metadata': 'null',
786+
'tracing': 'null',
782787
'logfire.msg_template': 'OpenAI Agents trace: {name}',
783788
'logfire.msg': 'OpenAI Agents trace: Agent workflow',
784789
'logfire.span_type': 'span',
@@ -835,6 +840,7 @@ async def zero_guardrail(_context: Any, _agent: Agent[Any], inp: Any) -> Guardra
835840
'name': 'Agent workflow',
836841
'group_id': 'null',
837842
'metadata': 'null',
843+
'tracing': 'null',
838844
'logfire.msg_template': 'OpenAI Agents trace: {name}',
839845
'logfire.msg': 'OpenAI Agents trace: Agent workflow',
840846
'logfire.span_type': 'span',
@@ -936,6 +942,7 @@ async def test_chat_completions(exporter: TestExporter):
936942
'name': 'Agent workflow',
937943
'group_id': 'null',
938944
'metadata': 'null',
945+
'tracing': 'null',
939946
'logfire.msg_template': 'OpenAI Agents trace: {name}',
940947
'logfire.msg': 'OpenAI Agents trace: Agent workflow',
941948
'logfire.span_type': 'span',
@@ -970,11 +977,18 @@ def test_custom_span(exporter: TestExporter):
970977
'agent_trace_id': 'trace_123',
971978
'group_id': '456',
972979
'metadata': 'null',
980+
'tracing': 'null',
973981
'logfire.msg_template': 'OpenAI Agents trace: {name}',
974982
'logfire.msg': 'OpenAI Agents trace: my_trace',
975983
'logfire.json_schema': {
976984
'type': 'object',
977-
'properties': {'name': {}, 'agent_trace_id': {}, 'group_id': {}, 'metadata': {'type': 'null'}},
985+
'properties': {
986+
'name': {},
987+
'agent_trace_id': {},
988+
'group_id': {},
989+
'metadata': {'type': 'null'},
990+
'tracing': {'type': 'null'},
991+
},
978992
},
979993
'logfire.span_type': 'pending_span',
980994
'logfire.pending_parent_id': '0000000000000000',
@@ -1037,14 +1051,21 @@ def test_custom_span(exporter: TestExporter):
10371051
'code.lineno': 123,
10381052
'name': 'my_trace',
10391053
'metadata': 'null',
1054+
'tracing': 'null',
10401055
'group_id': '456',
10411056
'logfire.msg_template': 'OpenAI Agents trace: {name}',
10421057
'logfire.msg': 'OpenAI Agents trace: my_trace',
10431058
'logfire.span_type': 'span',
10441059
'agent_trace_id': 'trace_123',
10451060
'logfire.json_schema': {
10461061
'type': 'object',
1047-
'properties': {'name': {}, 'agent_trace_id': {}, 'group_id': {}, 'metadata': {'type': 'null'}},
1062+
'properties': {
1063+
'name': {},
1064+
'agent_trace_id': {},
1065+
'group_id': {},
1066+
'metadata': {'type': 'null'},
1067+
'tracing': {'type': 'null'},
1068+
},
10481069
},
10491070
},
10501071
},
@@ -1127,6 +1148,7 @@ def type(self) -> str:
11271148
'code.lineno': 123,
11281149
'name': 'my_trace',
11291150
'metadata': 'null',
1151+
'tracing': 'null',
11301152
'logfire.msg_template': 'OpenAI Agents trace: {name}',
11311153
'logfire.msg': 'OpenAI Agents trace: my_trace',
11321154
'logfire.span_type': 'span',
@@ -1283,6 +1305,7 @@ async def test_responses_simple(exporter: TestExporter):
12831305
'name': 'my_trace',
12841306
'group_id': 'null',
12851307
'metadata': 'null',
1308+
'tracing': 'null',
12861309
'logfire.msg_template': 'OpenAI Agents trace: {name}',
12871310
'logfire.msg': 'OpenAI Agents trace: my_trace',
12881311
'logfire.span_type': 'span',
@@ -1482,6 +1505,7 @@ async def test_file_search(exporter: TestExporter):
14821505
'name': 'my_trace',
14831506
'group_id': 'null',
14841507
'metadata': 'null',
1508+
'tracing': 'null',
14851509
'logfire.msg_template': 'OpenAI Agents trace: {name}',
14861510
'logfire.msg': 'OpenAI Agents trace: my_trace',
14871511
'logfire.span_type': 'span',
@@ -1671,6 +1695,7 @@ def tool():
16711695
'name': 'Agent workflow',
16721696
'group_id': 'null',
16731697
'metadata': 'null',
1698+
'tracing': 'null',
16741699
'logfire.msg_template': 'OpenAI Agents trace: {name}',
16751700
'logfire.msg': 'OpenAI Agents trace: Agent workflow',
16761701
'logfire.span_type': 'span',
@@ -1761,6 +1786,7 @@ async def test_voice_pipeline(exporter: TestExporter, vcr_allow_bytes: None):
17611786
'code.lineno': 123,
17621787
'name': 'Voice Agent',
17631788
'metadata': 'null',
1789+
'tracing': 'null',
17641790
'logfire.msg_template': 'OpenAI Agents trace: {name}',
17651791
'logfire.msg': 'OpenAI Agents trace: Voice Agent',
17661792
'logfire.span_type': 'span',

tests/otel_integrations/test_openai_agents_mcp.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,7 @@ def name(self):
494494
'name': 'my_trace',
495495
'group_id': 'null',
496496
'metadata': 'null',
497+
'tracing': 'null',
497498
'logfire.msg_template': 'OpenAI Agents trace: {name}',
498499
'logfire.msg': 'OpenAI Agents trace: my_trace',
499500
'logfire.span_type': 'span',

tests/test_json_args.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import numpy
1919
import pandas
20+
import pydantic
2021
import pytest
2122
from attrs import define
2223
from dirty_equals import IsJson, IsStr
@@ -30,6 +31,7 @@
3031
from sqlmodel import SQLModel
3132

3233
import logfire
34+
from logfire._internal.utils import get_version
3335
from logfire.testing import TestExporter
3436

3537
if sys.version_info >= (3, 11): # pragma: no branch
@@ -529,7 +531,8 @@ class StrSubclass(str):
529531
pytest.param(
530532
MySQLModel(s=10),
531533
's=10',
532-
'{"s":10}',
534+
# SQLModel requires pydantic 2.7+ now
535+
'{"s":10}' if get_version(pydantic.__version__) >= get_version('2.5.0') else '"MySQLModel(s=10)"',
533536
{'type': 'object', 'title': 'MySQLModel', 'x-python-datatype': 'PydanticModel'},
534537
),
535538
pytest.param(

tests/test_pydantic_plugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1268,7 +1268,7 @@ def test_sqlmodel_pydantic_plugin(exporter: TestExporter) -> None:
12681268
logfire.instrument_pydantic()
12691269

12701270
class Hero(sqlmodel.SQLModel, table=True):
1271-
id: int = sqlmodel.Field(default=1, primary_key=True) # type: ignore
1271+
id: int = sqlmodel.Field(default=1, primary_key=True)
12721272

12731273
Hero.model_validate({})
12741274

0 commit comments

Comments
 (0)