Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions datadog_lambda/metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
# Copyright 2019 Datadog, Inc.

import os
import json
import time
import logging
import ujson as json

from datadog_lambda.extension import should_use_extension
from datadog_lambda.tags import get_enhanced_metrics_tags, dd_lambda_layer_tag
Expand Down Expand Up @@ -85,7 +85,8 @@ def write_metric_point_to_stdout(metric_name, value, timestamp=None, tags=[]):
"v": value,
"e": timestamp or int(time.time()),
"t": tags,
}
},
escape_forward_slashes=False,
)
)

Expand Down
6 changes: 3 additions & 3 deletions datadog_lambda/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
# This product includes software developed at Datadog (https://www.datadoghq.com/).
# Copyright 2019 Datadog, Inc.

import json
import os
import sys
import logging
import zlib
import ujson as json

from wrapt import wrap_function_wrapper as wrap
from wrapt.importer import when_imported
Expand Down Expand Up @@ -144,14 +144,14 @@ def _print_request_string(request):
data = zlib.decompress(data)
data_dict = json.loads(data)
data_dict.get("series", []).sort(key=lambda series: series.get("metric"))
sorted_data = json.dumps(data_dict)
sorted_data = json.dumps(data_dict, escape_forward_slashes=False)

# Sort headers to prevent any differences in ordering
headers = request.headers or {}
sorted_headers = sorted(
"{}:{}".format(key, value) for key, value in headers.items()
)
sorted_header_str = json.dumps(sorted_headers)
sorted_header_str = json.dumps(sorted_headers, escape_forward_slashes=False)
print(
"HTTP {} {} Headers: {} Data: {}".format(
method, url, sorted_header_str, sorted_data
Expand Down
2 changes: 1 addition & 1 deletion datadog_lambda/tag_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
# Copyright 2021 Datadog, Inc.

from decimal import Decimal
import json
import logging
import ujson as json

redactable_keys = ["authorization", "x-authorization", "password", "token"]
max_depth = 10
Expand Down
2 changes: 1 addition & 1 deletion datadog_lambda/tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import hashlib
import logging
import os
import json
import base64
import ujson as json
from datetime import datetime, timezone
from typing import Optional, Dict

Expand Down
2 changes: 1 addition & 1 deletion datadog_lambda/trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import base64
import gzip
import json
import ujson as json
from io import BytesIO, BufferedReader
from enum import Enum
from typing import Any
Expand Down
6 changes: 4 additions & 2 deletions datadog_lambda/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import os
import logging
import traceback
import ujson as json
from importlib import import_module
import json
from time import time_ns

from datadog_lambda.extension import should_use_extension, flush_extension
Expand Down Expand Up @@ -258,7 +258,9 @@ def _inject_authorizer_span_headers(self, request_id):
injected_headers[Headers.Parent_Span_Finish_Time] = finish_time_ns
if request_id is not None:
injected_headers[Headers.Authorizing_Request_Id] = request_id
datadog_data = base64.b64encode(json.dumps(injected_headers).encode()).decode()
datadog_data = base64.b64encode(
json.dumps(injected_headers, escape_forward_slashes=False).encode()
).decode()
self.response.setdefault("context", {})
self.response["context"]["_datadog"] = datadog_data

Expand Down
5 changes: 3 additions & 2 deletions datadog_lambda/xray.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import os
import logging
import json
import binascii
import time
import socket
import ujson as json

from datadog_lambda.constants import XrayDaemon, XraySubsegment, TraceContextSource

Expand Down Expand Up @@ -102,7 +102,8 @@ def build_segment(context, key, metadata):
key: metadata,
}
},
}
},
escape_forward_slashes=False,
)
return segment

Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ python = ">=3.8.0,<4"
datadog = ">=0.41.0,<1.0.0"
wrapt = "^1.11.2"
ddtrace = ">=2.7.2"
ujson = ">=5.9.0"
urllib3 = [
{version = "<2.0.0", python = "<3.11", optional = true},
{version = "<2.1.0", python = ">=3.11", optional = true},
Expand Down