Skip to content

Commit 6e78232

Browse files
authored
Add **kwargs to instrument_pydantic_ai for future compatibility (#1078)
1 parent 082b95c commit 6e78232

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

logfire/_internal/integrations/pydantic_ai.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import annotations
22

3-
from typing import Literal
3+
from typing import Any, Literal
44

55
from pydantic_ai import Agent
66
from pydantic_ai.agent import InstrumentationSettings
@@ -14,13 +14,15 @@ def instrument_pydantic_ai(
1414
logfire_instance: Logfire,
1515
obj: Agent | Model | None,
1616
event_mode: Literal['attributes', 'logs'] | None,
17+
**kwargs: Any,
1718
) -> None | InstrumentedModel:
1819
if event_mode is None:
1920
event_mode = InstrumentationSettings.event_mode
2021
settings = InstrumentationSettings(
2122
tracer_provider=logfire_instance.config.get_tracer_provider(),
2223
event_logger_provider=logfire_instance.config.get_event_logger_provider(),
2324
event_mode=event_mode,
25+
**kwargs,
2426
)
2527
if isinstance(obj, Agent):
2628
obj.instrument = settings

logfire/_internal/main.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -962,6 +962,7 @@ def instrument_pydantic_ai(
962962
/,
963963
*,
964964
event_mode: Literal['attributes', 'logs'] = 'attributes',
965+
**kwargs: Any,
965966
) -> None: ...
966967

967968
@overload
@@ -971,6 +972,7 @@ def instrument_pydantic_ai(
971972
/,
972973
*,
973974
event_mode: Literal['attributes', 'logs'] = 'attributes',
975+
**kwargs: Any,
974976
) -> pydantic_ai.models.Model: ...
975977

976978
def instrument_pydantic_ai(
@@ -979,6 +981,7 @@ def instrument_pydantic_ai(
979981
/,
980982
*,
981983
event_mode: Literal['attributes', 'logs'] | None = None,
984+
**kwargs: Any,
982985
) -> pydantic_ai.models.Model | None:
983986
"""Instrument PydanticAI.
984987
@@ -989,6 +992,9 @@ def instrument_pydantic_ai(
989992
If you pass a model, a new instrumented model will be returned.
990993
event_mode: See the [PydanticAI docs](https://ai.pydantic.dev/logfire/#data-format).
991994
The default is whatever the default is in your version of PydanticAI.
995+
kwargs: Additional keyword arguments to pass to
996+
[`InstrumentationSettings`](https://ai.pydantic.dev/api/models/instrumented/#pydantic_ai.models.instrumented.InstrumentationSettings)
997+
for future compatibility.
992998
"""
993999
from .integrations.pydantic_ai import instrument_pydantic_ai
9941000

@@ -997,6 +1003,7 @@ def instrument_pydantic_ai(
9971003
self,
9981004
obj=obj,
9991005
event_mode=event_mode,
1006+
**kwargs,
10001007
)
10011008

10021009
def instrument_fastapi(

0 commit comments

Comments
 (0)