Skip to content

Commit 5cfafa5

Browse files
authored
fix: Support Decimal for tag_object (#214)
* fix: Support Decimal for tag_object * fix: black * fix: black * feat: --allow-releaseinfo-change * feat: --fix-missing * add apt-get update before apt install
1 parent 1f59f3a commit 5cfafa5

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ jobs:
101101
run: sudo yarn global add serverless@^2.72.2 --prefix /usr/local
102102
- name: Install Crossbuild Deps
103103
run: |
104-
sudo apt-get update
104+
sudo apt-get update --allow-releaseinfo-change --fix-missing
105105
sudo apt install -y qemu-user-static binfmt-support
106106
107107
- name: Install dependencies

.github/workflows/check-size.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ jobs:
1515
python-version: 3.7
1616

1717
- name: Install Crossbuild Deps
18-
run: sudo apt install -y qemu-user-static binfmt-support
18+
run: |
19+
sudo apt-get update --allow-releaseinfo-change --fix-missing
20+
sudo apt install -y qemu-user-static binfmt-support
1921
2022
- name: Install dependencies
2123
run: |

datadog_lambda/tag_object.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# This product includes software developed at Datadog (https://www.datadoghq.com/).
44
# Copyright 2021 Datadog, Inc.
55

6+
from decimal import Decimal
67
import json
78
import logging
89

@@ -26,7 +27,7 @@ def tag_object(span, key, obj, depth=0):
2627
except ValueError:
2728
redacted = _redact_val(key, obj[0:5000])
2829
return span.set_tag(key, redacted)
29-
if isinstance(obj, int) or isinstance(obj, float):
30+
if isinstance(obj, int) or isinstance(obj, float) or isinstance(obj, Decimal):
3031
return span.set_tag(key, obj)
3132
if isinstance(obj, list):
3233
for k, v in enumerate(obj):

tests/test_tag_object.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import unittest
2+
from decimal import Decimal
23

34
try:
45
from unittest.mock import MagicMock, patch, call
@@ -82,3 +83,14 @@ def test_unicode_tag_object(self):
8283
],
8384
True,
8485
)
86+
87+
def test_decimal_tag_object(self):
88+
payload = {"myValue": Decimal(500.50)}
89+
spanMock = MagicMock()
90+
tag_object(spanMock, "function.request", payload)
91+
spanMock.set_tag.assert_has_calls(
92+
[
93+
call("function.request.myValue", Decimal(500.50)),
94+
],
95+
True,
96+
)

0 commit comments

Comments
 (0)