Skip to content

Commit a608157

Browse files
Merge branch 'major/3.0' into webb/openai/remove-include-prompts
2 parents 4ee6050 + 27e0e78 commit a608157

8 files changed

Lines changed: 45 additions & 47 deletions

File tree

‎scripts/populate_tox/tox.jinja‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,8 @@ setenv =
200200
# which targets the workspace `.venv` instead of the tox env and hangs.
201201
ray: RAY_ENABLE_UV_RUN_RUNTIME_ENV=0
202202

203+
litellm: LITELLM_LOCAL_MODEL_COST_MAP=true
204+
203205
# Avoid polluting test suite with imports
204206
common: PYTEST_ADDOPTS="--ignore=tests/test_shadowed_module.py"
205207
gevent: PYTEST_ADDOPTS="--ignore=tests/test_shadowed_module.py"

‎sentry_sdk/integrations/langchain.py‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,8 +1135,6 @@ def new_invoke(self: "Any", *args: "Any", **kwargs: "Any") -> "Any":
11351135
if run_name:
11361136
span.set_attribute(SPANDATA.GEN_AI_FUNCTION_ID, run_name)
11371137

1138-
_set_tools_on_span(span, tools)
1139-
11401138
# Run the agent
11411139
result = f(self, *args, **kwargs)
11421140

@@ -1192,8 +1190,6 @@ def new_stream(self: "Any", *args: "Any", **kwargs: "Any") -> "Any":
11921190
if run_name:
11931191
span.set_attribute(SPANDATA.GEN_AI_FUNCTION_ID, run_name)
11941192

1195-
_set_tools_on_span(span, tools)
1196-
11971193
input = args[0].get("input") if len(args) >= 1 else None
11981194
if input is not None and record_inputs:
11991195
normalized_messages = normalize_message_roles([input])

