@@ -1200,6 +1200,7 @@ def __init__(
1200
1200
scope = None , # type: Optional[Scope]
1201
1201
start_timestamp = None , # type: Optional[Union[datetime, float]]
1202
1202
origin = None , # type: Optional[str]
1203
+ name = None , # type: Optional[str]
1203
1204
** _ , # type: dict[str, object]
1204
1205
):
1205
1206
# type: (...) -> None
@@ -1224,6 +1225,7 @@ def __init__(
1224
1225
self .origin = origin or DEFAULT_SPAN_ORIGIN
1225
1226
self .op = op
1226
1227
self .description = description
1228
+ self .name = name
1227
1229
if status is not None :
1228
1230
self .set_status (status )
1229
1231
@@ -1303,7 +1305,9 @@ def containing_transaction(self):
1303
1305
.. deprecated:: 3.0.0
1304
1306
This will be removed in the future. Use :func:`root_span` instead.
1305
1307
"""
1306
- logger .warning ("Deprecated: This will be removed in the future." )
1308
+ logger .warning (
1309
+ "Deprecated: This will be removed in the future. Use root_span instead."
1310
+ )
1307
1311
return self .root_span
1308
1312
1309
1313
@containing_transaction .setter
@@ -1318,17 +1322,11 @@ def containing_transaction(self, value):
1318
1322
1319
1323
@property
1320
1324
def root_span (self ):
1321
- if isinstance (self ._otel_span , otel_trace .NonRecordingSpan ):
1322
- return None
1323
-
1324
- parent = None
1325
- while True :
1326
- if self ._otel_span .parent :
1327
- parent = self ._otel_span .parent
1328
- else :
1329
- break
1330
-
1331
- return parent
1325
+ # type: () -> Optional[POTelSpan]
1326
+ # XXX implement this
1327
+ # there's a span.parent property, but it returns the parent spancontext
1328
+ # not sure if there's a way to retrieve the parent with pure otel.
1329
+ return None
1332
1330
1333
1331
@root_span .setter
1334
1332
def root_span (self , value ):
@@ -1371,7 +1369,7 @@ def op(self):
1371
1369
# type: () -> Optional[str]
1372
1370
from sentry_sdk .integrations .opentelemetry .consts import SentrySpanAttribute
1373
1371
1374
- self ._otel_span .attributes .get (SentrySpanAttribute .OP )
1372
+ return self ._otel_span .attributes .get (SentrySpanAttribute .OP )
1375
1373
1376
1374
@op .setter
1377
1375
def op (self , value ):
@@ -1383,13 +1381,18 @@ def op(self, value):
1383
1381
1384
1382
@property
1385
1383
def name (self ):
1386
- # type: () -> str
1387
- pass
1384
+ # type: () -> Optional[str]
1385
+ from sentry_sdk .integrations .opentelemetry .consts import SentrySpanAttribute
1386
+
1387
+ return self ._otel_span .attributes .get (SentrySpanAttribute .NAME )
1388
1388
1389
1389
@name .setter
1390
1390
def name (self , value ):
1391
- # type: (str) -> None
1392
- pass
1391
+ # type: (Optional[str]) -> None
1392
+ from sentry_sdk .integrations .opentelemetry .consts import SentrySpanAttribute
1393
+
1394
+ if value is not None :
1395
+ self ._otel_span .set_attribute (SentrySpanAttribute .NAME , value )
1393
1396
1394
1397
@property
1395
1398
def source (self ):
0 commit comments