Skip to content

Commit 7ff12bc

Browse files
committed
attr name
1 parent f0514b6 commit 7ff12bc

3 files changed

Lines changed: 10 additions & 5 deletions

File tree

sentry_sdk/consts.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -882,6 +882,11 @@ class SPANDATA:
882882
The messaging system's name, e.g. `kafka`, `aws_sqs`
883883
"""
884884

885+
MIDDLEWARE_NAME = "middleware.name"
886+
"""
887+
The middleware's name, e.g. `AuthenticationMiddleware`
888+
"""
889+
885890
NETWORK_PROTOCOL_NAME = "network.protocol.name"
886891
"""
887892
The application layer protocol name used for the network connection.

sentry_sdk/integrations/starlite.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from copy import deepcopy
22

33
import sentry_sdk
4-
from sentry_sdk.consts import OP
4+
from sentry_sdk.consts import OP, SPANDATA
55
from sentry_sdk.integrations import DidNotEnable, Integration
66
from sentry_sdk.integrations.asgi import SentryAsgiMiddleware
77
from sentry_sdk.scope import should_send_default_pii
@@ -156,7 +156,7 @@ def _start_middleware_span(op: str, name: str) -> "Any":
156156
attributes={
157157
"sentry.op": op,
158158
"sentry.origin": StarliteIntegration.origin,
159-
"starlite.middleware_name": middleware_name,
159+
SPANDATA.MIDDLEWARE_NAME: middleware_name,
160160
},
161161
)
162162
return sentry_sdk.start_span(

tests/integrations/starlite/test_starlite.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def test_middleware_spans(sentry_init, capture_events, capture_items, span_strea
162162
assert span["name"] in expected
163163
assert span["name"] not in found
164164
found.add(span["name"])
165-
assert span["name"] == span["attributes"]["starlite.middleware_name"]
165+
assert span["name"] == span["attributes"]["middleware.name"]
166166
else:
167167
(_, transaction_event) = events
168168

@@ -246,7 +246,7 @@ def is_matching_span_streaming(expected_span, actual_span):
246246
expected_span["op"] == actual_span["attributes"]["sentry.op"]
247247
and expected_span["description"] == actual_span["name"]
248248
and expected_span["tags"]["starlite.middleware_name"]
249-
== actual_span["attributes"]["starlite.middleware_name"]
249+
== actual_span["attributes"]["middleware.name"]
250250
)
251251

252252
for expected_span in expected_starlite_spans:
@@ -377,7 +377,7 @@ def is_matching_span_streaming(expected_span, actual_span):
377377
expected_span["op"] == actual_span["attributes"]["sentry.op"]
378378
and actual_span["name"].startswith(expected_span["description"])
379379
and expected_span["tags"]["starlite.middleware_name"]
380-
== actual_span["attributes"]["starlite.middleware_name"]
380+
== actual_span["attributes"]["middleware.name"]
381381
)
382382

383383
for expected_span in expected_starlite_spans:

0 commit comments

Comments
 (0)