Skip to content

Commit 983f6aa

Browse files
committed
submit metric for dynamodb stream type
1 parent 58a55bb commit 983f6aa

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

datadog_lambda/metric.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,3 +188,12 @@ def submit_errors_metric(lambda_context):
188188
lambda_context (object): Lambda context dict passed to the function by AWS
189189
"""
190190
submit_enhanced_metric("errors", lambda_context)
191+
192+
def submit_dynamodb_stream_type_metric(event):
193+
stream_view_type = (
194+
event.get('Records', [{}])[0]
195+
.get('dynamodb', {})
196+
.get('StreamViewType')
197+
)
198+
if stream_view_type:
199+
lambda_metric("datadog.serverless.dynamodb.stream.type", 1, timestamp=None, tags=[f"streamtype:{stream_view_type}"], force_async=True)

datadog_lambda/span_pointers.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
from ddtrace._trace._span_pointer import _SpanPointerDirection
88
from ddtrace._trace._span_pointer import _SpanPointerDescription
9+
10+
from datadog_lambda.metric import submit_dynamodb_stream_type_metric
911
from datadog_lambda.trigger import EventTypes
1012

1113

@@ -28,6 +30,7 @@ def calculate_span_pointers(
2830
return _calculate_s3_span_pointers_for_event(event)
2931

3032
elif event_source.equals(EventTypes.DYNAMODB):
33+
submit_dynamodb_stream_type_metric(event) # Temporary metric. TODO eventually remove(@nhulston)
3134
return _calculate_dynamodb_span_pointers_for_event(event)
3235

3336
except Exception as e:

0 commit comments

Comments
 (0)