Skip to content

Commit 757f878

Browse files
fix tests
1 parent 68f6194 commit 757f878

15 files changed

Lines changed: 129 additions & 124 deletions

File tree

tests/integrations/aiomysql/test_aiomysql.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def _get_db_name():
4747
"db.name": MYSQL_DB,
4848
"db.system": "mysql",
4949
"db.user": MYSQL_USER,
50-
"server.address": MYSQL_HOST,
50+
SPANDATA.DEVICE_NAME: MYSQL_HOST,
5151
"server.port": MYSQL_PORT,
5252
}
5353
),
@@ -685,7 +685,7 @@ async def test_connection_pool(sentry_init, capture_events) -> None:
685685
assert len(connect_crumbs) >= pool_size # One connect span per pooled connection
686686
for crumb in connect_crumbs:
687687
assert crumb["data"]["db.system"] == "mysql"
688-
assert crumb["data"]["server.address"] == MYSQL_HOST
688+
assert crumb["data"][SPANDATA.DEVICE_NAME] == MYSQL_HOST
689689

690690

691691
@pytest.mark.asyncio

tests/integrations/asyncpg/test_asyncpg.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def _get_db_name():
5151
"db.system": "postgresql",
5252
"db.user": PG_USER,
5353
"db.driver.name": "asyncpg",
54-
"server.address": PG_HOST,
54+
SPANDATA.DEVICE_NAME: PG_HOST,
5555
"server.port": PG_PORT,
5656
}
5757
),
@@ -68,7 +68,7 @@ def _get_db_name():
6868
"db.namespace": PG_NAME,
6969
"db.user": PG_USER,
7070
"db.driver.name": "asyncpg",
71-
"server.address": PG_HOST,
71+
SPANDATA.DEVICE_NAME: PG_HOST,
7272
"server.port": PG_PORT,
7373
}
7474
),

tests/integrations/boto3/test_s3.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def test_streaming(
125125
"sentry.sdk.version": mock.ANY,
126126
"sentry.segment.id": mock.ANY,
127127
"sentry.segment.name": "custom parent",
128-
"server.address": mock.ANY,
128+
SPANDATA.DEVICE_NAME: mock.ANY,
129129
"thread.id": mock.ANY,
130130
"thread.name": mock.ANY,
131131
}
@@ -283,7 +283,7 @@ def test_omit_url_data_if_parsing_fails(
283283
"sentry.sdk.version": mock.ANY,
284284
"sentry.segment.id": mock.ANY,
285285
"sentry.segment.name": "custom parent",
286-
"server.address": mock.ANY,
286+
SPANDATA.DEVICE_NAME: mock.ANY,
287287
"thread.id": mock.ANY,
288288
"thread.name": mock.ANY,
289289
}

tests/integrations/clickhouse_driver/test_clickhouse_driver.py

Lines changed: 81 additions & 80 deletions
Large diffs are not rendered by default.

