diff --git a/datadog_lambda/metric.py b/datadog_lambda/metric.py index 8b9029ba..5eb1c2ac 100644 --- a/datadog_lambda/metric.py +++ b/datadog_lambda/metric.py @@ -21,9 +21,20 @@ logger = logging.getLogger(__name__) -class StatsDWrapper: +class StatsWriter: + def distribution(self, metric_name, value, tags=[], timestamp=None): + raise NotImplementedError() + + def flush(self): + raise NotImplementedError() + + def stop(self): + raise NotImplementedError() + + +class StatsDWriter(StatsWriter): """ - Wraps StatsD calls, to give an identical interface to ThreadStats + Writes distribution metrics using StatsD protocol """ def __init__(self): @@ -33,21 +44,82 @@ def __init__(self): def distribution(self, metric_name, value, tags=[], timestamp=None): statsd.distribution(metric_name, value, tags=tags) - def flush(self, value): + def flush(self): + pass + + def stop(self): pass +class ThreadStatsWriter(StatsWriter): + """ + Writes distribution metrics using the ThreadStats class + """ + + def __init__(self, flush_in_thread): + self.thread_stats = ThreadStats(compress_payload=True) + self.thread_stats.start(flush_in_thread=flush_in_thread) + + def distribution(self, metric_name, value, tags=[], timestamp=None): + self.thread_stats.distribution( + metric_name, value, tags=tags, timestamp=timestamp + ) + + def flush(self): + """ "Flush distributions from ThreadStats to Datadog. + Modified based on `datadog.threadstats.base.ThreadStats.flush()`, + to gain better control over exception handling. + """ + _, dists = self.thread_stats._get_aggregate_metrics_and_dists(float("inf")) + count_dists = len(dists) + if not count_dists: + logger.debug("No distributions to flush. Continuing.") + + self.thread_stats.flush_count += 1 + logger.debug( + "Flush #%s sending %s distributions", + self.thread_stats.flush_count, + count_dists, + ) + try: + self.thread_stats.reporter.flush_distributions(dists) + except Exception as e: + # The nature of the root issue https://bugs.python.org/issue41345 is complex, + # but comprehensive tests suggest that it is safe to retry on this specific error. + if isinstance( + e, api.exceptions.ClientError + ) and "RemoteDisconnected" in str(e): + logger.debug( + "Retry flush #%s due to RemoteDisconnected", + self.thread_stats.flush_count, + ) + try: + self.thread_stats.reporter.flush_distributions(dists) + except Exception: + logger.debug( + "Flush #%s failed after retry", + self.thread_stats.flush_count, + exc_info=True, + ) + else: + logger.debug( + "Flush #%s failed", self.thread_stats.flush_count, exc_info=True + ) + + def stop(self): + self.thread_stats.stop() + + lambda_stats = None if should_use_extension: - lambda_stats = StatsDWrapper() + lambda_stats = StatsDWriter() else: # Periodical flushing in a background thread is NOT guaranteed to succeed # and leads to data loss. When disabled, metrics are only flushed at the # end of invocation. To make metrics submitted from a long-running Lambda # function available sooner, consider using the Datadog Lambda extension. flush_in_thread = os.environ.get("DD_FLUSH_IN_THREAD", "").lower() == "true" - lambda_stats = ThreadStats(compress_payload=True) - lambda_stats.start(flush_in_thread=flush_in_thread) + lambda_stats = ThreadStatsWriter(flush_in_thread) def lambda_metric(metric_name, value, timestamp=None, tags=None, force_async=False): @@ -74,8 +146,7 @@ def lambda_metric(metric_name, value, timestamp=None, tags=None, force_async=Fal def write_metric_point_to_stdout(metric_name, value, timestamp=None, tags=[]): - """Writes the specified metric point to standard output - """ + """Writes the specified metric point to standard output""" logger.debug( "Sending metric %s value %s to Datadog via log forwarder", metric_name, value ) @@ -91,40 +162,8 @@ def write_metric_point_to_stdout(metric_name, value, timestamp=None, tags=[]): ) -def flush_thread_stats(): - """"Flush distributions from ThreadStats to Datadog. - - Modified based on `datadog.threadstats.base.ThreadStats.flush()`, - to gain better control over exception handling. - """ - _, dists = lambda_stats._get_aggregate_metrics_and_dists(float("inf")) - count_dists = len(dists) - if not count_dists: - logger.debug("No distributions to flush. Continuing.") - - lambda_stats.flush_count += 1 - logger.debug( - "Flush #%s sending %s distributions", lambda_stats.flush_count, count_dists - ) - try: - lambda_stats.reporter.flush_distributions(dists) - except Exception as e: - # The nature of the root issue https://bugs.python.org/issue41345 is complex, - # but comprehensive tests suggest that it is safe to retry on this specific error. - if isinstance(e, api.exceptions.ClientError) and "RemoteDisconnected" in str(e): - logger.debug( - "Retry flush #%s due to RemoteDisconnected", lambda_stats.flush_count - ) - try: - lambda_stats.reporter.flush_distributions(dists) - except Exception: - logger.debug( - "Flush #%s failed after retry", - lambda_stats.flush_count, - exc_info=True, - ) - else: - logger.debug("Flush #%s failed", lambda_stats.flush_count, exc_info=True) +def flush_stats(): + lambda_stats.flush() def are_enhanced_metrics_enabled(): diff --git a/datadog_lambda/wrapper.py b/datadog_lambda/wrapper.py index 0a16fe0d..352b8f49 100644 --- a/datadog_lambda/wrapper.py +++ b/datadog_lambda/wrapper.py @@ -12,7 +12,7 @@ from datadog_lambda.cold_start import set_cold_start, is_cold_start from datadog_lambda.constants import XraySubsegment, TraceContextSource from datadog_lambda.metric import ( - flush_thread_stats, + flush_stats, submit_invocations_metric, submit_errors_metric, ) @@ -177,7 +177,7 @@ def _after(self, event, context): ) if not self.flush_to_log or should_use_extension: - flush_thread_stats() + flush_stats() if should_use_extension: flush_extension() diff --git a/scripts/run_integration_tests.sh b/scripts/run_integration_tests.sh index 630ab0aa..296b0b49 100755 --- a/scripts/run_integration_tests.sh +++ b/scripts/run_integration_tests.sh @@ -197,6 +197,7 @@ for handler_name in "${LAMBDA_HANDLERS[@]}"; do # Normalize package version so that these snapshots aren't broken on version bumps sed -E "s/(dd_lambda_layer:datadog-python[0-9]+_)[0-9]+\.[0-9]+\.[0-9]+/\1X\.X\.X/g" | sed -E "s/(datadog_lambda:v)([0-9]+\.[0-9]+\.[0-9])/\1XX/g" | + sed -E "s/(python )([0-9]\.[0-9]+\.[0-9]+)/\1XX/g" | # Strip out run ID (from function name, resource, etc.) sed -E "s/${!run_id}/XXXX/g" | # Strip out trace/span/parent/timestamps diff --git a/tests/integration/snapshots/logs/sync-metrics_python27.log b/tests/integration/snapshots/logs/sync-metrics_python27.log index ddb5fcee..2edc88bd 100644 --- a/tests/integration/snapshots/logs/sync-metrics_python27.log +++ b/tests/integration/snapshots/logs/sync-metrics_python27.log @@ -2,7 +2,7 @@ START RequestId: XXXX Version: $LATEST {"e": XXXX, "m": "aws.lambda.enhanced.invocations", "t": ["region:sa-east-1", "account_id:XXXX", "functionname:integration-tests-python-XXXX-sync-metrics_python27", "resource:integration-tests-python-XXXX-sync-metrics_python27", "cold_start:true", "memorysize:1024", "runtime:python2.7", "datadog_lambda:vXX", "dd_lambda_layer:datadog-python27_X.X.X"], "v": 1} HTTP GET https://httpstat.us/200/ Headers: ["Accept-Encoding:gzip, deflate", "Accept:*/*", "Connection:keep-alive", "User-Agent:python-requests/2.25.1", "x-datadog-parent-id:XXXX", "x-datadog-sampling-priority:1", "x-datadog-trace-id:XXXX"] Data: {} HTTP GET https://httpstat.us/400/ Headers: ["Accept-Encoding:gzip, deflate", "Accept:*/*", "Connection:keep-alive", "User-Agent:python-requests/2.25.1", "x-datadog-parent-id:XXXX", "x-datadog-sampling-priority:1", "x-datadog-trace-id:XXXX"] Data: {} -HTTP POST https://api.datadoghq.com/api/v1/distribution_points?api_key=XXXX Headers: ["Accept-Encoding:gzip, deflate", "Accept:*/*", "Connection:keep-alive", "Content-Encoding:deflate", "Content-Length:XXXX", "Content-Type:application/json", "User-Agent:datadogpy/0.41.0 (python 2.7.18; os linux; arch x86_64)", "x-datadog-parent-id:XXXX", "x-datadog-sampling-priority:1", "x-datadog-trace-id:XXXX"] Data: {"series": [{"tags": ["team:serverless", "role:hello", "dd_lambda_layer:datadog-python27_X.X.X"], "metric": "hello.dog", "interval": 10, "host": null, "points": [[XXXX, [1.0]]], "device": null, "type": "distribution"}, {"tags": ["test:integration", "role:hello", "dd_lambda_layer:datadog-python27_X.X.X"], "metric": "tests.integration.count", "interval": 10, "host": null, "points": [[XXXX, [21.0]]], "device": null, "type": "distribution"}]} +HTTP POST https://api.datadoghq.com/api/v1/distribution_points?api_key=XXXX Headers: ["Accept-Encoding:gzip, deflate", "Accept:*/*", "Connection:keep-alive", "Content-Encoding:deflate", "Content-Length:XXXX", "Content-Type:application/json", "User-Agent:datadogpy/0.41.0 (python XX; os linux; arch x86_64)", "x-datadog-parent-id:XXXX", "x-datadog-sampling-priority:1", "x-datadog-trace-id:XXXX"] Data: {"series": [{"tags": ["team:serverless", "role:hello", "dd_lambda_layer:datadog-python27_X.X.X"], "metric": "hello.dog", "interval": 10, "host": null, "points": [[XXXX, [1.0]]], "device": null, "type": "distribution"}, {"tags": ["test:integration", "role:hello", "dd_lambda_layer:datadog-python27_X.X.X"], "metric": "tests.integration.count", "interval": 10, "host": null, "points": [[XXXX, [21.0]]], "device": null, "type": "distribution"}]} {"traces": [[{"resource": "integration-tests-python-XXXX-sync-metrics_python27", "name": "aws.lambda", "service": "aws.lambda", "start": XXXX, "trace_id": "XXXX", "metrics": {"_sampling_priority_v1": 1, "system.pid": XXXX, "_dd.agent_psr": 1.0}, "parent_id": "XXXX", "meta": {"http.method": "GET", "runtime-id": "XXXX", "request_id": "XXXX", "function_trigger.event_source": "api-gateway", "cold_start": "true", "datadog_lambda": "X.X.X", "function_arn": "arn:aws:lambda:sa-east-1:601427279990:function:integration-tests-python-XXXX-sync-metrics_python27", "dd_trace": "X.X.X", "_dd.origin": "lambda", "http.status_code": "200", "resource_names": "integration-tests-python-XXXX-sync-metrics_python27", "function_trigger.event_source_arn": "arn:aws:apigateway:sa-east-1::/restapis/wt6mne2s9k/stages/test", "function_version": "$LATEST"}, "error": 0, "duration": XXXX, "type": "serverless", "span_id": "XXXX"}, {"resource": "requests.request", "name": "requests.request", "service": "aws.lambda", "start": XXXX, "trace_id": "XXXX", "metrics": {"_dd.measured": 1}, "parent_id": "XXXX", "meta": {"http.status_code": "200", "http.url": "https://httpstat.us/200/", "_dd.origin": "lambda", "http.method": "GET"}, "error": 0, "duration": XXXX, "type": "http", "span_id": "XXXX"}, {"resource": "requests.request", "name": "requests.request", "service": "aws.lambda", "start": XXXX, "trace_id": "XXXX", "metrics": {"_dd.measured": 1}, "parent_id": "XXXX", "meta": {"http.status_code": "400", "http.url": "https://httpstat.us/400/", "_dd.origin": "lambda", "http.method": "GET"}, "error": 0, "duration": XXXX, "type": "http", "span_id": "XXXX"}, {"resource": "requests.request", "name": "requests.request", "service": "aws.lambda", "start": XXXX, "trace_id": "XXXX", "metrics": {"_dd.measured": 1}, "parent_id": "XXXX", "meta": {"http.status_code": "202", "http.url": "https://api.datadoghq.com/api/v1/distribution_points", "_dd.origin": "lambda", "http.method": "POST"}, "error": 0, "duration": XXXX, "type": "http", "span_id": "XXXX"}]]} END RequestId: XXXX REPORT RequestId: XXXX Duration: XXXX ms Billed Duration: XXXX ms Memory Size: 1024 MB Max Memory Used: XXXX MB Init Duration: XXXX ms @@ -10,7 +10,7 @@ START RequestId: XXXX Version: $LATEST {"e": XXXX, "m": "aws.lambda.enhanced.invocations", "t": ["region:sa-east-1", "account_id:XXXX", "functionname:integration-tests-python-XXXX-sync-metrics_python27", "resource:integration-tests-python-XXXX-sync-metrics_python27", "cold_start:false", "memorysize:1024", "runtime:python2.7", "datadog_lambda:vXX", "dd_lambda_layer:datadog-python27_X.X.X"], "v": 1} HTTP GET https://httpstat.us/200/ Headers: ["Accept-Encoding:gzip, deflate", "Accept:*/*", "Connection:keep-alive", "User-Agent:python-requests/2.25.1", "x-datadog-parent-id:XXXX", "x-datadog-sampling-priority:1", "x-datadog-trace-id:XXXX"] Data: {} HTTP GET https://httpstat.us/400/ Headers: ["Accept-Encoding:gzip, deflate", "Accept:*/*", "Connection:keep-alive", "User-Agent:python-requests/2.25.1", "x-datadog-parent-id:XXXX", "x-datadog-sampling-priority:1", "x-datadog-trace-id:XXXX"] Data: {} -HTTP POST https://api.datadoghq.com/api/v1/distribution_points?api_key=XXXX Headers: ["Accept-Encoding:gzip, deflate", "Accept:*/*", "Connection:keep-alive", "Content-Encoding:deflate", "Content-Length:XXXX", "Content-Type:application/json", "User-Agent:datadogpy/0.41.0 (python 2.7.18; os linux; arch x86_64)", "x-datadog-parent-id:XXXX", "x-datadog-sampling-priority:1", "x-datadog-trace-id:XXXX"] Data: {"series": [{"tags": ["team:serverless", "role:hello", "dd_lambda_layer:datadog-python27_X.X.X"], "metric": "hello.dog", "interval": 10, "host": null, "points": [[XXXX, [1.0]]], "device": null, "type": "distribution"}, {"tags": ["test:integration", "role:hello", "dd_lambda_layer:datadog-python27_X.X.X"], "metric": "tests.integration.count", "interval": 10, "host": null, "points": [[XXXX, [21.0]]], "device": null, "type": "distribution"}]} +HTTP POST https://api.datadoghq.com/api/v1/distribution_points?api_key=XXXX Headers: ["Accept-Encoding:gzip, deflate", "Accept:*/*", "Connection:keep-alive", "Content-Encoding:deflate", "Content-Length:XXXX", "Content-Type:application/json", "User-Agent:datadogpy/0.41.0 (python XX; os linux; arch x86_64)", "x-datadog-parent-id:XXXX", "x-datadog-sampling-priority:1", "x-datadog-trace-id:XXXX"] Data: {"series": [{"tags": ["team:serverless", "role:hello", "dd_lambda_layer:datadog-python27_X.X.X"], "metric": "hello.dog", "interval": 10, "host": null, "points": [[XXXX, [1.0]]], "device": null, "type": "distribution"}, {"tags": ["test:integration", "role:hello", "dd_lambda_layer:datadog-python27_X.X.X"], "metric": "tests.integration.count", "interval": 10, "host": null, "points": [[XXXX, [21.0]]], "device": null, "type": "distribution"}]} {"traces": [[{"resource": "integration-tests-python-XXXX-sync-metrics_python27", "name": "aws.lambda", "service": "aws.lambda", "start": XXXX, "trace_id": "XXXX", "metrics": {"_sampling_priority_v1": 1, "system.pid": XXXX, "_dd.agent_psr": 1.0}, "parent_id": "XXXX", "meta": {"runtime-id": "XXXX", "request_id": "XXXX", "function_trigger.event_source": "sns", "cold_start": "false", "datadog_lambda": "X.X.X", "function_arn": "arn:aws:lambda:sa-east-1:601427279990:function:integration-tests-python-XXXX-sync-metrics_python27", "dd_trace": "X.X.X", "_dd.origin": "lambda", "resource_names": "integration-tests-python-XXXX-sync-metrics_python27", "function_trigger.event_source_arn": "arn:aws:sns:us-east-2:123456789012:sns-lambda", "function_version": "$LATEST"}, "error": 0, "duration": XXXX, "type": "serverless", "span_id": "XXXX"}, {"resource": "requests.request", "name": "requests.request", "service": "aws.lambda", "start": XXXX, "trace_id": "XXXX", "metrics": {"_dd.measured": 1}, "parent_id": "XXXX", "meta": {"http.status_code": "200", "http.url": "https://httpstat.us/200/", "_dd.origin": "lambda", "http.method": "GET"}, "error": 0, "duration": XXXX, "type": "http", "span_id": "XXXX"}, {"resource": "requests.request", "name": "requests.request", "service": "aws.lambda", "start": XXXX, "trace_id": "XXXX", "metrics": {"_dd.measured": 1}, "parent_id": "XXXX", "meta": {"http.status_code": "400", "http.url": "https://httpstat.us/400/", "_dd.origin": "lambda", "http.method": "GET"}, "error": 0, "duration": XXXX, "type": "http", "span_id": "XXXX"}, {"resource": "requests.request", "name": "requests.request", "service": "aws.lambda", "start": XXXX, "trace_id": "XXXX", "metrics": {"_dd.measured": 1}, "parent_id": "XXXX", "meta": {"http.status_code": "202", "http.url": "https://api.datadoghq.com/api/v1/distribution_points", "_dd.origin": "lambda", "http.method": "POST"}, "error": 0, "duration": XXXX, "type": "http", "span_id": "XXXX"}]]} END RequestId: XXXX REPORT RequestId: XXXX Duration: XXXX ms Billed Duration: XXXX ms Memory Size: 1024 MB Max Memory Used: XXXX MB @@ -18,7 +18,7 @@ START RequestId: XXXX Version: $LATEST {"e": XXXX, "m": "aws.lambda.enhanced.invocations", "t": ["region:sa-east-1", "account_id:XXXX", "functionname:integration-tests-python-XXXX-sync-metrics_python27", "resource:integration-tests-python-XXXX-sync-metrics_python27", "cold_start:false", "memorysize:1024", "runtime:python2.7", "datadog_lambda:vXX", "dd_lambda_layer:datadog-python27_X.X.X"], "v": 1} HTTP GET https://httpstat.us/200/ Headers: ["Accept-Encoding:gzip, deflate", "Accept:*/*", "Connection:keep-alive", "User-Agent:python-requests/2.25.1", "x-datadog-parent-id:XXXX", "x-datadog-sampling-priority:1", "x-datadog-trace-id:XXXX"] Data: {} HTTP GET https://httpstat.us/400/ Headers: ["Accept-Encoding:gzip, deflate", "Accept:*/*", "Connection:keep-alive", "User-Agent:python-requests/2.25.1", "x-datadog-parent-id:XXXX", "x-datadog-sampling-priority:1", "x-datadog-trace-id:XXXX"] Data: {} -HTTP POST https://api.datadoghq.com/api/v1/distribution_points?api_key=XXXX Headers: ["Accept-Encoding:gzip, deflate", "Accept:*/*", "Connection:keep-alive", "Content-Encoding:deflate", "Content-Length:XXXX", "Content-Type:application/json", "User-Agent:datadogpy/0.41.0 (python 2.7.18; os linux; arch x86_64)", "x-datadog-parent-id:XXXX", "x-datadog-sampling-priority:1", "x-datadog-trace-id:XXXX"] Data: {"series": [{"tags": ["team:serverless", "role:hello", "dd_lambda_layer:datadog-python27_X.X.X"], "metric": "hello.dog", "interval": 10, "host": null, "points": [[XXXX, [1.0]]], "device": null, "type": "distribution"}, {"tags": ["test:integration", "role:hello", "dd_lambda_layer:datadog-python27_X.X.X"], "metric": "tests.integration.count", "interval": 10, "host": null, "points": [[XXXX, [21.0]]], "device": null, "type": "distribution"}]} +HTTP POST https://api.datadoghq.com/api/v1/distribution_points?api_key=XXXX Headers: ["Accept-Encoding:gzip, deflate", "Accept:*/*", "Connection:keep-alive", "Content-Encoding:deflate", "Content-Length:XXXX", "Content-Type:application/json", "User-Agent:datadogpy/0.41.0 (python XX; os linux; arch x86_64)", "x-datadog-parent-id:XXXX", "x-datadog-sampling-priority:1", "x-datadog-trace-id:XXXX"] Data: {"series": [{"tags": ["team:serverless", "role:hello", "dd_lambda_layer:datadog-python27_X.X.X"], "metric": "hello.dog", "interval": 10, "host": null, "points": [[XXXX, [1.0]]], "device": null, "type": "distribution"}, {"tags": ["test:integration", "role:hello", "dd_lambda_layer:datadog-python27_X.X.X"], "metric": "tests.integration.count", "interval": 10, "host": null, "points": [[XXXX, [21.0]]], "device": null, "type": "distribution"}]} {"traces": [[{"resource": "integration-tests-python-XXXX-sync-metrics_python27", "name": "aws.lambda", "service": "aws.lambda", "start": XXXX, "trace_id": "XXXX", "metrics": {"_sampling_priority_v1": 1}, "parent_id": "XXXX", "meta": {"function_arn": "arn:aws:lambda:sa-east-1:601427279990:function:integration-tests-python-XXXX-sync-metrics_python27", "request_id": "XXXX", "function_trigger.event_source": "sqs", "cold_start": "false", "datadog_lambda": "X.X.X", "dd_trace": "X.X.X", "_dd.origin": "lambda", "resource_names": "integration-tests-python-XXXX-sync-metrics_python27", "function_trigger.event_source_arn": "arn:aws:sqs:us-east-2:123456789012:my-queue", "function_version": "$LATEST"}, "error": 0, "duration": XXXX, "type": "serverless", "span_id": "XXXX"}, {"resource": "requests.request", "name": "requests.request", "service": "aws.lambda", "start": XXXX, "trace_id": "XXXX", "metrics": {"_dd.measured": 1}, "parent_id": "XXXX", "meta": {"http.status_code": "200", "http.url": "https://httpstat.us/200/", "_dd.origin": "lambda", "http.method": "GET"}, "error": 0, "duration": XXXX, "type": "http", "span_id": "XXXX"}, {"resource": "requests.request", "name": "requests.request", "service": "aws.lambda", "start": XXXX, "trace_id": "XXXX", "metrics": {"_dd.measured": 1}, "parent_id": "XXXX", "meta": {"http.status_code": "400", "http.url": "https://httpstat.us/400/", "_dd.origin": "lambda", "http.method": "GET"}, "error": 0, "duration": XXXX, "type": "http", "span_id": "XXXX"}, {"resource": "requests.request", "name": "requests.request", "service": "aws.lambda", "start": XXXX, "trace_id": "XXXX", "metrics": {"_dd.measured": 1}, "parent_id": "XXXX", "meta": {"http.status_code": "202", "http.url": "https://api.datadoghq.com/api/v1/distribution_points", "_dd.origin": "lambda", "http.method": "POST"}, "error": 0, "duration": XXXX, "type": "http", "span_id": "XXXX"}]]} END RequestId: XXXX REPORT RequestId: XXXX Duration: XXXX ms Billed Duration: XXXX ms Memory Size: 1024 MB Max Memory Used: XXXX MB diff --git a/tests/integration/snapshots/logs/sync-metrics_python36.log b/tests/integration/snapshots/logs/sync-metrics_python36.log index 29e7cc4b..eec2ce41 100644 --- a/tests/integration/snapshots/logs/sync-metrics_python36.log +++ b/tests/integration/snapshots/logs/sync-metrics_python36.log @@ -2,7 +2,7 @@ START RequestId: XXXX Version: $LATEST {"m": "aws.lambda.enhanced.invocations", "v": 1, "e": XXXX, "t": ["region:sa-east-1", "account_id:XXXX", "functionname:integration-tests-python-XXXX-sync-metrics_python36", "resource:integration-tests-python-XXXX-sync-metrics_python36", "cold_start:true", "memorysize:1024", "runtime:python3.6", "datadog_lambda:vXX", "dd_lambda_layer:datadog-python36_X.X.X"]} HTTP GET https://httpstat.us/200/ Headers: ["Accept-Encoding:gzip, deflate", "Accept:*/*", "Connection:keep-alive", "User-Agent:python-requests/2.25.1", "x-datadog-parent-id:XXXX", "x-datadog-sampling-priority:1", "x-datadog-trace-id:XXXX"] Data: {} HTTP GET https://httpstat.us/400/ Headers: ["Accept-Encoding:gzip, deflate", "Accept:*/*", "Connection:keep-alive", "User-Agent:python-requests/2.25.1", "x-datadog-parent-id:XXXX", "x-datadog-sampling-priority:1", "x-datadog-trace-id:XXXX"] Data: {} -HTTP POST https://api.datadoghq.com/api/v1/distribution_points?api_key=XXXX Headers: ["Accept-Encoding:gzip, deflate", "Accept:*/*", "Connection:keep-alive", "Content-Encoding:deflate", "Content-Length:XXXX", "Content-Type:application/json", "User-Agent:datadogpy/0.41.0 (python 3.6.13; os linux; arch x86_64)", "x-datadog-parent-id:XXXX", "x-datadog-sampling-priority:1", "x-datadog-trace-id:XXXX"] Data: {"series": [{"metric": "hello.dog", "points": [[XXXX, [1.0]]], "type": "distribution", "host": null, "device": null, "tags": ["team:serverless", "role:hello", "dd_lambda_layer:datadog-python36_X.X.X"], "interval": 10}, {"metric": "tests.integration.count", "points": [[XXXX, [21.0]]], "type": "distribution", "host": null, "device": null, "tags": ["test:integration", "role:hello", "dd_lambda_layer:datadog-python36_X.X.X"], "interval": 10}]} +HTTP POST https://api.datadoghq.com/api/v1/distribution_points?api_key=XXXX Headers: ["Accept-Encoding:gzip, deflate", "Accept:*/*", "Connection:keep-alive", "Content-Encoding:deflate", "Content-Length:XXXX", "Content-Type:application/json", "User-Agent:datadogpy/0.41.0 (python XX; os linux; arch x86_64)", "x-datadog-parent-id:XXXX", "x-datadog-sampling-priority:1", "x-datadog-trace-id:XXXX"] Data: {"series": [{"metric": "hello.dog", "points": [[XXXX, [1.0]]], "type": "distribution", "host": null, "device": null, "tags": ["team:serverless", "role:hello", "dd_lambda_layer:datadog-python36_X.X.X"], "interval": 10}, {"metric": "tests.integration.count", "points": [[XXXX, [21.0]]], "type": "distribution", "host": null, "device": null, "tags": ["test:integration", "role:hello", "dd_lambda_layer:datadog-python36_X.X.X"], "interval": 10}]} {"traces": [[{"trace_id": "XXXX", "parent_id": "XXXX", "span_id": "XXXX", "service": "aws.lambda", "resource": "integration-tests-python-XXXX-sync-metrics_python36", "name": "aws.lambda", "error": 0, "start": XXXX, "duration": XXXX, "meta": {"runtime-id": "XXXX", "_dd.origin": "lambda", "cold_start": "true", "function_arn": "arn:aws:lambda:sa-east-1:601427279990:function:integration-tests-python-XXXX-sync-metrics_python36", "function_version": "$LATEST", "request_id": "XXXX", "resource_names": "integration-tests-python-XXXX-sync-metrics_python36", "datadog_lambda": "X.X.X", "dd_trace": "X.X.X", "function_trigger.event_source": "api-gateway", "function_trigger.event_source_arn": "arn:aws:apigateway:sa-east-1::/restapis/wt6mne2s9k/stages/test", "http.method": "GET", "http.status_code": "200"}, "metrics": {"system.pid": XXXX, "_dd.agent_psr": 1.0, "_sampling_priority_v1": 1}, "type": "serverless"}, {"trace_id": "XXXX", "parent_id": "XXXX", "span_id": "XXXX", "service": "aws.lambda", "resource": "requests.request", "name": "requests.request", "error": 0, "start": XXXX, "duration": XXXX, "meta": {"_dd.origin": "lambda", "http.method": "GET", "http.url": "https://httpstat.us/200/", "http.status_code": "200"}, "metrics": {"_dd.measured": 1}, "type": "http"}, {"trace_id": "XXXX", "parent_id": "XXXX", "span_id": "XXXX", "service": "aws.lambda", "resource": "requests.request", "name": "requests.request", "error": 0, "start": XXXX, "duration": XXXX, "meta": {"_dd.origin": "lambda", "http.method": "GET", "http.url": "https://httpstat.us/400/", "http.status_code": "400"}, "metrics": {"_dd.measured": 1}, "type": "http"}, {"trace_id": "XXXX", "parent_id": "XXXX", "span_id": "XXXX", "service": "aws.lambda", "resource": "requests.request", "name": "requests.request", "error": 0, "start": XXXX, "duration": XXXX, "meta": {"_dd.origin": "lambda", "http.method": "POST", "http.url": "https://api.datadoghq.com/api/v1/distribution_points", "http.status_code": "202"}, "metrics": {"_dd.measured": 1}, "type": "http"}]]} END RequestId: XXXX REPORT RequestId: XXXX Duration: XXXX ms Billed Duration: XXXX ms Memory Size: 1024 MB Max Memory Used: XXXX MB Init Duration: XXXX ms @@ -10,7 +10,7 @@ START RequestId: XXXX Version: $LATEST {"m": "aws.lambda.enhanced.invocations", "v": 1, "e": XXXX, "t": ["region:sa-east-1", "account_id:XXXX", "functionname:integration-tests-python-XXXX-sync-metrics_python36", "resource:integration-tests-python-XXXX-sync-metrics_python36", "cold_start:false", "memorysize:1024", "runtime:python3.6", "datadog_lambda:vXX", "dd_lambda_layer:datadog-python36_X.X.X"]} HTTP GET https://httpstat.us/200/ Headers: ["Accept-Encoding:gzip, deflate", "Accept:*/*", "Connection:keep-alive", "User-Agent:python-requests/2.25.1", "x-datadog-parent-id:XXXX", "x-datadog-sampling-priority:1", "x-datadog-trace-id:XXXX"] Data: {} HTTP GET https://httpstat.us/400/ Headers: ["Accept-Encoding:gzip, deflate", "Accept:*/*", "Connection:keep-alive", "User-Agent:python-requests/2.25.1", "x-datadog-parent-id:XXXX", "x-datadog-sampling-priority:1", "x-datadog-trace-id:XXXX"] Data: {} -HTTP POST https://api.datadoghq.com/api/v1/distribution_points?api_key=XXXX Headers: ["Accept-Encoding:gzip, deflate", "Accept:*/*", "Connection:keep-alive", "Content-Encoding:deflate", "Content-Length:XXXX", "Content-Type:application/json", "User-Agent:datadogpy/0.41.0 (python 3.6.13; os linux; arch x86_64)", "x-datadog-parent-id:XXXX", "x-datadog-sampling-priority:1", "x-datadog-trace-id:XXXX"] Data: {"series": [{"metric": "hello.dog", "points": [[XXXX, [1.0]]], "type": "distribution", "host": null, "device": null, "tags": ["team:serverless", "role:hello", "dd_lambda_layer:datadog-python36_X.X.X"], "interval": 10}, {"metric": "tests.integration.count", "points": [[XXXX, [21.0]]], "type": "distribution", "host": null, "device": null, "tags": ["test:integration", "role:hello", "dd_lambda_layer:datadog-python36_X.X.X"], "interval": 10}]} +HTTP POST https://api.datadoghq.com/api/v1/distribution_points?api_key=XXXX Headers: ["Accept-Encoding:gzip, deflate", "Accept:*/*", "Connection:keep-alive", "Content-Encoding:deflate", "Content-Length:XXXX", "Content-Type:application/json", "User-Agent:datadogpy/0.41.0 (python XX; os linux; arch x86_64)", "x-datadog-parent-id:XXXX", "x-datadog-sampling-priority:1", "x-datadog-trace-id:XXXX"] Data: {"series": [{"metric": "hello.dog", "points": [[XXXX, [1.0]]], "type": "distribution", "host": null, "device": null, "tags": ["team:serverless", "role:hello", "dd_lambda_layer:datadog-python36_X.X.X"], "interval": 10}, {"metric": "tests.integration.count", "points": [[XXXX, [21.0]]], "type": "distribution", "host": null, "device": null, "tags": ["test:integration", "role:hello", "dd_lambda_layer:datadog-python36_X.X.X"], "interval": 10}]} {"traces": [[{"trace_id": "XXXX", "parent_id": "XXXX", "span_id": "XXXX", "service": "aws.lambda", "resource": "integration-tests-python-XXXX-sync-metrics_python36", "name": "aws.lambda", "error": 0, "start": XXXX, "duration": XXXX, "meta": {"runtime-id": "XXXX", "_dd.origin": "lambda", "cold_start": "false", "function_arn": "arn:aws:lambda:sa-east-1:601427279990:function:integration-tests-python-XXXX-sync-metrics_python36", "function_version": "$LATEST", "request_id": "XXXX", "resource_names": "integration-tests-python-XXXX-sync-metrics_python36", "datadog_lambda": "X.X.X", "dd_trace": "X.X.X", "function_trigger.event_source": "sns", "function_trigger.event_source_arn": "arn:aws:sns:us-east-2:123456789012:sns-lambda"}, "metrics": {"system.pid": XXXX, "_dd.agent_psr": 1.0, "_sampling_priority_v1": 1}, "type": "serverless"}, {"trace_id": "XXXX", "parent_id": "XXXX", "span_id": "XXXX", "service": "aws.lambda", "resource": "requests.request", "name": "requests.request", "error": 0, "start": XXXX, "duration": XXXX, "meta": {"_dd.origin": "lambda", "http.method": "GET", "http.url": "https://httpstat.us/200/", "http.status_code": "200"}, "metrics": {"_dd.measured": 1}, "type": "http"}, {"trace_id": "XXXX", "parent_id": "XXXX", "span_id": "XXXX", "service": "aws.lambda", "resource": "requests.request", "name": "requests.request", "error": 0, "start": XXXX, "duration": XXXX, "meta": {"_dd.origin": "lambda", "http.method": "GET", "http.url": "https://httpstat.us/400/", "http.status_code": "400"}, "metrics": {"_dd.measured": 1}, "type": "http"}, {"trace_id": "XXXX", "parent_id": "XXXX", "span_id": "XXXX", "service": "aws.lambda", "resource": "requests.request", "name": "requests.request", "error": 0, "start": XXXX, "duration": XXXX, "meta": {"_dd.origin": "lambda", "http.method": "POST", "http.url": "https://api.datadoghq.com/api/v1/distribution_points", "http.status_code": "202"}, "metrics": {"_dd.measured": 1}, "type": "http"}]]} END RequestId: XXXX REPORT RequestId: XXXX Duration: XXXX ms Billed Duration: XXXX ms Memory Size: 1024 MB Max Memory Used: XXXX MB @@ -18,7 +18,7 @@ START RequestId: XXXX Version: $LATEST {"m": "aws.lambda.enhanced.invocations", "v": 1, "e": XXXX, "t": ["region:sa-east-1", "account_id:XXXX", "functionname:integration-tests-python-XXXX-sync-metrics_python36", "resource:integration-tests-python-XXXX-sync-metrics_python36", "cold_start:false", "memorysize:1024", "runtime:python3.6", "datadog_lambda:vXX", "dd_lambda_layer:datadog-python36_X.X.X"]} HTTP GET https://httpstat.us/200/ Headers: ["Accept-Encoding:gzip, deflate", "Accept:*/*", "Connection:keep-alive", "User-Agent:python-requests/2.25.1", "x-datadog-parent-id:XXXX", "x-datadog-sampling-priority:1", "x-datadog-trace-id:XXXX"] Data: {} HTTP GET https://httpstat.us/400/ Headers: ["Accept-Encoding:gzip, deflate", "Accept:*/*", "Connection:keep-alive", "User-Agent:python-requests/2.25.1", "x-datadog-parent-id:XXXX", "x-datadog-sampling-priority:1", "x-datadog-trace-id:XXXX"] Data: {} -HTTP POST https://api.datadoghq.com/api/v1/distribution_points?api_key=XXXX Headers: ["Accept-Encoding:gzip, deflate", "Accept:*/*", "Connection:keep-alive", "Content-Encoding:deflate", "Content-Length:XXXX", "Content-Type:application/json", "User-Agent:datadogpy/0.41.0 (python 3.6.13; os linux; arch x86_64)", "x-datadog-parent-id:XXXX", "x-datadog-sampling-priority:1", "x-datadog-trace-id:XXXX"] Data: {"series": [{"metric": "hello.dog", "points": [[XXXX, [1.0]]], "type": "distribution", "host": null, "device": null, "tags": ["team:serverless", "role:hello", "dd_lambda_layer:datadog-python36_X.X.X"], "interval": 10}, {"metric": "tests.integration.count", "points": [[XXXX, [21.0]]], "type": "distribution", "host": null, "device": null, "tags": ["test:integration", "role:hello", "dd_lambda_layer:datadog-python36_X.X.X"], "interval": 10}]} +HTTP POST https://api.datadoghq.com/api/v1/distribution_points?api_key=XXXX Headers: ["Accept-Encoding:gzip, deflate", "Accept:*/*", "Connection:keep-alive", "Content-Encoding:deflate", "Content-Length:XXXX", "Content-Type:application/json", "User-Agent:datadogpy/0.41.0 (python XX; os linux; arch x86_64)", "x-datadog-parent-id:XXXX", "x-datadog-sampling-priority:1", "x-datadog-trace-id:XXXX"] Data: {"series": [{"metric": "hello.dog", "points": [[XXXX, [1.0]]], "type": "distribution", "host": null, "device": null, "tags": ["team:serverless", "role:hello", "dd_lambda_layer:datadog-python36_X.X.X"], "interval": 10}, {"metric": "tests.integration.count", "points": [[XXXX, [21.0]]], "type": "distribution", "host": null, "device": null, "tags": ["test:integration", "role:hello", "dd_lambda_layer:datadog-python36_X.X.X"], "interval": 10}]} {"traces": [[{"trace_id": "XXXX", "parent_id": "XXXX", "span_id": "XXXX", "service": "aws.lambda", "resource": "integration-tests-python-XXXX-sync-metrics_python36", "name": "aws.lambda", "error": 0, "start": XXXX, "duration": XXXX, "meta": {"_dd.origin": "lambda", "cold_start": "false", "function_arn": "arn:aws:lambda:sa-east-1:601427279990:function:integration-tests-python-XXXX-sync-metrics_python36", "function_version": "$LATEST", "request_id": "XXXX", "resource_names": "integration-tests-python-XXXX-sync-metrics_python36", "datadog_lambda": "X.X.X", "dd_trace": "X.X.X", "function_trigger.event_source": "sqs", "function_trigger.event_source_arn": "arn:aws:sqs:us-east-2:123456789012:my-queue"}, "metrics": {"_sampling_priority_v1": 1}, "type": "serverless"}, {"trace_id": "XXXX", "parent_id": "XXXX", "span_id": "XXXX", "service": "aws.lambda", "resource": "requests.request", "name": "requests.request", "error": 0, "start": XXXX, "duration": XXXX, "meta": {"_dd.origin": "lambda", "http.method": "GET", "http.url": "https://httpstat.us/200/", "http.status_code": "200"}, "metrics": {"_dd.measured": 1}, "type": "http"}, {"trace_id": "XXXX", "parent_id": "XXXX", "span_id": "XXXX", "service": "aws.lambda", "resource": "requests.request", "name": "requests.request", "error": 0, "start": XXXX, "duration": XXXX, "meta": {"_dd.origin": "lambda", "http.method": "GET", "http.url": "https://httpstat.us/400/", "http.status_code": "400"}, "metrics": {"_dd.measured": 1}, "type": "http"}, {"trace_id": "XXXX", "parent_id": "XXXX", "span_id": "XXXX", "service": "aws.lambda", "resource": "requests.request", "name": "requests.request", "error": 0, "start": XXXX, "duration": XXXX, "meta": {"_dd.origin": "lambda", "http.method": "POST", "http.url": "https://api.datadoghq.com/api/v1/distribution_points", "http.status_code": "202"}, "metrics": {"_dd.measured": 1}, "type": "http"}]]} END RequestId: XXXX REPORT RequestId: XXXX Duration: XXXX ms Billed Duration: XXXX ms Memory Size: 1024 MB Max Memory Used: XXXX MB diff --git a/tests/integration/snapshots/logs/sync-metrics_python37.log b/tests/integration/snapshots/logs/sync-metrics_python37.log index 591c1d7d..98046d2b 100644 --- a/tests/integration/snapshots/logs/sync-metrics_python37.log +++ b/tests/integration/snapshots/logs/sync-metrics_python37.log @@ -2,7 +2,7 @@ START RequestId: XXXX Version: $LATEST {"m": "aws.lambda.enhanced.invocations", "v": 1, "e": XXXX, "t": ["region:sa-east-1", "account_id:XXXX", "functionname:integration-tests-python-XXXX-sync-metrics_python37", "resource:integration-tests-python-XXXX-sync-metrics_python37", "cold_start:true", "memorysize:1024", "runtime:python3.7", "datadog_lambda:vXX", "dd_lambda_layer:datadog-python37_X.X.X"]} HTTP GET https://httpstat.us/200/ Headers: ["Accept-Encoding:gzip, deflate", "Accept:*/*", "Connection:keep-alive", "User-Agent:python-requests/2.25.1", "x-datadog-parent-id:XXXX", "x-datadog-sampling-priority:1", "x-datadog-trace-id:XXXX"] Data: {} HTTP GET https://httpstat.us/400/ Headers: ["Accept-Encoding:gzip, deflate", "Accept:*/*", "Connection:keep-alive", "User-Agent:python-requests/2.25.1", "x-datadog-parent-id:XXXX", "x-datadog-sampling-priority:1", "x-datadog-trace-id:XXXX"] Data: {} -HTTP POST https://api.datadoghq.com/api/v1/distribution_points?api_key=XXXX Headers: ["Accept-Encoding:gzip, deflate", "Accept:*/*", "Connection:keep-alive", "Content-Encoding:deflate", "Content-Length:XXXX", "Content-Type:application/json", "User-Agent:datadogpy/0.41.0 (python 3.7.10; os linux; arch x86_64)", "x-datadog-parent-id:XXXX", "x-datadog-sampling-priority:1", "x-datadog-trace-id:XXXX"] Data: {"series": [{"metric": "hello.dog", "points": [[XXXX, [1.0]]], "type": "distribution", "host": null, "device": null, "tags": ["team:serverless", "role:hello", "dd_lambda_layer:datadog-python37_X.X.X"], "interval": 10}, {"metric": "tests.integration.count", "points": [[XXXX, [21.0]]], "type": "distribution", "host": null, "device": null, "tags": ["test:integration", "role:hello", "dd_lambda_layer:datadog-python37_X.X.X"], "interval": 10}]} +HTTP POST https://api.datadoghq.com/api/v1/distribution_points?api_key=XXXX Headers: ["Accept-Encoding:gzip, deflate", "Accept:*/*", "Connection:keep-alive", "Content-Encoding:deflate", "Content-Length:XXXX", "Content-Type:application/json", "User-Agent:datadogpy/0.41.0 (python XX; os linux; arch x86_64)", "x-datadog-parent-id:XXXX", "x-datadog-sampling-priority:1", "x-datadog-trace-id:XXXX"] Data: {"series": [{"metric": "hello.dog", "points": [[XXXX, [1.0]]], "type": "distribution", "host": null, "device": null, "tags": ["team:serverless", "role:hello", "dd_lambda_layer:datadog-python37_X.X.X"], "interval": 10}, {"metric": "tests.integration.count", "points": [[XXXX, [21.0]]], "type": "distribution", "host": null, "device": null, "tags": ["test:integration", "role:hello", "dd_lambda_layer:datadog-python37_X.X.X"], "interval": 10}]} {"traces": [[{"trace_id": "XXXX", "parent_id": "XXXX", "span_id": "XXXX", "service": "aws.lambda", "resource": "integration-tests-python-XXXX-sync-metrics_python37", "name": "aws.lambda", "error": 0, "start": XXXX, "duration": XXXX, "meta": {"runtime-id": "XXXX", "_dd.origin": "lambda", "cold_start": "true", "function_arn": "arn:aws:lambda:sa-east-1:601427279990:function:integration-tests-python-XXXX-sync-metrics_python37", "function_version": "$LATEST", "request_id": "XXXX", "resource_names": "integration-tests-python-XXXX-sync-metrics_python37", "datadog_lambda": "X.X.X", "dd_trace": "X.X.X", "function_trigger.event_source": "api-gateway", "function_trigger.event_source_arn": "arn:aws:apigateway:sa-east-1::/restapis/wt6mne2s9k/stages/test", "http.method": "GET", "http.status_code": "200"}, "metrics": {"system.pid": XXXX, "_dd.agent_psr": 1.0, "_sampling_priority_v1": 1}, "type": "serverless"}, {"trace_id": "XXXX", "parent_id": "XXXX", "span_id": "XXXX", "service": "aws.lambda", "resource": "requests.request", "name": "requests.request", "error": 0, "start": XXXX, "duration": XXXX, "meta": {"_dd.origin": "lambda", "http.method": "GET", "http.url": "https://httpstat.us/200/", "http.status_code": "200"}, "metrics": {"_dd.measured": 1}, "type": "http"}, {"trace_id": "XXXX", "parent_id": "XXXX", "span_id": "XXXX", "service": "aws.lambda", "resource": "requests.request", "name": "requests.request", "error": 0, "start": XXXX, "duration": XXXX, "meta": {"_dd.origin": "lambda", "http.method": "GET", "http.url": "https://httpstat.us/400/", "http.status_code": "400"}, "metrics": {"_dd.measured": 1}, "type": "http"}, {"trace_id": "XXXX", "parent_id": "XXXX", "span_id": "XXXX", "service": "aws.lambda", "resource": "requests.request", "name": "requests.request", "error": 0, "start": XXXX, "duration": XXXX, "meta": {"_dd.origin": "lambda", "http.method": "POST", "http.url": "https://api.datadoghq.com/api/v1/distribution_points", "http.status_code": "202"}, "metrics": {"_dd.measured": 1}, "type": "http"}]]} END RequestId: XXXX REPORT RequestId: XXXX Duration: XXXX ms Billed Duration: XXXX ms Memory Size: 1024 MB Max Memory Used: XXXX MB Init Duration: XXXX ms @@ -10,7 +10,7 @@ START RequestId: XXXX Version: $LATEST {"m": "aws.lambda.enhanced.invocations", "v": 1, "e": XXXX, "t": ["region:sa-east-1", "account_id:XXXX", "functionname:integration-tests-python-XXXX-sync-metrics_python37", "resource:integration-tests-python-XXXX-sync-metrics_python37", "cold_start:false", "memorysize:1024", "runtime:python3.7", "datadog_lambda:vXX", "dd_lambda_layer:datadog-python37_X.X.X"]} HTTP GET https://httpstat.us/200/ Headers: ["Accept-Encoding:gzip, deflate", "Accept:*/*", "Connection:keep-alive", "User-Agent:python-requests/2.25.1", "x-datadog-parent-id:XXXX", "x-datadog-sampling-priority:1", "x-datadog-trace-id:XXXX"] Data: {} HTTP GET https://httpstat.us/400/ Headers: ["Accept-Encoding:gzip, deflate", "Accept:*/*", "Connection:keep-alive", "User-Agent:python-requests/2.25.1", "x-datadog-parent-id:XXXX", "x-datadog-sampling-priority:1", "x-datadog-trace-id:XXXX"] Data: {} -HTTP POST https://api.datadoghq.com/api/v1/distribution_points?api_key=XXXX Headers: ["Accept-Encoding:gzip, deflate", "Accept:*/*", "Connection:keep-alive", "Content-Encoding:deflate", "Content-Length:XXXX", "Content-Type:application/json", "User-Agent:datadogpy/0.41.0 (python 3.7.10; os linux; arch x86_64)", "x-datadog-parent-id:XXXX", "x-datadog-sampling-priority:1", "x-datadog-trace-id:XXXX"] Data: {"series": [{"metric": "hello.dog", "points": [[XXXX, [1.0]]], "type": "distribution", "host": null, "device": null, "tags": ["team:serverless", "role:hello", "dd_lambda_layer:datadog-python37_X.X.X"], "interval": 10}, {"metric": "tests.integration.count", "points": [[XXXX, [21.0]]], "type": "distribution", "host": null, "device": null, "tags": ["test:integration", "role:hello", "dd_lambda_layer:datadog-python37_X.X.X"], "interval": 10}]} +HTTP POST https://api.datadoghq.com/api/v1/distribution_points?api_key=XXXX Headers: ["Accept-Encoding:gzip, deflate", "Accept:*/*", "Connection:keep-alive", "Content-Encoding:deflate", "Content-Length:XXXX", "Content-Type:application/json", "User-Agent:datadogpy/0.41.0 (python XX; os linux; arch x86_64)", "x-datadog-parent-id:XXXX", "x-datadog-sampling-priority:1", "x-datadog-trace-id:XXXX"] Data: {"series": [{"metric": "hello.dog", "points": [[XXXX, [1.0]]], "type": "distribution", "host": null, "device": null, "tags": ["team:serverless", "role:hello", "dd_lambda_layer:datadog-python37_X.X.X"], "interval": 10}, {"metric": "tests.integration.count", "points": [[XXXX, [21.0]]], "type": "distribution", "host": null, "device": null, "tags": ["test:integration", "role:hello", "dd_lambda_layer:datadog-python37_X.X.X"], "interval": 10}]} {"traces": [[{"trace_id": "XXXX", "parent_id": "XXXX", "span_id": "XXXX", "service": "aws.lambda", "resource": "integration-tests-python-XXXX-sync-metrics_python37", "name": "aws.lambda", "error": 0, "start": XXXX, "duration": XXXX, "meta": {"runtime-id": "XXXX", "_dd.origin": "lambda", "cold_start": "false", "function_arn": "arn:aws:lambda:sa-east-1:601427279990:function:integration-tests-python-XXXX-sync-metrics_python37", "function_version": "$LATEST", "request_id": "XXXX", "resource_names": "integration-tests-python-XXXX-sync-metrics_python37", "datadog_lambda": "X.X.X", "dd_trace": "X.X.X", "function_trigger.event_source": "sns", "function_trigger.event_source_arn": "arn:aws:sns:us-east-2:123456789012:sns-lambda"}, "metrics": {"system.pid": XXXX, "_dd.agent_psr": 1.0, "_sampling_priority_v1": 1}, "type": "serverless"}, {"trace_id": "XXXX", "parent_id": "XXXX", "span_id": "XXXX", "service": "aws.lambda", "resource": "requests.request", "name": "requests.request", "error": 0, "start": XXXX, "duration": XXXX, "meta": {"_dd.origin": "lambda", "http.method": "GET", "http.url": "https://httpstat.us/200/", "http.status_code": "200"}, "metrics": {"_dd.measured": 1}, "type": "http"}, {"trace_id": "XXXX", "parent_id": "XXXX", "span_id": "XXXX", "service": "aws.lambda", "resource": "requests.request", "name": "requests.request", "error": 0, "start": XXXX, "duration": XXXX, "meta": {"_dd.origin": "lambda", "http.method": "GET", "http.url": "https://httpstat.us/400/", "http.status_code": "400"}, "metrics": {"_dd.measured": 1}, "type": "http"}, {"trace_id": "XXXX", "parent_id": "XXXX", "span_id": "XXXX", "service": "aws.lambda", "resource": "requests.request", "name": "requests.request", "error": 0, "start": XXXX, "duration": XXXX, "meta": {"_dd.origin": "lambda", "http.method": "POST", "http.url": "https://api.datadoghq.com/api/v1/distribution_points", "http.status_code": "202"}, "metrics": {"_dd.measured": 1}, "type": "http"}]]} END RequestId: XXXX REPORT RequestId: XXXX Duration: XXXX ms Billed Duration: XXXX ms Memory Size: 1024 MB Max Memory Used: XXXX MB @@ -18,7 +18,7 @@ START RequestId: XXXX Version: $LATEST {"m": "aws.lambda.enhanced.invocations", "v": 1, "e": XXXX, "t": ["region:sa-east-1", "account_id:XXXX", "functionname:integration-tests-python-XXXX-sync-metrics_python37", "resource:integration-tests-python-XXXX-sync-metrics_python37", "cold_start:false", "memorysize:1024", "runtime:python3.7", "datadog_lambda:vXX", "dd_lambda_layer:datadog-python37_X.X.X"]} HTTP GET https://httpstat.us/200/ Headers: ["Accept-Encoding:gzip, deflate", "Accept:*/*", "Connection:keep-alive", "User-Agent:python-requests/2.25.1", "x-datadog-parent-id:XXXX", "x-datadog-sampling-priority:1", "x-datadog-trace-id:XXXX"] Data: {} HTTP GET https://httpstat.us/400/ Headers: ["Accept-Encoding:gzip, deflate", "Accept:*/*", "Connection:keep-alive", "User-Agent:python-requests/2.25.1", "x-datadog-parent-id:XXXX", "x-datadog-sampling-priority:1", "x-datadog-trace-id:XXXX"] Data: {} -HTTP POST https://api.datadoghq.com/api/v1/distribution_points?api_key=XXXX Headers: ["Accept-Encoding:gzip, deflate", "Accept:*/*", "Connection:keep-alive", "Content-Encoding:deflate", "Content-Length:XXXX", "Content-Type:application/json", "User-Agent:datadogpy/0.41.0 (python 3.7.10; os linux; arch x86_64)", "x-datadog-parent-id:XXXX", "x-datadog-sampling-priority:1", "x-datadog-trace-id:XXXX"] Data: {"series": [{"metric": "hello.dog", "points": [[XXXX, [1.0]]], "type": "distribution", "host": null, "device": null, "tags": ["team:serverless", "role:hello", "dd_lambda_layer:datadog-python37_X.X.X"], "interval": 10}, {"metric": "tests.integration.count", "points": [[XXXX, [21.0]]], "type": "distribution", "host": null, "device": null, "tags": ["test:integration", "role:hello", "dd_lambda_layer:datadog-python37_X.X.X"], "interval": 10}]} +HTTP POST https://api.datadoghq.com/api/v1/distribution_points?api_key=XXXX Headers: ["Accept-Encoding:gzip, deflate", "Accept:*/*", "Connection:keep-alive", "Content-Encoding:deflate", "Content-Length:XXXX", "Content-Type:application/json", "User-Agent:datadogpy/0.41.0 (python XX; os linux; arch x86_64)", "x-datadog-parent-id:XXXX", "x-datadog-sampling-priority:1", "x-datadog-trace-id:XXXX"] Data: {"series": [{"metric": "hello.dog", "points": [[XXXX, [1.0]]], "type": "distribution", "host": null, "device": null, "tags": ["team:serverless", "role:hello", "dd_lambda_layer:datadog-python37_X.X.X"], "interval": 10}, {"metric": "tests.integration.count", "points": [[XXXX, [21.0]]], "type": "distribution", "host": null, "device": null, "tags": ["test:integration", "role:hello", "dd_lambda_layer:datadog-python37_X.X.X"], "interval": 10}]} {"traces": [[{"trace_id": "XXXX", "parent_id": "XXXX", "span_id": "XXXX", "service": "aws.lambda", "resource": "integration-tests-python-XXXX-sync-metrics_python37", "name": "aws.lambda", "error": 0, "start": XXXX, "duration": XXXX, "meta": {"_dd.origin": "lambda", "cold_start": "false", "function_arn": "arn:aws:lambda:sa-east-1:601427279990:function:integration-tests-python-XXXX-sync-metrics_python37", "function_version": "$LATEST", "request_id": "XXXX", "resource_names": "integration-tests-python-XXXX-sync-metrics_python37", "datadog_lambda": "X.X.X", "dd_trace": "X.X.X", "function_trigger.event_source": "sqs", "function_trigger.event_source_arn": "arn:aws:sqs:us-east-2:123456789012:my-queue"}, "metrics": {"_sampling_priority_v1": 1}, "type": "serverless"}, {"trace_id": "XXXX", "parent_id": "XXXX", "span_id": "XXXX", "service": "aws.lambda", "resource": "requests.request", "name": "requests.request", "error": 0, "start": XXXX, "duration": XXXX, "meta": {"_dd.origin": "lambda", "http.method": "GET", "http.url": "https://httpstat.us/200/", "http.status_code": "200"}, "metrics": {"_dd.measured": 1}, "type": "http"}, {"trace_id": "XXXX", "parent_id": "XXXX", "span_id": "XXXX", "service": "aws.lambda", "resource": "requests.request", "name": "requests.request", "error": 0, "start": XXXX, "duration": XXXX, "meta": {"_dd.origin": "lambda", "http.method": "GET", "http.url": "https://httpstat.us/400/", "http.status_code": "400"}, "metrics": {"_dd.measured": 1}, "type": "http"}, {"trace_id": "XXXX", "parent_id": "XXXX", "span_id": "XXXX", "service": "aws.lambda", "resource": "requests.request", "name": "requests.request", "error": 0, "start": XXXX, "duration": XXXX, "meta": {"_dd.origin": "lambda", "http.method": "POST", "http.url": "https://api.datadoghq.com/api/v1/distribution_points", "http.status_code": "202"}, "metrics": {"_dd.measured": 1}, "type": "http"}]]} END RequestId: XXXX REPORT RequestId: XXXX Duration: XXXX ms Billed Duration: XXXX ms Memory Size: 1024 MB Max Memory Used: XXXX MB diff --git a/tests/integration/snapshots/logs/sync-metrics_python38.log b/tests/integration/snapshots/logs/sync-metrics_python38.log index 661fe4f2..014058c6 100644 --- a/tests/integration/snapshots/logs/sync-metrics_python38.log +++ b/tests/integration/snapshots/logs/sync-metrics_python38.log @@ -2,7 +2,7 @@ START RequestId: XXXX Version: $LATEST {"m": "aws.lambda.enhanced.invocations", "v": 1, "e": XXXX, "t": ["region:sa-east-1", "account_id:XXXX", "functionname:integration-tests-python-XXXX-sync-metrics_python38", "resource:integration-tests-python-XXXX-sync-metrics_python38", "cold_start:true", "memorysize:1024", "runtime:python3.8", "datadog_lambda:vXX", "dd_lambda_layer:datadog-python38_X.X.X"]} HTTP GET https://httpstat.us/200/ Headers: ["Accept-Encoding:gzip, deflate", "Accept:*/*", "Connection:keep-alive", "User-Agent:python-requests/2.25.1", "x-datadog-parent-id:XXXX", "x-datadog-sampling-priority:1", "x-datadog-trace-id:XXXX"] Data: {} HTTP GET https://httpstat.us/400/ Headers: ["Accept-Encoding:gzip, deflate", "Accept:*/*", "Connection:keep-alive", "User-Agent:python-requests/2.25.1", "x-datadog-parent-id:XXXX", "x-datadog-sampling-priority:1", "x-datadog-trace-id:XXXX"] Data: {} -HTTP POST https://api.datadoghq.com/api/v1/distribution_points?api_key=XXXX Headers: ["Accept-Encoding:gzip, deflate", "Accept:*/*", "Connection:keep-alive", "Content-Encoding:deflate", "Content-Length:XXXX", "Content-Type:application/json", "User-Agent:datadogpy/0.41.0 (python 3.8.8; os linux; arch x86_64)", "x-datadog-parent-id:XXXX", "x-datadog-sampling-priority:1", "x-datadog-trace-id:XXXX"] Data: {"series": [{"metric": "hello.dog", "points": [[XXXX, [1.0]]], "type": "distribution", "host": null, "device": null, "tags": ["team:serverless", "role:hello", "dd_lambda_layer:datadog-python38_X.X.X"], "interval": 10}, {"metric": "tests.integration.count", "points": [[XXXX, [21.0]]], "type": "distribution", "host": null, "device": null, "tags": ["test:integration", "role:hello", "dd_lambda_layer:datadog-python38_X.X.X"], "interval": 10}]} +HTTP POST https://api.datadoghq.com/api/v1/distribution_points?api_key=XXXX Headers: ["Accept-Encoding:gzip, deflate", "Accept:*/*", "Connection:keep-alive", "Content-Encoding:deflate", "Content-Length:XXXX", "Content-Type:application/json", "User-Agent:datadogpy/0.41.0 (python XX; os linux; arch x86_64)", "x-datadog-parent-id:XXXX", "x-datadog-sampling-priority:1", "x-datadog-trace-id:XXXX"] Data: {"series": [{"metric": "hello.dog", "points": [[XXXX, [1.0]]], "type": "distribution", "host": null, "device": null, "tags": ["team:serverless", "role:hello", "dd_lambda_layer:datadog-python38_X.X.X"], "interval": 10}, {"metric": "tests.integration.count", "points": [[XXXX, [21.0]]], "type": "distribution", "host": null, "device": null, "tags": ["test:integration", "role:hello", "dd_lambda_layer:datadog-python38_X.X.X"], "interval": 10}]} {"traces": [[{"trace_id": "XXXX", "parent_id": "XXXX", "span_id": "XXXX", "service": "aws.lambda", "resource": "integration-tests-python-XXXX-sync-metrics_python38", "name": "aws.lambda", "error": 0, "start": XXXX, "duration": XXXX, "meta": {"runtime-id": "XXXX", "_dd.origin": "lambda", "cold_start": "true", "function_arn": "arn:aws:lambda:sa-east-1:601427279990:function:integration-tests-python-XXXX-sync-metrics_python38", "function_version": "$LATEST", "request_id": "XXXX", "resource_names": "integration-tests-python-XXXX-sync-metrics_python38", "datadog_lambda": "X.X.X", "dd_trace": "X.X.X", "function_trigger.event_source": "api-gateway", "function_trigger.event_source_arn": "arn:aws:apigateway:sa-east-1::/restapis/wt6mne2s9k/stages/test", "http.method": "GET", "http.status_code": "200"}, "metrics": {"system.pid": XXXX, "_dd.agent_psr": 1.0, "_sampling_priority_v1": 1}, "type": "serverless"}, {"trace_id": "XXXX", "parent_id": "XXXX", "span_id": "XXXX", "service": "aws.lambda", "resource": "requests.request", "name": "requests.request", "error": 0, "start": XXXX, "duration": XXXX, "meta": {"_dd.origin": "lambda", "http.method": "GET", "http.url": "https://httpstat.us/200/", "http.status_code": "200"}, "metrics": {"_dd.measured": 1}, "type": "http"}, {"trace_id": "XXXX", "parent_id": "XXXX", "span_id": "XXXX", "service": "aws.lambda", "resource": "requests.request", "name": "requests.request", "error": 0, "start": XXXX, "duration": XXXX, "meta": {"_dd.origin": "lambda", "http.method": "GET", "http.url": "https://httpstat.us/400/", "http.status_code": "400"}, "metrics": {"_dd.measured": 1}, "type": "http"}, {"trace_id": "XXXX", "parent_id": "XXXX", "span_id": "XXXX", "service": "aws.lambda", "resource": "requests.request", "name": "requests.request", "error": 0, "start": XXXX, "duration": XXXX, "meta": {"_dd.origin": "lambda", "http.method": "POST", "http.url": "https://api.datadoghq.com/api/v1/distribution_points", "http.status_code": "202"}, "metrics": {"_dd.measured": 1}, "type": "http"}]]} END RequestId: XXXX REPORT RequestId: XXXX Duration: XXXX ms Billed Duration: XXXX ms Memory Size: 1024 MB Max Memory Used: XXXX MB Init Duration: XXXX ms @@ -10,7 +10,7 @@ START RequestId: XXXX Version: $LATEST {"m": "aws.lambda.enhanced.invocations", "v": 1, "e": XXXX, "t": ["region:sa-east-1", "account_id:XXXX", "functionname:integration-tests-python-XXXX-sync-metrics_python38", "resource:integration-tests-python-XXXX-sync-metrics_python38", "cold_start:false", "memorysize:1024", "runtime:python3.8", "datadog_lambda:vXX", "dd_lambda_layer:datadog-python38_X.X.X"]} HTTP GET https://httpstat.us/200/ Headers: ["Accept-Encoding:gzip, deflate", "Accept:*/*", "Connection:keep-alive", "User-Agent:python-requests/2.25.1", "x-datadog-parent-id:XXXX", "x-datadog-sampling-priority:1", "x-datadog-trace-id:XXXX"] Data: {} HTTP GET https://httpstat.us/400/ Headers: ["Accept-Encoding:gzip, deflate", "Accept:*/*", "Connection:keep-alive", "User-Agent:python-requests/2.25.1", "x-datadog-parent-id:XXXX", "x-datadog-sampling-priority:1", "x-datadog-trace-id:XXXX"] Data: {} -HTTP POST https://api.datadoghq.com/api/v1/distribution_points?api_key=XXXX Headers: ["Accept-Encoding:gzip, deflate", "Accept:*/*", "Connection:keep-alive", "Content-Encoding:deflate", "Content-Length:XXXX", "Content-Type:application/json", "User-Agent:datadogpy/0.41.0 (python 3.8.8; os linux; arch x86_64)", "x-datadog-parent-id:XXXX", "x-datadog-sampling-priority:1", "x-datadog-trace-id:XXXX"] Data: {"series": [{"metric": "hello.dog", "points": [[XXXX, [1.0]]], "type": "distribution", "host": null, "device": null, "tags": ["team:serverless", "role:hello", "dd_lambda_layer:datadog-python38_X.X.X"], "interval": 10}, {"metric": "tests.integration.count", "points": [[XXXX, [21.0]]], "type": "distribution", "host": null, "device": null, "tags": ["test:integration", "role:hello", "dd_lambda_layer:datadog-python38_X.X.X"], "interval": 10}]} +HTTP POST https://api.datadoghq.com/api/v1/distribution_points?api_key=XXXX Headers: ["Accept-Encoding:gzip, deflate", "Accept:*/*", "Connection:keep-alive", "Content-Encoding:deflate", "Content-Length:XXXX", "Content-Type:application/json", "User-Agent:datadogpy/0.41.0 (python XX; os linux; arch x86_64)", "x-datadog-parent-id:XXXX", "x-datadog-sampling-priority:1", "x-datadog-trace-id:XXXX"] Data: {"series": [{"metric": "hello.dog", "points": [[XXXX, [1.0]]], "type": "distribution", "host": null, "device": null, "tags": ["team:serverless", "role:hello", "dd_lambda_layer:datadog-python38_X.X.X"], "interval": 10}, {"metric": "tests.integration.count", "points": [[XXXX, [21.0]]], "type": "distribution", "host": null, "device": null, "tags": ["test:integration", "role:hello", "dd_lambda_layer:datadog-python38_X.X.X"], "interval": 10}]} {"traces": [[{"trace_id": "XXXX", "parent_id": "XXXX", "span_id": "XXXX", "service": "aws.lambda", "resource": "integration-tests-python-XXXX-sync-metrics_python38", "name": "aws.lambda", "error": 0, "start": XXXX, "duration": XXXX, "meta": {"runtime-id": "XXXX", "_dd.origin": "lambda", "cold_start": "false", "function_arn": "arn:aws:lambda:sa-east-1:601427279990:function:integration-tests-python-XXXX-sync-metrics_python38", "function_version": "$LATEST", "request_id": "XXXX", "resource_names": "integration-tests-python-XXXX-sync-metrics_python38", "datadog_lambda": "X.X.X", "dd_trace": "X.X.X", "function_trigger.event_source": "sns", "function_trigger.event_source_arn": "arn:aws:sns:us-east-2:123456789012:sns-lambda"}, "metrics": {"system.pid": XXXX, "_dd.agent_psr": 1.0, "_sampling_priority_v1": 1}, "type": "serverless"}, {"trace_id": "XXXX", "parent_id": "XXXX", "span_id": "XXXX", "service": "aws.lambda", "resource": "requests.request", "name": "requests.request", "error": 0, "start": XXXX, "duration": XXXX, "meta": {"_dd.origin": "lambda", "http.method": "GET", "http.url": "https://httpstat.us/200/", "http.status_code": "200"}, "metrics": {"_dd.measured": 1}, "type": "http"}, {"trace_id": "XXXX", "parent_id": "XXXX", "span_id": "XXXX", "service": "aws.lambda", "resource": "requests.request", "name": "requests.request", "error": 0, "start": XXXX, "duration": XXXX, "meta": {"_dd.origin": "lambda", "http.method": "GET", "http.url": "https://httpstat.us/400/", "http.status_code": "400"}, "metrics": {"_dd.measured": 1}, "type": "http"}, {"trace_id": "XXXX", "parent_id": "XXXX", "span_id": "XXXX", "service": "aws.lambda", "resource": "requests.request", "name": "requests.request", "error": 0, "start": XXXX, "duration": XXXX, "meta": {"_dd.origin": "lambda", "http.method": "POST", "http.url": "https://api.datadoghq.com/api/v1/distribution_points", "http.status_code": "202"}, "metrics": {"_dd.measured": 1}, "type": "http"}]]} END RequestId: XXXX REPORT RequestId: XXXX Duration: XXXX ms Billed Duration: XXXX ms Memory Size: 1024 MB Max Memory Used: XXXX MB @@ -18,7 +18,7 @@ START RequestId: XXXX Version: $LATEST {"m": "aws.lambda.enhanced.invocations", "v": 1, "e": XXXX, "t": ["region:sa-east-1", "account_id:XXXX", "functionname:integration-tests-python-XXXX-sync-metrics_python38", "resource:integration-tests-python-XXXX-sync-metrics_python38", "cold_start:false", "memorysize:1024", "runtime:python3.8", "datadog_lambda:vXX", "dd_lambda_layer:datadog-python38_X.X.X"]} HTTP GET https://httpstat.us/200/ Headers: ["Accept-Encoding:gzip, deflate", "Accept:*/*", "Connection:keep-alive", "User-Agent:python-requests/2.25.1", "x-datadog-parent-id:XXXX", "x-datadog-sampling-priority:1", "x-datadog-trace-id:XXXX"] Data: {} HTTP GET https://httpstat.us/400/ Headers: ["Accept-Encoding:gzip, deflate", "Accept:*/*", "Connection:keep-alive", "User-Agent:python-requests/2.25.1", "x-datadog-parent-id:XXXX", "x-datadog-sampling-priority:1", "x-datadog-trace-id:XXXX"] Data: {} -HTTP POST https://api.datadoghq.com/api/v1/distribution_points?api_key=XXXX Headers: ["Accept-Encoding:gzip, deflate", "Accept:*/*", "Connection:keep-alive", "Content-Encoding:deflate", "Content-Length:XXXX", "Content-Type:application/json", "User-Agent:datadogpy/0.41.0 (python 3.8.8; os linux; arch x86_64)", "x-datadog-parent-id:XXXX", "x-datadog-sampling-priority:1", "x-datadog-trace-id:XXXX"] Data: {"series": [{"metric": "hello.dog", "points": [[XXXX, [1.0]]], "type": "distribution", "host": null, "device": null, "tags": ["team:serverless", "role:hello", "dd_lambda_layer:datadog-python38_X.X.X"], "interval": 10}, {"metric": "tests.integration.count", "points": [[XXXX, [21.0]]], "type": "distribution", "host": null, "device": null, "tags": ["test:integration", "role:hello", "dd_lambda_layer:datadog-python38_X.X.X"], "interval": 10}]} +HTTP POST https://api.datadoghq.com/api/v1/distribution_points?api_key=XXXX Headers: ["Accept-Encoding:gzip, deflate", "Accept:*/*", "Connection:keep-alive", "Content-Encoding:deflate", "Content-Length:XXXX", "Content-Type:application/json", "User-Agent:datadogpy/0.41.0 (python XX; os linux; arch x86_64)", "x-datadog-parent-id:XXXX", "x-datadog-sampling-priority:1", "x-datadog-trace-id:XXXX"] Data: {"series": [{"metric": "hello.dog", "points": [[XXXX, [1.0]]], "type": "distribution", "host": null, "device": null, "tags": ["team:serverless", "role:hello", "dd_lambda_layer:datadog-python38_X.X.X"], "interval": 10}, {"metric": "tests.integration.count", "points": [[XXXX, [21.0]]], "type": "distribution", "host": null, "device": null, "tags": ["test:integration", "role:hello", "dd_lambda_layer:datadog-python38_X.X.X"], "interval": 10}]} {"traces": [[{"trace_id": "XXXX", "parent_id": "XXXX", "span_id": "XXXX", "service": "aws.lambda", "resource": "integration-tests-python-XXXX-sync-metrics_python38", "name": "aws.lambda", "error": 0, "start": XXXX, "duration": XXXX, "meta": {"_dd.origin": "lambda", "cold_start": "false", "function_arn": "arn:aws:lambda:sa-east-1:601427279990:function:integration-tests-python-XXXX-sync-metrics_python38", "function_version": "$LATEST", "request_id": "XXXX", "resource_names": "integration-tests-python-XXXX-sync-metrics_python38", "datadog_lambda": "X.X.X", "dd_trace": "X.X.X", "function_trigger.event_source": "sqs", "function_trigger.event_source_arn": "arn:aws:sqs:us-east-2:123456789012:my-queue"}, "metrics": {"_sampling_priority_v1": 1}, "type": "serverless"}, {"trace_id": "XXXX", "parent_id": "XXXX", "span_id": "XXXX", "service": "aws.lambda", "resource": "requests.request", "name": "requests.request", "error": 0, "start": XXXX, "duration": XXXX, "meta": {"_dd.origin": "lambda", "http.method": "GET", "http.url": "https://httpstat.us/200/", "http.status_code": "200"}, "metrics": {"_dd.measured": 1}, "type": "http"}, {"trace_id": "XXXX", "parent_id": "XXXX", "span_id": "XXXX", "service": "aws.lambda", "resource": "requests.request", "name": "requests.request", "error": 0, "start": XXXX, "duration": XXXX, "meta": {"_dd.origin": "lambda", "http.method": "GET", "http.url": "https://httpstat.us/400/", "http.status_code": "400"}, "metrics": {"_dd.measured": 1}, "type": "http"}, {"trace_id": "XXXX", "parent_id": "XXXX", "span_id": "XXXX", "service": "aws.lambda", "resource": "requests.request", "name": "requests.request", "error": 0, "start": XXXX, "duration": XXXX, "meta": {"_dd.origin": "lambda", "http.method": "POST", "http.url": "https://api.datadoghq.com/api/v1/distribution_points", "http.status_code": "202"}, "metrics": {"_dd.measured": 1}, "type": "http"}]]} END RequestId: XXXX REPORT RequestId: XXXX Duration: XXXX ms Billed Duration: XXXX ms Memory Size: 1024 MB Max Memory Used: XXXX MB diff --git a/tests/test_metric.py b/tests/test_metric.py index 1fbd33ce..848a9328 100644 --- a/tests/test_metric.py +++ b/tests/test_metric.py @@ -7,7 +7,7 @@ from mock import patch, call from datadog.api.exceptions import ClientError -from datadog_lambda.metric import lambda_metric, flush_thread_stats +from datadog_lambda.metric import lambda_metric, ThreadStatsWriter from datadog_lambda.tags import _format_dd_lambda_layer_tag @@ -49,10 +49,12 @@ def setUp(self): def test_retry_on_remote_disconnected(self): # Raise the RemoteDisconnected error + lambda_stats = ThreadStatsWriter(True) + self.mock_threadstats_flush_distributions.side_effect = ClientError( "POST", "https://api.datadoghq.com/api/v1/distribution_points", "RemoteDisconnected('Remote end closed connection without response')", ) - flush_thread_stats() + lambda_stats.flush() self.assertEqual(self.mock_threadstats_flush_distributions.call_count, 2) diff --git a/tests/test_wrapper.py b/tests/test_wrapper.py index 00ed0e75..77d1bde3 100644 --- a/tests/test_wrapper.py +++ b/tests/test_wrapper.py @@ -7,7 +7,7 @@ from mock import patch, call, ANY, MagicMock from datadog_lambda.wrapper import datadog_lambda_wrapper -from datadog_lambda.metric import lambda_metric +from datadog_lambda.metric import lambda_metric, ThreadStatsWriter def get_mock_context( @@ -136,7 +136,7 @@ def test_datadog_lambda_wrapper_flush_in_thread(self): import datadog_lambda.metric as metric_module metric_module.lambda_stats.stop() - metric_module.lambda_stats.start(flush_in_thread=True) + metric_module.lambda_stats = ThreadStatsWriter(True) @datadog_lambda_wrapper def lambda_handler(event, context): @@ -156,14 +156,14 @@ def lambda_handler(event, context): # reset ThreadStats metric_module.lambda_stats.stop() - metric_module.lambda_stats.start(flush_in_thread=False) + metric_module.lambda_stats = ThreadStatsWriter(False) def test_datadog_lambda_wrapper_not_flush_in_thread(self): # force ThreadStats to not flush in thread import datadog_lambda.metric as metric_module metric_module.lambda_stats.stop() - metric_module.lambda_stats.start(flush_in_thread=False) + metric_module.lambda_stats = ThreadStatsWriter(False) @datadog_lambda_wrapper def lambda_handler(event, context): @@ -183,7 +183,7 @@ def lambda_handler(event, context): # reset ThreadStats metric_module.lambda_stats.stop() - metric_module.lambda_stats.start(flush_in_thread=False) + metric_module.lambda_stats = ThreadStatsWriter(False) def test_datadog_lambda_wrapper_inject_correlation_ids(self): os.environ["DD_LOGS_INJECTION"] = "True"