Skip to content

Commit 139a9a1

Browse files
feat: Add server.address to transformed spans when stream_gen_ai_spans=True (#6307)
1 parent 7bf1d6e commit 139a9a1

4 files changed

Lines changed: 19 additions & 0 deletions

File tree

sentry_sdk/client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,8 @@ def _serialized_v1_span_to_serialized_v2_span(
225225
attributes["sentry.release"] = event["release"]
226226
if "environment" in event:
227227
attributes["sentry.environment"] = event["environment"]
228+
if "server_name" in event:
229+
attributes["server.address"] = event["server_name"]
228230
if "transaction" in event:
229231
attributes["sentry.segment.name"] = event["transaction"]
230232

tests/integrations/huggingface_hub/test_huggingface_hub.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,7 @@ def test_text_generation(
529529
"sentry.sdk.version": mock.ANY,
530530
"sentry.segment.id": mock.ANY,
531531
"sentry.segment.name": "test",
532+
"server.address": mock.ANY,
532533
"thread.id": mock.ANY,
533534
"thread.name": mock.ANY,
534535
}
@@ -665,6 +666,7 @@ def test_text_generation_streaming(
665666
"sentry.sdk.version": mock.ANY,
666667
"sentry.segment.id": mock.ANY,
667668
"sentry.segment.name": "test",
669+
"server.address": mock.ANY,
668670
"thread.id": mock.ANY,
669671
"thread.name": mock.ANY,
670672
}
@@ -805,6 +807,7 @@ def test_chat_completion(
805807
"sentry.sdk.version": mock.ANY,
806808
"sentry.segment.id": mock.ANY,
807809
"sentry.segment.name": "test",
810+
"server.address": mock.ANY,
808811
"thread.id": mock.ANY,
809812
"thread.name": mock.ANY,
810813
}
@@ -953,6 +956,7 @@ def test_chat_completion_streaming(
953956
"sentry.sdk.version": mock.ANY,
954957
"sentry.segment.id": mock.ANY,
955958
"sentry.segment.name": "test",
959+
"server.address": mock.ANY,
956960
"thread.id": mock.ANY,
957961
"thread.name": mock.ANY,
958962
}
@@ -1099,6 +1103,7 @@ def test_chat_completion_api_error(
10991103
"sentry.sdk.version": mock.ANY,
11001104
"sentry.segment.id": mock.ANY,
11011105
"sentry.segment.name": "test",
1106+
"server.address": mock.ANY,
11021107
"thread.id": mock.ANY,
11031108
"thread.name": mock.ANY,
11041109
}
@@ -1297,6 +1302,7 @@ def test_chat_completion_with_tools(
12971302
"sentry.sdk.version": mock.ANY,
12981303
"sentry.segment.id": mock.ANY,
12991304
"sentry.segment.name": "test",
1305+
"server.address": mock.ANY,
13001306
"thread.id": mock.ANY,
13011307
"thread.name": mock.ANY,
13021308
}
@@ -1456,6 +1462,7 @@ def test_chat_completion_streaming_with_tools(
14561462
"sentry.sdk.version": mock.ANY,
14571463
"sentry.segment.id": mock.ANY,
14581464
"sentry.segment.name": "test",
1465+
"server.address": mock.ANY,
14591466
"thread.id": mock.ANY,
14601467
"thread.name": mock.ANY,
14611468
}

tests/integrations/openai/test_openai.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3643,6 +3643,7 @@ def test_ai_client_span_responses_api_no_pii(
36433643
"sentry.sdk.version": mock.ANY,
36443644
"sentry.segment.id": mock.ANY,
36453645
"sentry.segment.name": "openai tx",
3646+
"server.address": mock.ANY,
36463647
"thread.id": mock.ANY,
36473648
"thread.name": mock.ANY,
36483649
}
@@ -3898,6 +3899,7 @@ def test_ai_client_span_responses_api(
38983899
"sentry.sdk.version": mock.ANY,
38993900
"sentry.segment.id": mock.ANY,
39003901
"sentry.segment.name": "openai tx",
3902+
"server.address": mock.ANY,
39013903
"thread.id": mock.ANY,
39023904
"thread.name": mock.ANY,
39033905
}
@@ -4293,6 +4295,7 @@ async def test_ai_client_span_responses_async_api(
42934295
"sentry.sdk.version": mock.ANY,
42944296
"sentry.segment.id": mock.ANY,
42954297
"sentry.segment.name": "openai tx",
4298+
"server.address": mock.ANY,
42964299
"thread.id": mock.ANY,
42974300
"thread.name": mock.ANY,
42984301
}
@@ -4576,6 +4579,7 @@ async def test_ai_client_span_streaming_responses_async_api(
45764579
"sentry.sdk.version": mock.ANY,
45774580
"sentry.segment.id": mock.ANY,
45784581
"sentry.segment.name": "openai tx",
4582+
"server.address": mock.ANY,
45794583
"thread.id": mock.ANY,
45804584
"thread.name": mock.ANY,
45814585
}

tests/tracing/test_decorator.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ def my_agent():
195195
"sentry.sdk.version": mock.ANY,
196196
"sentry.segment.id": mock.ANY,
197197
"sentry.segment.name": "test-transaction",
198+
"server.address": mock.ANY,
198199
"thread.id": mock.ANY,
199200
"thread.name": mock.ANY,
200201
}
@@ -217,6 +218,7 @@ def my_agent():
217218
"sentry.sdk.version": mock.ANY,
218219
"sentry.segment.id": mock.ANY,
219220
"sentry.segment.name": "test-transaction",
221+
"server.address": mock.ANY,
220222
"thread.id": mock.ANY,
221223
"thread.name": mock.ANY,
222224
}
@@ -245,6 +247,7 @@ def my_agent():
245247
"sentry.sdk.version": mock.ANY,
246248
"sentry.segment.id": mock.ANY,
247249
"sentry.segment.name": "test-transaction",
250+
"server.address": mock.ANY,
248251
"thread.id": mock.ANY,
249252
"thread.name": mock.ANY,
250253
}
@@ -389,6 +392,7 @@ def my_agent():
389392
"sentry.sdk.version": mock.ANY,
390393
"sentry.segment.id": mock.ANY,
391394
"sentry.segment.name": "test-transaction",
395+
"server.address": mock.ANY,
392396
"thread.id": mock.ANY,
393397
"thread.name": mock.ANY,
394398
}
@@ -412,6 +416,7 @@ def my_agent():
412416
"sentry.sdk.version": mock.ANY,
413417
"sentry.segment.id": mock.ANY,
414418
"sentry.segment.name": "test-transaction",
419+
"server.address": mock.ANY,
415420
"thread.id": mock.ANY,
416421
"thread.name": mock.ANY,
417422
}
@@ -439,6 +444,7 @@ def my_agent():
439444
"sentry.sdk.version": mock.ANY,
440445
"sentry.segment.id": mock.ANY,
441446
"sentry.segment.name": "test-transaction",
447+
"server.address": mock.ANY,
442448
"thread.id": mock.ANY,
443449
"thread.name": mock.ANY,
444450
}

0 commit comments

Comments
 (0)