@@ -307,62 +307,65 @@ def _update_span_with_otel_data(self, sentry_span, otel_span):
307
307
Convert OTel span data and update the Sentry span with it.
308
308
This should eventually happen on the server when ingesting the spans.
309
309
"""
310
- if otel_span .attributes is not None :
311
- for key , val in otel_span .attributes .items ():
312
- sentry_span .set_data (key , val )
313
-
314
310
sentry_span .set_data ("otel.kind" , otel_span .kind )
315
311
316
312
op = otel_span .name
317
313
description = otel_span .name
318
314
319
- http_method = otel_span .attributes .get (SpanAttributes .HTTP_METHOD , None )
320
- db_query = otel_span .attributes .get (SpanAttributes .DB_SYSTEM , None )
315
+ if otel_span .attributes is not None :
316
+ for key , val in otel_span .attributes .items ():
317
+ sentry_span .set_data (key , val )
321
318
322
- if http_method :
323
- op = "http"
319
+ http_method = otel_span . attributes . get ( SpanAttributes . HTTP_METHOD , None )
320
+ db_query = otel_span . attributes . get ( SpanAttributes . DB_SYSTEM , None )
324
321
325
- if otel_span .kind == SpanKind .SERVER :
326
- op += ".server"
327
- elif otel_span .kind == SpanKind .CLIENT :
328
- op += ".client"
322
+ if http_method :
323
+ op = "http"
329
324
330
- description = http_method
325
+ if otel_span .kind == SpanKind .SERVER :
326
+ op += ".server"
327
+ elif otel_span .kind == SpanKind .CLIENT :
328
+ op += ".client"
331
329
332
- peer_name = otel_span .attributes .get (SpanAttributes .NET_PEER_NAME , None )
333
- if peer_name :
334
- description += " {}" .format (peer_name )
330
+ description = http_method
335
331
336
- target = otel_span .attributes .get (SpanAttributes .HTTP_TARGET , None )
337
- if target :
338
- description += " {}" .format (target )
332
+ peer_name = otel_span .attributes .get (SpanAttributes .NET_PEER_NAME , None )
333
+ if peer_name :
334
+ description += " {}" .format (peer_name )
339
335
340
- if not peer_name and not target :
341
- url = otel_span .attributes .get (SpanAttributes .HTTP_URL , None )
342
- if url :
343
- parsed_url = urlparse (url )
344
- url = "{}://{}{}" .format (
345
- parsed_url .scheme , parsed_url .netloc , parsed_url .path
346
- )
347
- description += " {}" .format (url )
336
+ target = otel_span .attributes .get (SpanAttributes .HTTP_TARGET , None )
337
+ if target :
338
+ description += " {}" .format (target )
348
339
349
- status_code = otel_span .attributes .get (
350
- SpanAttributes .HTTP_STATUS_CODE , None
351
- )
352
- if status_code :
353
- sentry_span .set_http_status (status_code )
340
+ if not peer_name and not target :
341
+ url = otel_span .attributes .get (SpanAttributes .HTTP_URL , None )
342
+ if url :
343
+ parsed_url = urlparse (url )
344
+ url = "{}://{}{}" .format (
345
+ parsed_url .scheme , parsed_url .netloc , parsed_url .path
346
+ )
347
+ description += " {}" .format (url )
348
+
349
+ status_code = otel_span .attributes .get (
350
+ SpanAttributes .HTTP_STATUS_CODE , None
351
+ )
352
+ if status_code :
353
+ sentry_span .set_http_status (status_code )
354
354
355
- elif db_query :
356
- op = "db"
357
- statement = otel_span .attributes .get (SpanAttributes .DB_STATEMENT , None )
358
- if statement :
359
- description = statement
355
+ elif db_query :
356
+ op = "db"
357
+ statement = otel_span .attributes .get (SpanAttributes .DB_STATEMENT , None )
358
+ if statement :
359
+ description = statement
360
360
361
361
sentry_span .op = op
362
362
sentry_span .description = description
363
363
364
364
def _update_transaction_with_otel_data (self , sentry_span , otel_span ):
365
365
# type: (SentrySpan, OTelSpan) -> None
366
+ if otel_span .attributes is None :
367
+ return
368
+
366
369
http_method = otel_span .attributes .get (SpanAttributes .HTTP_METHOD )
367
370
368
371
if http_method :
0 commit comments