Skip to content

Commit dd9c62b

Browse files
authored
Merge branch 'master' into ivana/add-transport-timeouts
2 parents 19cc84a + 97c435a commit dd9c62b

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

sentry_sdk/client.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
from sentry_sdk.tracing import trace
2828
from sentry_sdk.transport import BaseHttpTransport, make_transport
2929
from sentry_sdk.consts import (
30+
SPANDATA,
3031
DEFAULT_MAX_VALUE_LENGTH,
3132
DEFAULT_OPTIONS,
3233
INSTRUMENTER,
@@ -894,6 +895,13 @@ def _capture_experimental_log(self, current_scope, log):
894895
return
895896
isolation_scope = current_scope.get_isolation_scope()
896897

898+
log["attributes"]["sentry.sdk.name"] = SDK_INFO["name"]
899+
log["attributes"]["sentry.sdk.version"] = SDK_INFO["version"]
900+
901+
server_name = self.options.get("server_name")
902+
if server_name is not None and SPANDATA.SERVER_ADDRESS not in log["attributes"]:
903+
log["attributes"][SPANDATA.SERVER_ADDRESS] = server_name
904+
897905
environment = self.options.get("environment")
898906
if environment is not None and "sentry.environment" not in log["attributes"]:
899907
log["attributes"]["sentry.environment"] = environment

tests/test_logs.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from sentry_sdk.envelope import Envelope
1212
from sentry_sdk.integrations.logging import LoggingIntegration
1313
from sentry_sdk.types import Log
14+
from sentry_sdk.consts import SPANDATA, VERSION
1415

1516
minimum_python_37 = pytest.mark.skipif(
1617
sys.version_info < (3, 7), reason="Asyncio tests need Python >= 3.7"
@@ -161,7 +162,7 @@ def test_logs_attributes(sentry_init, capture_envelopes):
161162
"""
162163
Passing arbitrary attributes to log messages.
163164
"""
164-
sentry_init(_experiments={"enable_logs": True})
165+
sentry_init(_experiments={"enable_logs": True}, server_name="test-server")
165166
envelopes = capture_envelopes()
166167

167168
attrs = {
@@ -184,6 +185,9 @@ def test_logs_attributes(sentry_init, capture_envelopes):
184185
assert logs[0]["attributes"]["sentry.environment"] == "production"
185186
assert "sentry.release" in logs[0]["attributes"]
186187
assert logs[0]["attributes"]["sentry.message.parameters.my_var"] == "some value"
188+
assert logs[0]["attributes"][SPANDATA.SERVER_ADDRESS] == "test-server"
189+
assert logs[0]["attributes"]["sentry.sdk.name"] == "sentry.python"
190+
assert logs[0]["attributes"]["sentry.sdk.version"] == VERSION
187191

188192

189193
@minimum_python_37

0 commit comments

Comments
 (0)