rebrandly-otel 0.1.19__tar.gz → 0.1.20__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of rebrandly-otel might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rebrandly_otel
3
- Version: 0.1.19
3
+ Version: 0.1.20
4
4
  Summary: Python OTEL wrapper by Rebrandly
5
5
  Home-page: https://github.com/rebrandly/rebrandly-otel-python
6
6
  Author: Antonio Romano
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rebrandly_otel
3
- Version: 0.1.19
3
+ Version: 0.1.20
4
4
  Summary: Python OTEL wrapper by Rebrandly
5
5
  Home-page: https://github.com/rebrandly/rebrandly-otel-python
6
6
  Author: Antonio Romano
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
5
5
 
6
6
  setuptools.setup(
7
7
  name="rebrandly_otel",
8
- version="0.1.19",
8
+ version="0.1.20",
9
9
  author="Antonio Romano",
10
10
  author_email="antonio@rebrandly.com",
11
11
  description="Python OTEL wrapper by Rebrandly",
@@ -4,6 +4,7 @@
4
4
  import os
5
5
  import sys
6
6
  import grpc
7
+ import json
7
8
 
8
9
  from opentelemetry.sdk.resources import Resource
9
10
  from opentelemetry.semconv.attributes import service_attributes
@@ -86,4 +87,23 @@ def get_millis_batch_time():
86
87
  return int(os.environ.get('BATCH_EXPORT_TIME_MILLIS', 100))
87
88
  except Exception as e:
88
89
  print(f"[OTEL Utils] Warning: Invalid BATCH_EXPORT_TIME_MILLIS value, using default 5000ms: {e}")
89
- return 5000
90
+ return 5000
91
+
92
+ def extract_event_from(message) -> str | None:
93
+ body = None
94
+ if 'body' in message:
95
+ body = message['body']
96
+ if 'Body' in message:
97
+ body = message['Body']
98
+ if 'Message' in message:
99
+ body = message['Message']
100
+ if 'Sns' in message and 'Message' in message['Sns']:
101
+ body = message['Sns']['Message']
102
+ if body is not None:
103
+ try:
104
+ jbody = json.loads(body)
105
+ if 'event' in jbody:
106
+ return jbody['event']
107
+ except:
108
+ pass
109
+ return None
@@ -12,6 +12,7 @@ from opentelemetry import baggage, propagate, context
12
12
  from .traces import RebrandlyTracer
13
13
  from .metrics import RebrandlyMeter
14
14
  from .logs import RebrandlyLogger
15
+ from .otel_utils import extract_event_from
15
16
 
16
17
 
17
18
  T = TypeVar('T')
@@ -262,6 +263,9 @@ class RebrandlyOTEL:
262
263
  span_function = self.span
263
264
  if record is not None and (('MessageAttributes' in record or 'messageAttributes' in record) or ('Sns' in record and 'MessageAttributes' in record['Sns'])):
264
265
  span_function = self.aws_message_span
266
+ evt = extract_event_from(record)
267
+ if evt:
268
+ span_attributes['event.type'] = evt
265
269
 
266
270
  with span_function(span_name, message=record, attributes=span_attributes, kind=kind) as span_context:
267
271
  # Add processing start event with standardized name
@@ -487,6 +491,10 @@ class RebrandlyOTEL:
487
491
  if 'awsRegion' in message:
488
492
  combined_attributes['cloud.region'] = message['awsRegion']
489
493
 
494
+ evt = extract_event_from(message)
495
+ if evt:
496
+ combined_attributes['event.type'] = evt
497
+
490
498
 
491
499
  # Use the tracer's start_span method directly to ensure it works
492
500
  # This creates a child span of whatever is currently active
File without changes