tests/integrations/grpc/test_grpc.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import sentry_sdk
1010
from sentry_sdk import start_span, start_transaction
11-
from sentry_sdk.consts import OP
11+
from sentry_sdk.consts import OP, SPANDATA
1212
from sentry_sdk.integrations.grpc import GRPCIntegration
1313
from sentry_sdk.integrations.grpc.client import ClientInterceptor
1414
from sentry_sdk.tracing_utils import has_span_streaming_enabled
@@ -316,7 +316,7 @@ def test_grpc_client_starts_span(
316316
"sentry.sdk.version": mock.ANY,
317317
"sentry.segment.id": mock.ANY,
318318
"sentry.segment.name": "custom parent",
319-
"server.address": mock.ANY,
319+
SPANDATA.DEVICE_NAME: mock.ANY,
320320
"thread.id": mock.ANY,
321321
"thread.name": mock.ANY,
322322
"rpc.response.status_code": "OK",
@@ -400,7 +400,7 @@ def test_grpc_client_unary_stream_starts_span(
400400
"sentry.sdk.version": mock.ANY,
401401
"sentry.segment.id": mock.ANY,
402402
"sentry.segment.name": "custom parent",
403-
"server.address": mock.ANY,
403+
SPANDATA.DEVICE_NAME: mock.ANY,
404404
"thread.id": mock.ANY,
405405
"thread.name": mock.ANY,
406406
}
@@ -494,7 +494,7 @@ def test_grpc_client_other_interceptor(
494494
"sentry.sdk.version": mock.ANY,
495495
"sentry.segment.id": mock.ANY,
496496
"sentry.segment.name": "custom parent",
497-
"server.address": mock.ANY,
497+
SPANDATA.DEVICE_NAME: mock.ANY,
498498
"thread.id": mock.ANY,
499499
"thread.name": mock.ANY,
500500
"rpc.response.status_code": "OK",

tests/integrations/grpc/test_grpc_aio.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import sentry_sdk
1010
from sentry_sdk import start_span, start_transaction
11-
from sentry_sdk.consts import OP
11+
from sentry_sdk.consts import OP, SPANDATA
1212
from sentry_sdk.integrations.grpc import GRPCIntegration
1313
from sentry_sdk.tracing_utils import has_span_streaming_enabled
1414
from tests.conftest import ApproxDict
@@ -341,7 +341,7 @@ async def test_grpc_client_starts_span(
341341
"sentry.sdk.version": mock.ANY,
342342
"sentry.segment.id": mock.ANY,
343343
"sentry.segment.name": "custom parent",
344-
"server.address": mock.ANY,
344+
SPANDATA.DEVICE_NAME: mock.ANY,
345345
"thread.id": mock.ANY,
346346
"thread.name": mock.ANY,
347347
"rpc.response.status_code": "OK",
@@ -416,7 +416,7 @@ async def test_grpc_client_unary_stream_starts_span(
416416
"sentry.sdk.version": mock.ANY,
417417
"sentry.segment.id": mock.ANY,
418418
"sentry.segment.name": "custom parent",
419-
"server.address": mock.ANY,
419+
SPANDATA.DEVICE_NAME: mock.ANY,
420420
"thread.id": mock.ANY,
421421
"thread.name": mock.ANY,
422422
}

tests/integrations/huggingface_hub/test_huggingface_hub.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ def test_text_generation(
532532
"sentry.sdk.version": mock.ANY,
533533
"sentry.segment.id": mock.ANY,
534534
"sentry.segment.name": "test",
535-
"server.address": mock.ANY,
535+
SPANDATA.DEVICE_NAME: mock.ANY,
536536
"thread.id": mock.ANY,
537537
"thread.name": mock.ANY,
538538
}
@@ -671,7 +671,7 @@ def test_text_generation_streaming(
671671
"sentry.sdk.version": mock.ANY,
672672
"sentry.segment.id": mock.ANY,
673673
"sentry.segment.name": "test",
674-
"server.address": mock.ANY,
674+
SPANDATA.DEVICE_NAME: mock.ANY,
675675
"thread.id": mock.ANY,
676676
"thread.name": mock.ANY,
677677
}
@@ -814,7 +814,7 @@ def test_chat_completion(
814814
"sentry.sdk.version": mock.ANY,
815815
"sentry.segment.id": mock.ANY,
816816
"sentry.segment.name": "test",
817-
"server.address": mock.ANY,
817+
SPANDATA.DEVICE_NAME: mock.ANY,
818818
"thread.id": mock.ANY,
819819
"thread.name": mock.ANY,
820820
}
@@ -965,7 +965,7 @@ def test_chat_completion_streaming(
965965
"sentry.sdk.version": mock.ANY,
966966
"sentry.segment.id": mock.ANY,
967967
"sentry.segment.name": "test",
968-
"server.address": mock.ANY,
968+
SPANDATA.DEVICE_NAME: mock.ANY,
969969
"thread.id": mock.ANY,
970970
"thread.name": mock.ANY,
971971
}
@@ -1114,7 +1114,7 @@ def test_chat_completion_api_error(
11141114
"sentry.sdk.version": mock.ANY,
11151115
"sentry.segment.id": mock.ANY,
11161116
"sentry.segment.name": "test",
1117-
"server.address": mock.ANY,
1117+
SPANDATA.DEVICE_NAME: mock.ANY,
11181118
"thread.id": mock.ANY,
11191119
"thread.name": mock.ANY,
11201120
}
@@ -1315,7 +1315,7 @@ def test_chat_completion_with_tools(
13151315
"sentry.sdk.version": mock.ANY,
13161316
"sentry.segment.id": mock.ANY,
13171317
"sentry.segment.name": "test",
1318-
"server.address": mock.ANY,
1318+
SPANDATA.DEVICE_NAME: mock.ANY,
13191319
"thread.id": mock.ANY,
13201320
"thread.name": mock.ANY,
13211321
}
@@ -1477,7 +1477,7 @@ def test_chat_completion_streaming_with_tools(
14771477
"sentry.sdk.version": mock.ANY,
14781478
"sentry.segment.id": mock.ANY,
14791479
"sentry.segment.name": "test",
1480-
"server.address": mock.ANY,
1480+
SPANDATA.DEVICE_NAME: mock.ANY,
14811481
"thread.id": mock.ANY,
14821482
"thread.name": mock.ANY,
14831483
}

tests/integrations/logging/test_logging.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import pytest
66

77
from sentry_sdk import get_client
8-
from sentry_sdk.consts import VERSION
8+
from sentry_sdk.consts import SPANDATA, VERSION
99
from sentry_sdk.integrations.logging import (
1010
LoggingIntegration,
1111
ignore_logger,
@@ -572,9 +572,9 @@ def test_logger_with_all_attributes(sentry_init, capture_items):
572572
assert isinstance(attributes["sentry.release"], str)
573573
del attributes["sentry.release"]
574574

575-
assert "server.address" in attributes
576-
assert isinstance(attributes["server.address"], str)
577-
del attributes["server.address"]
575+
assert SPANDATA.DEVICE_NAME in attributes
576+
assert isinstance(attributes[SPANDATA.DEVICE_NAME], str)
577+
del attributes[SPANDATA.DEVICE_NAME]
578578

579579
assert "thread.id" in attributes
580580
assert isinstance(attributes["thread.id"], int)

tests/integrations/loguru/test_loguru.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from loguru._recattrs import RecordFile, RecordLevel
77

88
import sentry_sdk
9-
from sentry_sdk.consts import VERSION
9+
from sentry_sdk.consts import SPANDATA, VERSION
1010
from sentry_sdk.integrations.loguru import LoggingLevels, LoguruIntegration
1111

1212
logger.remove(0) # don't print to console
@@ -507,9 +507,9 @@ def test_logger_with_all_attributes(
507507
assert isinstance(attributes["sentry.release"], str)
508508
del attributes["sentry.release"]
509509

510-
assert "server.address" in attributes
511-
assert isinstance(attributes["server.address"], str)
512-
del attributes["server.address"]
510+
assert SPANDATA.DEVICE_NAME in attributes
511+
assert isinstance(attributes[SPANDATA.DEVICE_NAME], str)
512+
del attributes[SPANDATA.DEVICE_NAME]
513513

514514
assert "thread.id" in attributes
515515
assert isinstance(attributes["thread.id"], int)

tests/integrations/socket/test_socket.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import sentry_sdk
66
from sentry_sdk import start_transaction
7+
from sentry_sdk.consts import SPANDATA
78
from sentry_sdk.integrations.socket import SocketIntegration
89
from tests.conftest import ApproxDict, create_mock_http_server
910

@@ -30,7 +31,7 @@ def test_getaddrinfo_trace(sentry_init, capture_events, capture_items, span_stre
3031
assert dns_span["attributes"]["sentry.op"] == "socket.dns"
3132
assert dns_span["attributes"]["sentry.origin"] == "auto.socket.socket"
3233
assert dns_span["name"] == f"localhost:{PORT}" # noqa: E231
33-
assert dns_span["attributes"]["server.address"] == "localhost"
34+
assert dns_span["attributes"][SPANDATA.DEVICE_NAME] == "localhost"
3435
assert dns_span["attributes"]["server.port"] == PORT
3536
else:
3637
events = capture_events()
@@ -76,12 +77,12 @@ def test_create_connection_trace(
7677

7778
assert connect_span["attributes"]["sentry.op"] == "socket.connection"
7879
assert connect_span["name"] == f"localhost:{PORT}" # noqa: E231
79-
assert connect_span["attributes"]["server.address"] == "localhost"
80+
assert connect_span["attributes"][SPANDATA.DEVICE_NAME] == "localhost"
8081
assert connect_span["attributes"]["server.port"] == PORT
8182

8283
assert dns_span["attributes"]["sentry.op"] == "socket.dns"
8384
assert dns_span["name"] == f"localhost:{PORT}" # noqa: E231
84-
assert dns_span["attributes"]["server.address"] == "localhost"
85+
assert dns_span["attributes"][SPANDATA.DEVICE_NAME] == "localhost"
8586
assert dns_span["attributes"]["server.port"] == PORT
8687
else:
8788
events = capture_events()

0 commit comments

Comments
 (0)