‎sentry_sdk/integrations/pydantic_ai/spans/invoke_agent.py‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from ..consts import SPAN_ORIGIN
1212
from ..utils import (
1313
_set_agent_data,
14-
_set_available_tools,
1514
_set_model_data,
1615
_should_send_inputs,
1716
_should_send_outputs,
@@ -59,7 +58,6 @@ def invoke_agent_span(
5958

6059
_set_agent_data(span, agent)
6160
_set_model_data(span, agent, model, model_settings)
62-
_set_available_tools(span, agent)
6361

6462
# Add user prompt and system prompts if available and prompts are enabled
6563
if _should_send_inputs():

‎tests/integrations/langchain/test_langchain.py‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3328,11 +3328,6 @@ def test_langchain_data_collection_tools(
33283328
for s in spans
33293329
if s["attributes"].get("sentry.op") == "gen_ai.chat"
33303330
]
3331-
invoke_agent_span = next(
3332-
s["attributes"]
3333-
for s in spans
3334-
if s["attributes"].get("sentry.op") == "gen_ai.invoke_agent"
3335-
)
33363331

33373332
assert len(chat_spans) == 2
33383333

@@ -3351,7 +3346,6 @@ def test_langchain_data_collection_tools(
33513346
):
33523347
collected = key in expected_present
33533348
assert (key in chat_spans[1]) is collected
3354-
assert (key in invoke_agent_span) is collected
33553349

33563350

33573351
@pytest.mark.parametrize("send_default_pii", [True, False])

‎tests/integrations/pydantic_ai/test_pydantic_ai.py‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2980,10 +2980,7 @@ def add_numbers(a: int, b: int) -> int:
29802980
assert SPANDATA.GEN_AI_REQUEST_MODEL in chat_span
29812981

29822982
# Both the chat and the invoke_agent spans list the agent's available tools
2983-
for op, span_data in spans:
2984-
if op not in ("gen_ai.chat", "gen_ai.invoke_agent"):
2985-
continue
2986-
2983+
for span_data in chat_spans:
29872984
if expect_available_tools:
29882985
assert "add_numbers" in span_data[SPANDATA.GEN_AI_REQUEST_AVAILABLE_TOOLS]
29892986
else:

‎tests/integrations/ray/test_ray.py‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,11 @@ def example_task_with_kwargs(**kwargs):
161161
[example_task, example_task_with_kwargs],
162162
)
163163
def test_tracing_in_ray_tasks(
164+
sentry_init,
164165
task_options,
165166
task,
166167
):
167-
sentry_sdk.init(
168+
sentry_init(
168169
integrations=[RayIntegration()],
169170
disabled_integrations=[StdlibIntegration],
170171
transport=RayTestTransport(),
@@ -237,8 +238,8 @@ def test_tracing_in_ray_tasks(
237238
assert client_spans[1]["trace_id"] == worker_spans[1]["trace_id"]
238239

239240

240-
def test_errors_in_ray_tasks():
241-
sentry_sdk.init(
241+
def test_errors_in_ray_tasks(sentry_init):
242+
sentry_init(
242243
integrations=[RayIntegration()],
243244
disabled_integrations=[StdlibIntegration],
244245
transport=RayTestTransport(),
@@ -288,9 +289,10 @@ def example_task():
288289
# Arbitrary keyword argument to test all decorator paths
289290
@pytest.mark.parametrize("remote_kwargs", [{}, {"namespace": "actors"}])
290291
def test_tracing_in_ray_actors(
292+
sentry_init,
291293
remote_kwargs,
292294
):
293-
sentry_sdk.init(
295+
sentry_init(
294296
integrations=[RayIntegration()],
295297
disabled_integrations=[StdlibIntegration],
296298
transport=RayTestTransport(),
@@ -363,8 +365,8 @@ def increment(self):
363365
assert len(worker_spans) == 1
364366

365367

366-
def test_errors_in_ray_actors():
367-
sentry_sdk.init(
368+
def test_errors_in_ray_actors(sentry_init):
369+
sentry_init(
368370
integrations=[RayIntegration()],
369371
disabled_integrations=[StdlibIntegration],
370372
transport=RayLoggingTransport(),

‎tests/test_data_collection.py‎

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
from sentry_sdk.utils import has_data_collection_enabled
88

99

10-
def test_kvcb_invalid_mode():
10+
def test_kvcb_invalid_mode(sentry_init):
1111
with pytest.raises(ValueError):
12-
sentry_sdk.init(data_collection={"cookies": {"mode": "nope"}}) # type: ignore Purposely ignoring to test invalid option
12+
sentry_init(data_collection={"cookies": {"mode": "nope"}}) # type: ignore Purposely ignoring to test invalid option
1313

1414

15-
def test_stack_frame_variables_invalid_mode():
15+
def test_stack_frame_variables_invalid_mode(sentry_init):
1616
with pytest.raises(ValueError):
17-
sentry_sdk.init(data_collection={"stack_frame_variables": {"mode": "nope"}})
17+
sentry_init(data_collection={"stack_frame_variables": {"mode": "nope"}})
1818

1919

2020
@pytest.mark.parametrize(
@@ -27,45 +27,45 @@ def test_stack_frame_variables_invalid_mode():
2727
"frame_context_lines_float",
2828
],
2929
)
30-
def test_frame_context_lines_invalid_value(value):
30+
def test_frame_context_lines_invalid_value(sentry_init, value):
3131
with pytest.raises(ValueError):
32-
sentry_sdk.init(data_collection={"frame_context_lines": value})
32+
sentry_init(data_collection={"frame_context_lines": value})
3333

3434

35-
def test_kvcb_from_dict_defaults_mode():
36-
sentry_sdk.init(data_collection={"cookies": {"mode": "denylist", "terms": ["x"]}})
35+
def test_kvcb_from_dict_defaults_mode(sentry_init):
36+
sentry_init(data_collection={"cookies": {"mode": "denylist", "terms": ["x"]}})
3737
client = sentry_sdk.get_client()
3838
assert client.options["data_collection"]["cookies"] == {
3939
"mode": "denylist",
4040
"terms": ["x"],
4141
}
4242

4343

44-
def test_http_headers_collection_defaults():
44+
def test_http_headers_collection_defaults(sentry_init):
4545
default_terms = ["forwarded", "-ip", "remote-", "via", "-user"]
4646

47-
sentry_sdk.init(data_collection={"http_headers": {}}) # type: ignore Purposely ignoring to test invalid option
47+
sentry_init(data_collection={"http_headers": {}}) # type: ignore Purposely ignoring to test invalid option
4848
client = sentry_sdk.get_client()
4949
assert client.options["data_collection"]["http_headers"]["request"] == {
5050
"mode": "denylist"
5151
}
5252

53-
sentry_sdk.init(data_collection={"http_headers": "off"}) # type: ignore Purposely ignoring to test invalid option
53+
sentry_init(data_collection={"http_headers": "off"}) # type: ignore Purposely ignoring to test invalid option
5454
client = sentry_sdk.get_client()
5555
assert client.options["data_collection"]["http_headers"]["request"] == {
5656
"mode": "denylist"
5757
}
5858

59-
sentry_sdk.init()
59+
sentry_init()
6060
client = sentry_sdk.get_client()
6161
assert client.options["data_collection"]["http_headers"]["request"] == {
6262
"mode": "denylist",
6363
"terms": default_terms,
6464
}
6565

6666

67-
def test_http_headers_use_default_in_setting_with_missing_config():
68-
sentry_sdk.init(
67+
def test_http_headers_use_default_in_setting_with_missing_config(sentry_init):
68+
sentry_init(
6969
data_collection={
7070
"http_headers": {
7171
"request": {"mode": "allowlist", "terms": ["x-id"]},
@@ -81,8 +81,8 @@ def test_http_headers_use_default_in_setting_with_missing_config():
8181
}
8282

8383

84-
def _initialize_client_with_config(**options):
85-
sentry_sdk.init(**options)
84+
def _initialize_client_with_config(sentry_init, **options):
85+
sentry_init(**options)
8686
return sentry_sdk.get_client().options["data_collection"]
8787

8888

@@ -323,16 +323,19 @@ def _get(dc, path):
323323
),
324324
],
325325
)
326-
def test_initialize_client_data_collection(options, expected):
327-
dc = _initialize_client_with_config(**options)
326+
def test_initialize_client_data_collection(sentry_init, options, expected):
327+
dc = _initialize_client_with_config(sentry_init, **options)
328328
for path, value in expected.items():
329329
assert _get(dc, path) == value, f"{path} != {value!r}"
330330

331331

332-
def test_initialize_client_data_collection_overrides_send_default_pii_and_warns():
332+
def test_initialize_client_data_collection_overrides_send_default_pii_and_warns(
333+
sentry_init,
334+
):
333335
with warnings.catch_warnings(record=True) as caught:
334336
warnings.simplefilter("always")
335337
dc = _initialize_client_with_config(
338+
sentry_init,
336339
send_default_pii=True,
337340
data_collection={"user_info": False},
338341
)
@@ -377,8 +380,8 @@ def test_initialize_client_data_collection_overrides_send_default_pii_and_warns(
377380
),
378381
],
379382
)
380-
def test_client_data_collection_settings(init_kwargs, expected):
381-
sentry_sdk.init(**init_kwargs)
383+
def test_client_data_collection_settings(sentry_init, init_kwargs, expected):
384+
sentry_init(**init_kwargs)
382385
client = sentry_sdk.get_client()
383386
for key, value in expected.items():
384387
if key == "should_send_default_pii":
@@ -419,13 +422,17 @@ def test_has_data_collection_enabled_gates_on_user_provided_config():
419422
),
420423
],
421424
)
422-
def test_has_data_collection_enabled_after_resolution(init_kwargs, expected):
423-
sentry_sdk.init(**init_kwargs)
425+
def test_has_data_collection_enabled_after_resolution(
426+
sentry_init, init_kwargs, expected
427+
):
428+
sentry_init(**init_kwargs)
424429
assert has_data_collection_enabled(sentry_sdk.get_client().options) is expected
425430

426431

427-
def test_no_data_collection_values_fall_back_to_send_default_pii_configuration():
428-
sentry_sdk.init(send_default_pii=True)
432+
def test_no_data_collection_values_fall_back_to_send_default_pii_configuration(
433+
sentry_init,
434+
):
435+
sentry_init(send_default_pii=True)
429436
client = sentry_sdk.get_client()
430437
dc = client.options["data_collection"]
431438
assert dc["provided_by_user"] is False

‎tox.ini‎

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)