diff --git a/.gitignore b/.gitignore index ff0272ba..3e604ef1 100644 --- a/.gitignore +++ b/.gitignore @@ -43,3 +43,10 @@ node_modules yarn-lock.json .benchmarks + +# Integration test build artifacts +tests/integration/.build/ +tests/integration/.aws-sam/ + +# Generated from ci/input_files/build.yaml.tpl (regenerated by the CI generator job) +ci/build-pipeline.yaml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 417398ec..6fa9417b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,6 +1,8 @@ variables: SKIP_E2E_TESTS: "false" - + # Opt-in pytest integration suite (integration-test-pytest jobs). + # TODO(APMSVLS-728): set back to "false" before merging. + RUN_PYTEST_INTEGRATION_TESTS: "true" stages: - pre - build diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d632d151..e3193bc2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -40,6 +40,17 @@ We love pull requests. For new features, consider opening an issue to discuss th ```bash UPDATE_SNAPSHOTS=true DD_API_KEY= ./scripts/run_integration_tests.sh ``` +1. The pytest integration suite in `tests/integration` (replacing the snapshot suite) deploys a stack from a SAM template, so it needs the [SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/install-sam-cli.html) (`pip install -r tests/integration/requirements-test.txt`): + ```bash + BUILD_LAYERS=true PYTHON_VERSION=3.13 ARCH=amd64 DD_API_KEY= ./scripts/run_integration_pytest.sh + ``` + `DD_API_KEY_SECRET_ARN=` can stand in for `DD_API_KEY`. The deployed functions read the key from Secrets Manager, so their role must be allowed to read that secret. + Leave out `PYTHON_VERSION` to run every supported version, one after another. + The tests that use the Datadog Extension (with a mock intake) use the layer version pinned in `DEFAULT_EXTENSION_LAYER_VERSION` in `tests/integration/harness/settings.py` by default; set `DD_EXTENSION_LAYER_VERSION` to another version number, or to `none` to skip them. In CI this suite only runs in pipelines with `RUN_PYTEST_INTEGRATION_TESTS=true`, as two jobs per runtime: `integration-test-pytest` (library only, no Extension) and `integration-test-pytest-extension` (the Extension tests, using that same pinned version). While iterating, set `KEEP_STACK=true` once, then `INTEGRATION_STACK_NAME=` to skip redeploying. +1. The pytest suite compares every span tag, outgoing request header, and metric tag against structured snapshots in `tests/integration/expected/` (`///.json`, where the variant is `default` or a runtime override such as `python38` or `python314-amd64`). Requests and metrics are condensed: every event emits the same metrics, so there is one file per function (`metrics//.json`), and requests have one file per function (`requests//.json`) plus an event file only where an event's requests differ (for example `appsync` on `default`, and the `zstd` `Accept-Encoding` on python314/315). python39 has no files of its own: its snapshots match python38's, so it falls back to them (`SHARED_RUNTIMES` in `tests/integration/harness/snapshots.py`). If the two ever diverge, `dedupe` fails and asks for the alias to be removed. The `cold_start` tag and the DynamoDB-only stream metric (value and tags) are asserted in `tests/integration/test_baseline.py` instead. Unexpected log output (warnings, prints, tracebacks) is not snapshotted: `test_no_unexpected_log_lines` in `tests/integration/test_baseline.py` requires it to be empty, and an intended new line goes on `ALLOWED_LOG_LINES` in that file (Lambda platform lines are filtered by `_PLATFORM_LINE_RES` in `tests/integration/harness/logs.py`). To update the snapshots after an intended change: + 1. Run the suite with `UPDATE_EXPECTED=true`, locally (writes files for that runtime) or in CI with `RUN_PYTEST_INTEGRATION_TESTS=true UPDATE_EXPECTED=true` (each `integration-test-pytest` job saves `tests/integration/expected/` as an artifact; extract all of them into the repo). + 1. Fold the per-run files into defaults plus overrides: `cd tests/integration && python -m harness.snapshots dedupe`. + 1. Review the diff and commit it. 1. Push to your fork and [submit a pull request][pr]. [pr]: https://github.com/your-username/datadog-lambda-python/compare/DataDog:main...main diff --git a/ci/input_files/build.yaml.tpl b/ci/input_files/build.yaml.tpl index b014ba1d..9290ecdd 100644 --- a/ci/input_files/build.yaml.tpl +++ b/ci/input_files/build.yaml.tpl @@ -26,6 +26,13 @@ default: - /opt/ci-python-tools/bin/pip install awscli - export PATH="/opt/ci-python-tools/bin:$PATH" +# aws-sam-cli and awscli pin incompatible botocore versions, so the integration +# test dependencies get their own venv, ahead of the awscli one on PATH. +.install-integration-test-deps: &install-integration-test-deps + - python3 -m venv /opt/integration-test-venv + - /opt/integration-test-venv/bin/pip install -r tests/integration/requirements-test.txt + - export PATH="/opt/integration-test-venv/bin:$PATH" + # This is for serverless framework .install-node: &install-node - apt-get update @@ -134,6 +141,76 @@ integration-test ({{ $runtime.name }}-{{ $runtime.arch }}): - RUNTIME_PARAM={{ $runtime.python_version }} ARCH={{ $runtime.arch }} ./scripts/run_integration_tests.sh retry: 2 +# Pytest + SAM replacement for the snapshot-based integration-test job above. +# Opt-in: only runs when the pipeline has RUN_PYTEST_INTEGRATION_TESTS=true (set it +# when running a pipeline, or as a CI/CD variable). Non-blocking until it has been +# green for a while; then the old job is removed. +# +# Two jobs per runtime, so an Extension release cannot fail the library tests: +# integration-test-pytest the library alone (no Extension layer) +# integration-test-pytest-extension the library with the Datadog Extension layer +integration-test-pytest ({{ $runtime.name }}-{{ $runtime.arch }}): + stage: test + tags: ["arch:amd64"] + image: registry.ddbuild.io/images/docker:29.4.0-noble-py3 + allow_failure: true + rules: + - if: '$RUN_PYTEST_INTEGRATION_TESTS != "true"' + when: never + - if: '$SKIP_E2E_TESTS == "true"' + when: never + - when: on_success + needs: + - build-layer ({{ $runtime.name }}-{{ $runtime.arch }}) + dependencies: + - build-layer ({{ $runtime.name }}-{{ $runtime.arch }}) + variables: + # No Extension layer: skips the tests marked "extension". + DD_EXTENSION_LAYER_VERSION: "none" + before_script: + - *install-python-tools + - EXTERNAL_ID_NAME=integration-test-externalid ROLE_TO_ASSUME=sandbox-integration-test-deployer AWS_ACCOUNT=425362996713 source ./ci/get_secrets.sh + - *install-integration-test-deps + script: + - PYTHON_VERSION={{ $runtime.python_version }} ARCH={{ $runtime.arch }} ./scripts/run_integration_pytest.sh --junitxml=integration-junit.xml + artifacts: + when: always + # With UPDATE_EXPECTED=true, the snapshots this job wrote (see CONTRIBUTING.md). + paths: + - tests/integration/expected/ + reports: + junit: tests/integration/integration-junit.xml + retry: 1 + +integration-test-pytest-extension ({{ $runtime.name }}-{{ $runtime.arch }}): + stage: test + tags: ["arch:amd64"] + image: registry.ddbuild.io/images/docker:29.4.0-noble-py3 + allow_failure: true + rules: + - if: '$RUN_PYTEST_INTEGRATION_TESTS != "true"' + when: never + - if: '$SKIP_E2E_TESTS == "true"' + when: never + - when: on_success + needs: + - build-layer ({{ $runtime.name }}-{{ $runtime.arch }}) + dependencies: + - build-layer ({{ $runtime.name }}-{{ $runtime.arch }}) + # The Extension layer version is DEFAULT_EXTENSION_LAYER_VERSION in + # tests/integration/harness/settings.py; change it there, not per pipeline. + before_script: + - *install-python-tools + - EXTERNAL_ID_NAME=integration-test-externalid ROLE_TO_ASSUME=sandbox-integration-test-deployer AWS_ACCOUNT=425362996713 source ./ci/get_secrets.sh + - *install-integration-test-deps + script: + - PYTHON_VERSION={{ $runtime.python_version }} ARCH={{ $runtime.arch }} ./scripts/run_integration_pytest.sh -m extension --junitxml=integration-extension-junit.xml + artifacts: + when: always + reports: + junit: tests/integration/integration-extension-junit.xml + retry: 1 + sign-layer ({{ $runtime.name }}-{{ $runtime.arch }}): stage: sign tags: ["arch:amd64"] diff --git a/scripts/run_integration_pytest.sh b/scripts/run_integration_pytest.sh new file mode 100755 index 00000000..9e817718 --- /dev/null +++ b/scripts/run_integration_pytest.sh @@ -0,0 +1,106 @@ +#!/bin/bash + +# Unless explicitly stated otherwise all files in this repository are licensed +# under the Apache License Version 2.0. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2026 Datadog, Inc. + +# Runs the pytest integration suite in tests/integration (SAM-deployed stack). +# +# Usage, from the repo root: +# ARCH=amd64 DD_API_KEY=XXXX \ +# aws-vault exec sso-serverless-sandbox-account-admin -- ./scripts/run_integration_pytest.sh +# +# DD_API_KEY_SECRET_ARN can stand in for DD_API_KEY. The deployed functions read +# the key from Secrets Manager themselves, so the role they run as must be +# allowed to read that secret. +# +# Runs every Python version in python_versions.yaml, one after another (each +# deploys its own stack), unless PYTHON_VERSION is set. +# +# Optional: +# PYTHON_VERSION=3.13 run one version only (shorthand like 13 works too) +# BUILD_LAYERS=true build the layer(s) first +# DD_EXTENSION_LAYER_VERSION=N Datadog Extension layer version (default: the pin in +# tests/integration/harness/settings.py; +# "none" skips the extension / mock intake tests) +# INTEGRATION_STACK_NAME=... reuse a deployed stack (kept afterwards); needs PYTHON_VERSION +# KEEP_STACK=true keep the stack(s) for debugging +# UPDATE_EXPECTED=true write snapshots instead of comparing (see CONTRIBUTING.md) +# Extra arguments are passed to pytest, e.g. -k sqs. With several versions, +# --junitxml=.xml writes one -.xml per version. + +set -e + +scripts_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +repo_dir=$(dirname "$scripts_dir") +source "$scripts_dir/python_versions.sh" + +if [ -z "$ARCH" ]; then + echo "ARCH must be set" + exit 1 +fi + +if [ -z "$DD_API_KEY" ] && [ -z "$DD_API_KEY_SECRET_ARN" ]; then + echo "DD_API_KEY or DD_API_KEY_SECRET_ARN must be set" + exit 1 +fi + +if [ -n "$PYTHON_VERSION" ]; then + if [[ "$PYTHON_VERSION" =~ ^[0-9]+$ ]]; then + PYTHON_VERSION="3.${PYTHON_VERSION}" + fi + if [[ ! " ${SUPPORTED_PYTHON_VERSIONS[*]} " =~ " ${PYTHON_VERSION} " ]]; then + echo "Python version $PYTHON_VERSION is not supported. Choose from: ${SUPPORTED_PYTHON_VERSIONS[*]}" + exit 1 + fi + versions=("$PYTHON_VERSION") +else + if [ -n "$INTEGRATION_STACK_NAME" ]; then + echo "INTEGRATION_STACK_NAME reuses one runtime's stack; set PYTHON_VERSION too" + exit 1 + fi + versions=("${SUPPORTED_PYTHON_VERSIONS[@]}") + echo "PYTHON_VERSION not set, running all versions: ${versions[*]}" +fi + +marker_args=() +if [ "$DD_EXTENSION_LAYER_VERSION" = "none" ]; then + echo "DD_EXTENSION_LAYER_VERSION=none, skipping extension tests" + marker_args=(-m "not extension") +fi + +failed=() +for version in "${versions[@]}"; do + echo "=== Python $version ($ARCH) ===" + + # One JUnit file per version, so runs don't overwrite each other. + pytest_args=() + for arg in "$@"; do + if [ ${#versions[@]} -gt 1 ] && [[ "$arg" == --junitxml=*.xml ]]; then + arg="${arg%.xml}-${version}.xml" + fi + pytest_args+=("$arg") + done + + # Keep going after a failure, so one run covers every version. + set +e + ( + set -e + if [ -n "$BUILD_LAYERS" ]; then + PYTHON_VERSION=$version ARCH=$ARCH "$scripts_dir/build_layers.sh" + fi + cd "$repo_dir/tests/integration" + PYTHON_VERSION=$version python -m pytest "${marker_args[@]}" "${pytest_args[@]}" + ) + status=$? + set -e + if [ $status -ne 0 ]; then + failed+=("$version") + fi +done + +if [ ${#versions[@]} -gt 1 ]; then + echo "=== Ran ${#versions[@]} versions on $ARCH; failed: ${failed[*]:-none} ===" +fi +[ ${#failed[@]} -eq 0 ] diff --git a/tests/conftest.py b/tests/conftest.py index 33869802..caafbb47 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -2,6 +2,10 @@ from datadog_lambda.config import config +# tests/integration deploys AWS resources; it runs from its own directory +# (cd tests/integration && pytest), never as part of the unit tests. +collect_ignore = ["integration"] + @pytest.fixture(autouse=True) def reset_config(): diff --git a/tests/integration/__init__.py b/tests/integration/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py new file mode 100644 index 00000000..571ef079 --- /dev/null +++ b/tests/integration/conftest.py @@ -0,0 +1,107 @@ +"""Session fixtures: deploy the stack once, run the baseline invocations once. + +Environment: + PYTHON_VERSION, ARCH, and one of DD_API_KEY or DD_API_KEY_SECRET_ARN required + DD_EXTENSION_LAYER_VERSION Datadog Extension layer version number (default: + the pinned version in harness/settings.py) or "none" + (no extension tests) + INTEGRATION_STACK_NAME reuse a deployed stack (it is kept afterwards) + KEEP_STACK=true don't delete the stack at the end + INTEGRATION_REGION default eu-west-1 +""" + +from __future__ import annotations + +import json +import secrets +from typing import Dict, Tuple + +import pytest + +from .harness import aws +from .harness import settings as settings_mod + +from .harness.settings import BASELINE_FUNCTIONS, EVENT_NAMES, INPUT_EVENTS_DIR + +CASES = [(fn, ev) for fn in BASELINE_FUNCTIONS for ev in EVENT_NAMES] + + +def load_event(name: str): + return json.loads((INPUT_EVENTS_DIR / (name + ".json")).read_text()) + + +@pytest.fixture(scope="session") +def run_settings() -> settings_mod.Settings: + return settings_mod.load() + + +@pytest.fixture(scope="session") +def stack(request, run_settings) -> Dict[str, str]: + """Deploy the stack and return its outputs.""" + s = run_settings + if not s.existing_stack: + # Stream deploy output (pip, sam) live instead of capturing it. + capture = request.config.pluginmanager.getplugin("capturemanager") + with capture.global_and_fixture_disabled(): + print("\nIntegration test stack: %s" % s.stack_name, flush=True) + try: + aws.deploy(s, mock_intake_api_key=secrets.token_hex(16)) + except Exception as e: + # Report the deploy error first: a failing cleanup must not hide it. + print("Deploying %s failed: %s" % (s.stack_name, e), flush=True) + if not s.keep_stack: + try: + aws.delete(s) + except Exception as cleanup_error: + print( + "Deleting %s also failed, delete it manually: %s" + % (s.stack_name, cleanup_error), + flush=True, + ) + # Every test needs the stack; stop with one error, not one per test. + pytest.exit("Deploying %s failed: %s" % (s.stack_name, e), returncode=1) + try: + yield aws.stack_outputs(s) + finally: + if not s.keep_stack: + aws.delete(s) + + +@pytest.fixture(scope="session") +def baseline_invocations(run_settings, stack) -> Dict[Tuple[str, str], aws.Invocation]: + """Invoke each baseline function once per input event, in sorted order, + and attach the parsed logs. Keyed by (function key, event name).""" + results: Dict[Tuple[str, str], aws.Invocation] = {} + for key, output in BASELINE_FUNCTIONS.items(): + function_name = stack[output] + if run_settings.existing_stack: + # A reused stack may be warm; the first invocation must be a cold start. + aws.force_cold_start(run_settings.region, function_name) + invocations = [ + aws.invoke(run_settings.region, function_name, load_event(name)) + for name in EVENT_NAMES + ] + logs = aws.wait_for_logs( + run_settings.region, function_name, [i.request_id for i in invocations] + ) + for name, inv in zip(EVENT_NAMES, invocations): + inv.logs = logs[inv.request_id] + results[(key, name)] = inv + return results + + +@pytest.fixture(params=CASES, ids=["%s-%s" % c for c in CASES]) +def case(request, baseline_invocations): + """(function key, event name, Invocation), once per baseline function and event.""" + fn, event_name = request.param + return fn, event_name, baseline_invocations[(fn, event_name)] + + +@pytest.fixture(scope="session") +def extension_function(run_settings, stack) -> str: + if "ExtensionFunctionName" not in stack: + pytest.fail( + "Stack has no extension function (DD_EXTENSION_LAYER_VERSION=none); " + 'deselect these tests with -m "not extension"' + ) + return stack["ExtensionFunctionName"] diff --git a/tests/integration/expected/metrics/default/async-metrics.json b/tests/integration/expected/metrics/default/async-metrics.json new file mode 100644 index 00000000..b4f79668 --- /dev/null +++ b/tests/integration/expected/metrics/default/async-metrics.json @@ -0,0 +1,35 @@ +[ + { + "m": "aws.lambda.enhanced.invocations", + "t": [ + "account_id:", + "cold_start:", + "datadog_lambda:", + "dd_lambda_layer:datadog-_", + "functionname:", + "memorysize:1024", + "region:eu-west-1", + "resource:", + "runtime:" + ], + "v": 1 + }, + { + "m": "hello.dog", + "t": [ + "dd_lambda_layer:datadog-_", + "role:hello", + "team:serverless" + ], + "v": 1 + }, + { + "m": "tests.integration.count", + "t": [ + "dd_lambda_layer:datadog-_", + "role:hello", + "test:integration" + ], + "v": 21 + } +] diff --git a/tests/integration/expected/metrics/default/sync-metrics.json b/tests/integration/expected/metrics/default/sync-metrics.json new file mode 100644 index 00000000..66276c9b --- /dev/null +++ b/tests/integration/expected/metrics/default/sync-metrics.json @@ -0,0 +1,17 @@ +[ + { + "m": "aws.lambda.enhanced.invocations", + "t": [ + "account_id:", + "cold_start:", + "datadog_lambda:", + "dd_lambda_layer:datadog-_", + "functionname:", + "memorysize:1024", + "region:eu-west-1", + "resource:", + "runtime:" + ], + "v": 1 + } +] diff --git a/tests/integration/expected/requests/default/async-metrics.json b/tests/integration/expected/requests/default/async-metrics.json new file mode 100644 index 00000000..a9b6bf10 --- /dev/null +++ b/tests/integration/expected/requests/default/async-metrics.json @@ -0,0 +1,36 @@ +[ + { + "data": {}, + "headers": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "python-requests/X", + "traceparent": "00---01", + "tracestate": "dd=p:;s:1;t.dm:-0;t.tid:,ot=rv:;th:0", + "x-datadog-parent-id": "", + "x-datadog-sampling-priority": "1", + "x-datadog-tags": "_dd.p.dm=-0,_dd.p.tid=", + "x-datadog-trace-id": "" + }, + "method": "GET", + "url": "https://datadoghq.com/" + }, + { + "data": {}, + "headers": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "python-requests/X", + "traceparent": "00---01", + "tracestate": "dd=p:;s:1;t.dm:-0;t.tid:,ot=rv:;th:0", + "x-datadog-parent-id": "", + "x-datadog-sampling-priority": "1", + "x-datadog-tags": "_dd.p.dm=-0,_dd.p.tid=", + "x-datadog-trace-id": "" + }, + "method": "GET", + "url": "https://www.datadoghq.com/" + } +] diff --git a/tests/integration/expected/requests/default/async-metrics/appsync.json b/tests/integration/expected/requests/default/async-metrics/appsync.json new file mode 100644 index 00000000..eff62208 --- /dev/null +++ b/tests/integration/expected/requests/default/async-metrics/appsync.json @@ -0,0 +1,34 @@ +[ + { + "data": {}, + "headers": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "python-requests/X", + "traceparent": "00---01", + "tracestate": "dd=p:;s:1", + "x-datadog-parent-id": "", + "x-datadog-sampling-priority": "1", + "x-datadog-trace-id": "" + }, + "method": "GET", + "url": "https://datadoghq.com/" + }, + { + "data": {}, + "headers": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "python-requests/X", + "traceparent": "00---01", + "tracestate": "dd=p:;s:1", + "x-datadog-parent-id": "", + "x-datadog-sampling-priority": "1", + "x-datadog-trace-id": "" + }, + "method": "GET", + "url": "https://www.datadoghq.com/" + } +] diff --git a/tests/integration/expected/requests/default/sync-metrics.json b/tests/integration/expected/requests/default/sync-metrics.json new file mode 100644 index 00000000..2425f972 --- /dev/null +++ b/tests/integration/expected/requests/default/sync-metrics.json @@ -0,0 +1,102 @@ +[ + { + "data": {}, + "headers": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "python-requests/X", + "traceparent": "00---01", + "tracestate": "dd=p:;s:1;t.dm:-0;t.tid:,ot=rv:;th:0", + "x-datadog-parent-id": "", + "x-datadog-sampling-priority": "1", + "x-datadog-tags": "_dd.p.dm=-0,_dd.p.tid=", + "x-datadog-trace-id": "" + }, + "method": "GET", + "url": "https://datadoghq.com/" + }, + { + "data": {}, + "headers": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "python-requests/X", + "traceparent": "00---01", + "tracestate": "dd=p:;s:1;t.dm:-0;t.tid:,ot=rv:;th:0", + "x-datadog-parent-id": "", + "x-datadog-sampling-priority": "1", + "x-datadog-tags": "_dd.p.dm=-0,_dd.p.tid=", + "x-datadog-trace-id": "" + }, + "method": "GET", + "url": "https://www.datadoghq.com/" + }, + { + "data": { + "series": [ + { + "device": null, + "host": null, + "interval": 10, + "metric": "hello.dog", + "points": [ + [ + "", + [ + 1.0 + ] + ] + ], + "tags": [ + "dd_lambda_layer:datadog-_", + "role:hello", + "service:integration-tests-python", + "team:serverless" + ], + "type": "distribution" + }, + { + "device": null, + "host": null, + "interval": 10, + "metric": "tests.integration.count", + "points": [ + [ + "", + [ + 21.0 + ] + ] + ], + "tags": [ + "dd_lambda_layer:datadog-_", + "role:hello", + "service:integration-tests-python", + "test:integration" + ], + "type": "distribution" + } + ] + }, + "headers": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Content-Encoding": "deflate", + "Content-Length": "", + "Content-Type": "application/json", + "DD-API-KEY": "", + "User-Agent": "datadogpy/X (python X; os linux; arch )", + "traceparent": "00---01", + "tracestate": "dd=p:;s:1;t.dm:-0;t.tid:,ot=rv:;th:0", + "x-datadog-parent-id": "", + "x-datadog-sampling-priority": "1", + "x-datadog-tags": "_dd.p.dm=-0,_dd.p.tid=", + "x-datadog-trace-id": "" + }, + "method": "POST", + "url": "https://api.datadoghq.com/api/v1/distribution_points" + } +] diff --git a/tests/integration/expected/requests/default/sync-metrics/appsync.json b/tests/integration/expected/requests/default/sync-metrics/appsync.json new file mode 100644 index 00000000..56d55977 --- /dev/null +++ b/tests/integration/expected/requests/default/sync-metrics/appsync.json @@ -0,0 +1,100 @@ +[ + { + "data": {}, + "headers": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "python-requests/X", + "traceparent": "00---01", + "tracestate": "dd=p:;s:1", + "x-datadog-parent-id": "", + "x-datadog-sampling-priority": "1", + "x-datadog-trace-id": "" + }, + "method": "GET", + "url": "https://datadoghq.com/" + }, + { + "data": {}, + "headers": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "python-requests/X", + "traceparent": "00---01", + "tracestate": "dd=p:;s:1", + "x-datadog-parent-id": "", + "x-datadog-sampling-priority": "1", + "x-datadog-trace-id": "" + }, + "method": "GET", + "url": "https://www.datadoghq.com/" + }, + { + "data": { + "series": [ + { + "device": null, + "host": null, + "interval": 10, + "metric": "hello.dog", + "points": [ + [ + "", + [ + 1.0 + ] + ] + ], + "tags": [ + "dd_lambda_layer:datadog-_", + "role:hello", + "service:integration-tests-python", + "team:serverless" + ], + "type": "distribution" + }, + { + "device": null, + "host": null, + "interval": 10, + "metric": "tests.integration.count", + "points": [ + [ + "", + [ + 21.0 + ] + ] + ], + "tags": [ + "dd_lambda_layer:datadog-_", + "role:hello", + "service:integration-tests-python", + "test:integration" + ], + "type": "distribution" + } + ] + }, + "headers": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Content-Encoding": "deflate", + "Content-Length": "", + "Content-Type": "application/json", + "DD-API-KEY": "", + "User-Agent": "datadogpy/X (python X; os linux; arch )", + "traceparent": "00---01", + "tracestate": "dd=p:;s:1;t.dm:-0;t.tid:,ot=rv:;th:0", + "x-datadog-parent-id": "", + "x-datadog-sampling-priority": "1", + "x-datadog-tags": "_dd.p.dm=-0,_dd.p.tid=", + "x-datadog-trace-id": "" + }, + "method": "POST", + "url": "https://api.datadoghq.com/api/v1/distribution_points" + } +] diff --git a/tests/integration/expected/requests/python314/async-metrics.json b/tests/integration/expected/requests/python314/async-metrics.json new file mode 100644 index 00000000..495f10b9 --- /dev/null +++ b/tests/integration/expected/requests/python314/async-metrics.json @@ -0,0 +1,36 @@ +[ + { + "data": {}, + "headers": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate, zstd", + "Connection": "keep-alive", + "User-Agent": "python-requests/X", + "traceparent": "00---01", + "tracestate": "dd=p:;s:1;t.dm:-0;t.tid:,ot=rv:;th:0", + "x-datadog-parent-id": "", + "x-datadog-sampling-priority": "1", + "x-datadog-tags": "_dd.p.dm=-0,_dd.p.tid=", + "x-datadog-trace-id": "" + }, + "method": "GET", + "url": "https://datadoghq.com/" + }, + { + "data": {}, + "headers": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate, zstd", + "Connection": "keep-alive", + "User-Agent": "python-requests/X", + "traceparent": "00---01", + "tracestate": "dd=p:;s:1;t.dm:-0;t.tid:,ot=rv:;th:0", + "x-datadog-parent-id": "", + "x-datadog-sampling-priority": "1", + "x-datadog-tags": "_dd.p.dm=-0,_dd.p.tid=", + "x-datadog-trace-id": "" + }, + "method": "GET", + "url": "https://www.datadoghq.com/" + } +] diff --git a/tests/integration/expected/requests/python314/async-metrics/appsync.json b/tests/integration/expected/requests/python314/async-metrics/appsync.json new file mode 100644 index 00000000..a197577d --- /dev/null +++ b/tests/integration/expected/requests/python314/async-metrics/appsync.json @@ -0,0 +1,34 @@ +[ + { + "data": {}, + "headers": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate, zstd", + "Connection": "keep-alive", + "User-Agent": "python-requests/X", + "traceparent": "00---01", + "tracestate": "dd=p:;s:1", + "x-datadog-parent-id": "", + "x-datadog-sampling-priority": "1", + "x-datadog-trace-id": "" + }, + "method": "GET", + "url": "https://datadoghq.com/" + }, + { + "data": {}, + "headers": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate, zstd", + "Connection": "keep-alive", + "User-Agent": "python-requests/X", + "traceparent": "00---01", + "tracestate": "dd=p:;s:1", + "x-datadog-parent-id": "", + "x-datadog-sampling-priority": "1", + "x-datadog-trace-id": "" + }, + "method": "GET", + "url": "https://www.datadoghq.com/" + } +] diff --git a/tests/integration/expected/requests/python314/sync-metrics.json b/tests/integration/expected/requests/python314/sync-metrics.json new file mode 100644 index 00000000..1c12237d --- /dev/null +++ b/tests/integration/expected/requests/python314/sync-metrics.json @@ -0,0 +1,102 @@ +[ + { + "data": {}, + "headers": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate, zstd", + "Connection": "keep-alive", + "User-Agent": "python-requests/X", + "traceparent": "00---01", + "tracestate": "dd=p:;s:1;t.dm:-0;t.tid:,ot=rv:;th:0", + "x-datadog-parent-id": "", + "x-datadog-sampling-priority": "1", + "x-datadog-tags": "_dd.p.dm=-0,_dd.p.tid=", + "x-datadog-trace-id": "" + }, + "method": "GET", + "url": "https://datadoghq.com/" + }, + { + "data": {}, + "headers": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate, zstd", + "Connection": "keep-alive", + "User-Agent": "python-requests/X", + "traceparent": "00---01", + "tracestate": "dd=p:;s:1;t.dm:-0;t.tid:,ot=rv:;th:0", + "x-datadog-parent-id": "", + "x-datadog-sampling-priority": "1", + "x-datadog-tags": "_dd.p.dm=-0,_dd.p.tid=", + "x-datadog-trace-id": "" + }, + "method": "GET", + "url": "https://www.datadoghq.com/" + }, + { + "data": { + "series": [ + { + "device": null, + "host": null, + "interval": 10, + "metric": "hello.dog", + "points": [ + [ + "", + [ + 1.0 + ] + ] + ], + "tags": [ + "dd_lambda_layer:datadog-_", + "role:hello", + "service:integration-tests-python", + "team:serverless" + ], + "type": "distribution" + }, + { + "device": null, + "host": null, + "interval": 10, + "metric": "tests.integration.count", + "points": [ + [ + "", + [ + 21.0 + ] + ] + ], + "tags": [ + "dd_lambda_layer:datadog-_", + "role:hello", + "service:integration-tests-python", + "test:integration" + ], + "type": "distribution" + } + ] + }, + "headers": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate, zstd", + "Connection": "keep-alive", + "Content-Encoding": "deflate", + "Content-Length": "", + "Content-Type": "application/json", + "DD-API-KEY": "", + "User-Agent": "datadogpy/X (python X; os linux; arch )", + "traceparent": "00---01", + "tracestate": "dd=p:;s:1;t.dm:-0;t.tid:,ot=rv:;th:0", + "x-datadog-parent-id": "", + "x-datadog-sampling-priority": "1", + "x-datadog-tags": "_dd.p.dm=-0,_dd.p.tid=", + "x-datadog-trace-id": "" + }, + "method": "POST", + "url": "https://api.datadoghq.com/api/v1/distribution_points" + } +] diff --git a/tests/integration/expected/requests/python314/sync-metrics/appsync.json b/tests/integration/expected/requests/python314/sync-metrics/appsync.json new file mode 100644 index 00000000..38c895b0 --- /dev/null +++ b/tests/integration/expected/requests/python314/sync-metrics/appsync.json @@ -0,0 +1,100 @@ +[ + { + "data": {}, + "headers": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate, zstd", + "Connection": "keep-alive", + "User-Agent": "python-requests/X", + "traceparent": "00---01", + "tracestate": "dd=p:;s:1", + "x-datadog-parent-id": "", + "x-datadog-sampling-priority": "1", + "x-datadog-trace-id": "" + }, + "method": "GET", + "url": "https://datadoghq.com/" + }, + { + "data": {}, + "headers": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate, zstd", + "Connection": "keep-alive", + "User-Agent": "python-requests/X", + "traceparent": "00---01", + "tracestate": "dd=p:;s:1", + "x-datadog-parent-id": "", + "x-datadog-sampling-priority": "1", + "x-datadog-trace-id": "" + }, + "method": "GET", + "url": "https://www.datadoghq.com/" + }, + { + "data": { + "series": [ + { + "device": null, + "host": null, + "interval": 10, + "metric": "hello.dog", + "points": [ + [ + "", + [ + 1.0 + ] + ] + ], + "tags": [ + "dd_lambda_layer:datadog-_", + "role:hello", + "service:integration-tests-python", + "team:serverless" + ], + "type": "distribution" + }, + { + "device": null, + "host": null, + "interval": 10, + "metric": "tests.integration.count", + "points": [ + [ + "", + [ + 21.0 + ] + ] + ], + "tags": [ + "dd_lambda_layer:datadog-_", + "role:hello", + "service:integration-tests-python", + "test:integration" + ], + "type": "distribution" + } + ] + }, + "headers": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate, zstd", + "Connection": "keep-alive", + "Content-Encoding": "deflate", + "Content-Length": "", + "Content-Type": "application/json", + "DD-API-KEY": "", + "User-Agent": "datadogpy/X (python X; os linux; arch )", + "traceparent": "00---01", + "tracestate": "dd=p:;s:1;t.dm:-0;t.tid:,ot=rv:;th:0", + "x-datadog-parent-id": "", + "x-datadog-sampling-priority": "1", + "x-datadog-tags": "_dd.p.dm=-0,_dd.p.tid=", + "x-datadog-trace-id": "" + }, + "method": "POST", + "url": "https://api.datadoghq.com/api/v1/distribution_points" + } +] diff --git a/tests/integration/expected/requests/python315/async-metrics.json b/tests/integration/expected/requests/python315/async-metrics.json new file mode 100644 index 00000000..495f10b9 --- /dev/null +++ b/tests/integration/expected/requests/python315/async-metrics.json @@ -0,0 +1,36 @@ +[ + { + "data": {}, + "headers": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate, zstd", + "Connection": "keep-alive", + "User-Agent": "python-requests/X", + "traceparent": "00---01", + "tracestate": "dd=p:;s:1;t.dm:-0;t.tid:,ot=rv:;th:0", + "x-datadog-parent-id": "", + "x-datadog-sampling-priority": "1", + "x-datadog-tags": "_dd.p.dm=-0,_dd.p.tid=", + "x-datadog-trace-id": "" + }, + "method": "GET", + "url": "https://datadoghq.com/" + }, + { + "data": {}, + "headers": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate, zstd", + "Connection": "keep-alive", + "User-Agent": "python-requests/X", + "traceparent": "00---01", + "tracestate": "dd=p:;s:1;t.dm:-0;t.tid:,ot=rv:;th:0", + "x-datadog-parent-id": "", + "x-datadog-sampling-priority": "1", + "x-datadog-tags": "_dd.p.dm=-0,_dd.p.tid=", + "x-datadog-trace-id": "" + }, + "method": "GET", + "url": "https://www.datadoghq.com/" + } +] diff --git a/tests/integration/expected/requests/python315/async-metrics/appsync.json b/tests/integration/expected/requests/python315/async-metrics/appsync.json new file mode 100644 index 00000000..a197577d --- /dev/null +++ b/tests/integration/expected/requests/python315/async-metrics/appsync.json @@ -0,0 +1,34 @@ +[ + { + "data": {}, + "headers": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate, zstd", + "Connection": "keep-alive", + "User-Agent": "python-requests/X", + "traceparent": "00---01", + "tracestate": "dd=p:;s:1", + "x-datadog-parent-id": "", + "x-datadog-sampling-priority": "1", + "x-datadog-trace-id": "" + }, + "method": "GET", + "url": "https://datadoghq.com/" + }, + { + "data": {}, + "headers": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate, zstd", + "Connection": "keep-alive", + "User-Agent": "python-requests/X", + "traceparent": "00---01", + "tracestate": "dd=p:;s:1", + "x-datadog-parent-id": "", + "x-datadog-sampling-priority": "1", + "x-datadog-trace-id": "" + }, + "method": "GET", + "url": "https://www.datadoghq.com/" + } +] diff --git a/tests/integration/expected/requests/python315/sync-metrics.json b/tests/integration/expected/requests/python315/sync-metrics.json new file mode 100644 index 00000000..1c12237d --- /dev/null +++ b/tests/integration/expected/requests/python315/sync-metrics.json @@ -0,0 +1,102 @@ +[ + { + "data": {}, + "headers": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate, zstd", + "Connection": "keep-alive", + "User-Agent": "python-requests/X", + "traceparent": "00---01", + "tracestate": "dd=p:;s:1;t.dm:-0;t.tid:,ot=rv:;th:0", + "x-datadog-parent-id": "", + "x-datadog-sampling-priority": "1", + "x-datadog-tags": "_dd.p.dm=-0,_dd.p.tid=", + "x-datadog-trace-id": "" + }, + "method": "GET", + "url": "https://datadoghq.com/" + }, + { + "data": {}, + "headers": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate, zstd", + "Connection": "keep-alive", + "User-Agent": "python-requests/X", + "traceparent": "00---01", + "tracestate": "dd=p:;s:1;t.dm:-0;t.tid:,ot=rv:;th:0", + "x-datadog-parent-id": "", + "x-datadog-sampling-priority": "1", + "x-datadog-tags": "_dd.p.dm=-0,_dd.p.tid=", + "x-datadog-trace-id": "" + }, + "method": "GET", + "url": "https://www.datadoghq.com/" + }, + { + "data": { + "series": [ + { + "device": null, + "host": null, + "interval": 10, + "metric": "hello.dog", + "points": [ + [ + "", + [ + 1.0 + ] + ] + ], + "tags": [ + "dd_lambda_layer:datadog-_", + "role:hello", + "service:integration-tests-python", + "team:serverless" + ], + "type": "distribution" + }, + { + "device": null, + "host": null, + "interval": 10, + "metric": "tests.integration.count", + "points": [ + [ + "", + [ + 21.0 + ] + ] + ], + "tags": [ + "dd_lambda_layer:datadog-_", + "role:hello", + "service:integration-tests-python", + "test:integration" + ], + "type": "distribution" + } + ] + }, + "headers": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate, zstd", + "Connection": "keep-alive", + "Content-Encoding": "deflate", + "Content-Length": "", + "Content-Type": "application/json", + "DD-API-KEY": "", + "User-Agent": "datadogpy/X (python X; os linux; arch )", + "traceparent": "00---01", + "tracestate": "dd=p:;s:1;t.dm:-0;t.tid:,ot=rv:;th:0", + "x-datadog-parent-id": "", + "x-datadog-sampling-priority": "1", + "x-datadog-tags": "_dd.p.dm=-0,_dd.p.tid=", + "x-datadog-trace-id": "" + }, + "method": "POST", + "url": "https://api.datadoghq.com/api/v1/distribution_points" + } +] diff --git a/tests/integration/expected/requests/python315/sync-metrics/appsync.json b/tests/integration/expected/requests/python315/sync-metrics/appsync.json new file mode 100644 index 00000000..38c895b0 --- /dev/null +++ b/tests/integration/expected/requests/python315/sync-metrics/appsync.json @@ -0,0 +1,100 @@ +[ + { + "data": {}, + "headers": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate, zstd", + "Connection": "keep-alive", + "User-Agent": "python-requests/X", + "traceparent": "00---01", + "tracestate": "dd=p:;s:1", + "x-datadog-parent-id": "", + "x-datadog-sampling-priority": "1", + "x-datadog-trace-id": "" + }, + "method": "GET", + "url": "https://datadoghq.com/" + }, + { + "data": {}, + "headers": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate, zstd", + "Connection": "keep-alive", + "User-Agent": "python-requests/X", + "traceparent": "00---01", + "tracestate": "dd=p:;s:1", + "x-datadog-parent-id": "", + "x-datadog-sampling-priority": "1", + "x-datadog-trace-id": "" + }, + "method": "GET", + "url": "https://www.datadoghq.com/" + }, + { + "data": { + "series": [ + { + "device": null, + "host": null, + "interval": 10, + "metric": "hello.dog", + "points": [ + [ + "", + [ + 1.0 + ] + ] + ], + "tags": [ + "dd_lambda_layer:datadog-_", + "role:hello", + "service:integration-tests-python", + "team:serverless" + ], + "type": "distribution" + }, + { + "device": null, + "host": null, + "interval": 10, + "metric": "tests.integration.count", + "points": [ + [ + "", + [ + 21.0 + ] + ] + ], + "tags": [ + "dd_lambda_layer:datadog-_", + "role:hello", + "service:integration-tests-python", + "test:integration" + ], + "type": "distribution" + } + ] + }, + "headers": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate, zstd", + "Connection": "keep-alive", + "Content-Encoding": "deflate", + "Content-Length": "", + "Content-Type": "application/json", + "DD-API-KEY": "", + "User-Agent": "datadogpy/X (python X; os linux; arch )", + "traceparent": "00---01", + "tracestate": "dd=p:;s:1;t.dm:-0;t.tid:,ot=rv:;th:0", + "x-datadog-parent-id": "", + "x-datadog-sampling-priority": "1", + "x-datadog-tags": "_dd.p.dm=-0,_dd.p.tid=", + "x-datadog-trace-id": "" + }, + "method": "POST", + "url": "https://api.datadoghq.com/api/v1/distribution_points" + } +] diff --git a/tests/integration/expected/requests/python38/async-metrics.json b/tests/integration/expected/requests/python38/async-metrics.json new file mode 100644 index 00000000..0e4d4e2b --- /dev/null +++ b/tests/integration/expected/requests/python38/async-metrics.json @@ -0,0 +1,36 @@ +[ + { + "data": {}, + "headers": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "python-requests/X", + "traceparent": "00---01", + "tracestate": "dd=p:;s:1;t.dm:-0;t.tid:", + "x-datadog-parent-id": "", + "x-datadog-sampling-priority": "1", + "x-datadog-tags": "_dd.p.dm=-0,_dd.p.tid=", + "x-datadog-trace-id": "" + }, + "method": "GET", + "url": "https://datadoghq.com/" + }, + { + "data": {}, + "headers": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "python-requests/X", + "traceparent": "00---01", + "tracestate": "dd=p:;s:1;t.dm:-0;t.tid:", + "x-datadog-parent-id": "", + "x-datadog-sampling-priority": "1", + "x-datadog-tags": "_dd.p.dm=-0,_dd.p.tid=", + "x-datadog-trace-id": "" + }, + "method": "GET", + "url": "https://www.datadoghq.com/" + } +] diff --git a/tests/integration/expected/requests/python38/sync-metrics.json b/tests/integration/expected/requests/python38/sync-metrics.json new file mode 100644 index 00000000..a6525d91 --- /dev/null +++ b/tests/integration/expected/requests/python38/sync-metrics.json @@ -0,0 +1,102 @@ +[ + { + "data": {}, + "headers": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "python-requests/X", + "traceparent": "00---01", + "tracestate": "dd=p:;s:1;t.dm:-0;t.tid:", + "x-datadog-parent-id": "", + "x-datadog-sampling-priority": "1", + "x-datadog-tags": "_dd.p.dm=-0,_dd.p.tid=", + "x-datadog-trace-id": "" + }, + "method": "GET", + "url": "https://datadoghq.com/" + }, + { + "data": {}, + "headers": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "python-requests/X", + "traceparent": "00---01", + "tracestate": "dd=p:;s:1;t.dm:-0;t.tid:", + "x-datadog-parent-id": "", + "x-datadog-sampling-priority": "1", + "x-datadog-tags": "_dd.p.dm=-0,_dd.p.tid=", + "x-datadog-trace-id": "" + }, + "method": "GET", + "url": "https://www.datadoghq.com/" + }, + { + "data": { + "series": [ + { + "device": null, + "host": null, + "interval": 10, + "metric": "hello.dog", + "points": [ + [ + "", + [ + 1.0 + ] + ] + ], + "tags": [ + "dd_lambda_layer:datadog-_", + "role:hello", + "service:integration-tests-python", + "team:serverless" + ], + "type": "distribution" + }, + { + "device": null, + "host": null, + "interval": 10, + "metric": "tests.integration.count", + "points": [ + [ + "", + [ + 21.0 + ] + ] + ], + "tags": [ + "dd_lambda_layer:datadog-_", + "role:hello", + "service:integration-tests-python", + "test:integration" + ], + "type": "distribution" + } + ] + }, + "headers": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Content-Encoding": "deflate", + "Content-Length": "", + "Content-Type": "application/json", + "DD-API-KEY": "", + "User-Agent": "datadogpy/X (python X; os linux; arch )", + "traceparent": "00---01", + "tracestate": "dd=p:;s:1;t.dm:-0;t.tid:", + "x-datadog-parent-id": "", + "x-datadog-sampling-priority": "1", + "x-datadog-tags": "_dd.p.dm=-0,_dd.p.tid=", + "x-datadog-trace-id": "" + }, + "method": "POST", + "url": "https://api.datadoghq.com/api/v1/distribution_points" + } +] diff --git a/tests/integration/expected/requests/python38/sync-metrics/appsync.json b/tests/integration/expected/requests/python38/sync-metrics/appsync.json new file mode 100644 index 00000000..75dc98b4 --- /dev/null +++ b/tests/integration/expected/requests/python38/sync-metrics/appsync.json @@ -0,0 +1,100 @@ +[ + { + "data": {}, + "headers": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "python-requests/X", + "traceparent": "00---01", + "tracestate": "dd=p:;s:1", + "x-datadog-parent-id": "", + "x-datadog-sampling-priority": "1", + "x-datadog-trace-id": "" + }, + "method": "GET", + "url": "https://datadoghq.com/" + }, + { + "data": {}, + "headers": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "python-requests/X", + "traceparent": "00---01", + "tracestate": "dd=p:;s:1", + "x-datadog-parent-id": "", + "x-datadog-sampling-priority": "1", + "x-datadog-trace-id": "" + }, + "method": "GET", + "url": "https://www.datadoghq.com/" + }, + { + "data": { + "series": [ + { + "device": null, + "host": null, + "interval": 10, + "metric": "hello.dog", + "points": [ + [ + "", + [ + 1.0 + ] + ] + ], + "tags": [ + "dd_lambda_layer:datadog-_", + "role:hello", + "service:integration-tests-python", + "team:serverless" + ], + "type": "distribution" + }, + { + "device": null, + "host": null, + "interval": 10, + "metric": "tests.integration.count", + "points": [ + [ + "", + [ + 21.0 + ] + ] + ], + "tags": [ + "dd_lambda_layer:datadog-_", + "role:hello", + "service:integration-tests-python", + "test:integration" + ], + "type": "distribution" + } + ] + }, + "headers": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Content-Encoding": "deflate", + "Content-Length": "", + "Content-Type": "application/json", + "DD-API-KEY": "", + "User-Agent": "datadogpy/X (python X; os linux; arch )", + "traceparent": "00---01", + "tracestate": "dd=p:;s:1;t.dm:-0;t.tid:", + "x-datadog-parent-id": "", + "x-datadog-sampling-priority": "1", + "x-datadog-tags": "_dd.p.dm=-0,_dd.p.tid=", + "x-datadog-trace-id": "" + }, + "method": "POST", + "url": "https://api.datadoghq.com/api/v1/distribution_points" + } +] diff --git a/tests/integration/expected/spans/default/async-metrics/api-gateway-get.json b/tests/integration/expected/spans/default/async-metrics/api-gateway-get.json new file mode 100644 index 00000000..2a10abb3 --- /dev/null +++ b/tests/integration/expected/spans/default/async-metrics/api-gateway-get.json @@ -0,0 +1,128 @@ +[ + { + "error": 0, + "label": "aws.apigateway GET / https://70ixmpl4fl.execute-api.us-east-2.amazonaws.com/", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.p.dm": "-0", + "_dd.p.tid": "", + "_dd.peer.service.source": "peer.service", + "_dd.svc_src": "m", + "_dd.tags.process": "entrypoint.basedir:runtime,entrypoint.name:bootstrap,entrypoint.type:script,entrypoint.workdir:task,svc.user:true", + "_inferred_span.synchronicity": "sync", + "_inferred_span.tag_source": "self", + "apiid": "70ixmpl4fl", + "apiname": "70ixmpl4fl", + "dd_resource_key": "arn:aws:apigateway:eu-west-1::/restapis/70ixmpl4fl/stages/Prod", + "endpoint": "/", + "http.method": "GET", + "http.route": "/", + "http.status_code": "200", + "http.url": "https://70ixmpl4fl.execute-api.us-east-2.amazonaws.com/", + "http.useragent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36", + "language": "python", + "peer.service": "integration-tests-python", + "request_id": "", + "resource_names": "GET /", + "runtime-id": "", + "span.kind": "server", + "stage": "Prod" + }, + "metrics": { + "_dd._inferred_span": 1.0, + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "aws.apigateway", + "parent": null, + "resource": "GET /", + "service": "70ixmpl4fl.execute-api.us-east-2.amazonaws.com", + "type": "web" + }, + { + "error": 0, + "label": "aws.lambda https://70ixmpl4fl.execute-api.us-east-2.amazonaws.com/Prod/", + "meta": { + "_dd.origin": "lambda", + "_dd.svc_src": "m", + "cold_start": "true", + "datadog_lambda": "", + "dd_trace": "", + "function_arn": "arn:aws:lambda:eu-west-1::function:", + "function_trigger.event_source": "api-gateway", + "function_trigger.event_source_arn": "arn:aws:apigateway:eu-west-1::/restapis/70ixmpl4fl/stages/Prod", + "function_version": "$LATEST", + "functionname": "", + "http.method": "GET", + "http.route": "/", + "http.status_code": "200", + "http.url": "https://70ixmpl4fl.execute-api.us-east-2.amazonaws.com/Prod/", + "request_id": "", + "resource_names": "", + "span.kind": "server", + "span.name": "aws.lambda" + }, + "metrics": { + "_dd.top_level": 1 + }, + "name": "aws.lambda", + "parent": "aws.apigateway GET / https://70ixmpl4fl.execute-api.us-east-2.amazonaws.com/", + "resource": "", + "service": "integration-tests-python", + "type": "serverless" + }, + { + "error": 0, + "label": "requests.request GET / https://datadoghq.com/", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.svc_src": "requests", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.status_msg": "OK", + "http.url": "https://datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1 + }, + "name": "requests.request", + "parent": "aws.lambda https://70ixmpl4fl.execute-api.us-east-2.amazonaws.com/Prod/", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request GET / https://www.datadoghq.com/", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.p.tid": "", + "_dd.svc_src": "requests", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.status_msg": "OK", + "http.url": "https://www.datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "www.datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1 + }, + "name": "requests.request", + "parent": "requests.request GET / https://datadoghq.com/", + "resource": "GET /", + "service": "requests", + "type": "http" + } +] diff --git a/tests/integration/expected/spans/default/async-metrics/appsync.json b/tests/integration/expected/spans/default/async-metrics/appsync.json new file mode 100644 index 00000000..fe6a0878 --- /dev/null +++ b/tests/integration/expected/spans/default/async-metrics/appsync.json @@ -0,0 +1,84 @@ +[ + { + "error": 0, + "label": "aws.lambda ", + "meta": { + "_dd.origin": "lambda", + "_dd.svc_src": "m", + "_dd.tags.process": "entrypoint.basedir:runtime,entrypoint.name:bootstrap,entrypoint.type:script,entrypoint.workdir:task,svc.user:true", + "cold_start": "false", + "datadog_lambda": "", + "dd_trace": "", + "function_arn": "arn:aws:lambda:eu-west-1::function:", + "function_version": "$LATEST", + "functionname": "", + "language": "python", + "request_id": "", + "resource_names": "", + "runtime-id": "", + "span.kind": "server", + "span.name": "aws.lambda" + }, + "metrics": { + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "aws.lambda", + "parent": null, + "resource": "", + "service": "integration-tests-python", + "type": "serverless" + }, + { + "error": 0, + "label": "requests.request GET / https://datadoghq.com/", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.svc_src": "requests", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.status_msg": "OK", + "http.url": "https://datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1 + }, + "name": "requests.request", + "parent": "aws.lambda ", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request GET / https://www.datadoghq.com/", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.svc_src": "requests", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.status_msg": "OK", + "http.url": "https://www.datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "www.datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1 + }, + "name": "requests.request", + "parent": "requests.request GET / https://datadoghq.com/", + "resource": "GET /", + "service": "requests", + "type": "http" + } +] diff --git a/tests/integration/expected/spans/default/async-metrics/dynamodb.json b/tests/integration/expected/spans/default/async-metrics/dynamodb.json new file mode 100644 index 00000000..1e0a9207 --- /dev/null +++ b/tests/integration/expected/spans/default/async-metrics/dynamodb.json @@ -0,0 +1,154 @@ +[ + { + "error": 0, + "label": "aws.dynamodb ExampleTableWithStream", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.p.dm": "-0", + "_dd.p.tid": "", + "_dd.peer.service.source": "peer.service", + "_dd.svc_src": "m", + "_dd.tags.process": "entrypoint.basedir:runtime,entrypoint.name:bootstrap,entrypoint.type:script,entrypoint.workdir:task,svc.user:true", + "_inferred_span.synchronicity": "async", + "_inferred_span.tag_source": "self", + "dd_resource_key": "arn:aws:dynamodb:us-east-1:123456789012:table/ExampleTableWithStream/stream/2015-06-27T00:48:05.899", + "event_id": "c4ca4238a0b923820dcc509a6f75849b", + "event_name": "INSERT", + "event_source_arn": "arn:aws:dynamodb:us-east-1:123456789012:table/ExampleTableWithStream/stream/2015-06-27T00:48:05.899", + "event_version": "1.1", + "language": "python", + "operation_name": "aws.dynamodb", + "peer.service": "integration-tests-python", + "resource_names": "ExampleTableWithStream", + "runtime-id": "", + "size_bytes": "26", + "span.kind": "server", + "stream_view_type": "NEW_AND_OLD_IMAGES", + "tablename": "ExampleTableWithStream" + }, + "metrics": { + "_dd._inferred_span": 1.0, + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "aws.dynamodb", + "parent": null, + "resource": "ExampleTableWithStream", + "service": "ExampleTableWithStream", + "span_links": [ + { + "attributes": { + "link.kind": "span-pointer", + "ptr.dir": "u", + "ptr.hash": "e2af34d333891f765c7f02d2da80895e", + "ptr.kind": "aws.dynamodb.item" + }, + "span_id": "0000000000000000", + "trace_id": "00000000000000000000000000000000" + }, + { + "attributes": { + "link.kind": "span-pointer", + "ptr.dir": "u", + "ptr.hash": "e2af34d333891f765c7f02d2da80895e", + "ptr.kind": "aws.dynamodb.item" + }, + "span_id": "0000000000000000", + "trace_id": "00000000000000000000000000000000" + }, + { + "attributes": { + "link.kind": "span-pointer", + "ptr.dir": "u", + "ptr.hash": "e2af34d333891f765c7f02d2da80895e", + "ptr.kind": "aws.dynamodb.item" + }, + "span_id": "0000000000000000", + "trace_id": "00000000000000000000000000000000" + } + ], + "type": "web" + }, + { + "error": 0, + "label": "aws.lambda ", + "meta": { + "_dd.origin": "lambda", + "_dd.svc_src": "m", + "cold_start": "false", + "datadog_lambda": "", + "dd_trace": "", + "function_arn": "arn:aws:lambda:eu-west-1::function:", + "function_trigger.event_source": "dynamodb", + "function_trigger.event_source_arn": "arn:aws:dynamodb:us-east-1:123456789012:table/ExampleTableWithStream/stream/2015-06-27T00:48:05.899", + "function_version": "$LATEST", + "functionname": "", + "request_id": "", + "resource_names": "", + "span.kind": "server", + "span.name": "aws.lambda" + }, + "metrics": { + "_dd.top_level": 1 + }, + "name": "aws.lambda", + "parent": "aws.dynamodb ExampleTableWithStream", + "resource": "", + "service": "integration-tests-python", + "type": "serverless" + }, + { + "error": 0, + "label": "requests.request GET / https://datadoghq.com/", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.svc_src": "requests", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.status_msg": "OK", + "http.url": "https://datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1 + }, + "name": "requests.request", + "parent": "aws.lambda ", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request GET / https://www.datadoghq.com/", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.p.tid": "", + "_dd.svc_src": "requests", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.status_msg": "OK", + "http.url": "https://www.datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "www.datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1 + }, + "name": "requests.request", + "parent": "requests.request GET / https://datadoghq.com/", + "resource": "GET /", + "service": "requests", + "type": "http" + } +] diff --git a/tests/integration/expected/spans/default/async-metrics/eventbridge-custom.json b/tests/integration/expected/spans/default/async-metrics/eventbridge-custom.json new file mode 100644 index 00000000..434872a6 --- /dev/null +++ b/tests/integration/expected/spans/default/async-metrics/eventbridge-custom.json @@ -0,0 +1,114 @@ +[ + { + "error": 0, + "label": "aws.eventbridge eventbridge.custom.event.sender", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.p.dm": "-0", + "_dd.p.tid": "", + "_dd.peer.service.source": "peer.service", + "_dd.svc_src": "m", + "_dd.tags.process": "entrypoint.basedir:runtime,entrypoint.name:bootstrap,entrypoint.type:script,entrypoint.workdir:task,svc.user:true", + "_inferred_span.synchronicity": "async", + "_inferred_span.tag_source": "self", + "detail_type": "testdetail", + "language": "python", + "operation_name": "aws.eventbridge", + "peer.service": "integration-tests-python", + "resource_names": "eventbridge.custom.event.sender", + "runtime-id": "", + "span.kind": "server" + }, + "metrics": { + "_dd._inferred_span": 1.0, + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "aws.eventbridge", + "parent": null, + "resource": "eventbridge.custom.event.sender", + "service": "eventbridge.custom.event.sender", + "type": "web" + }, + { + "error": 0, + "label": "aws.lambda ", + "meta": { + "_dd.origin": "lambda", + "_dd.svc_src": "m", + "cold_start": "false", + "datadog_lambda": "", + "dd_trace": "", + "function_arn": "arn:aws:lambda:eu-west-1::function:", + "function_trigger.event_source": "eventbridge", + "function_version": "$LATEST", + "functionname": "", + "request_id": "", + "resource_names": "", + "span.kind": "server", + "span.name": "aws.lambda" + }, + "metrics": { + "_dd.top_level": 1 + }, + "name": "aws.lambda", + "parent": "aws.eventbridge eventbridge.custom.event.sender", + "resource": "", + "service": "integration-tests-python", + "type": "serverless" + }, + { + "error": 0, + "label": "requests.request GET / https://datadoghq.com/", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.svc_src": "requests", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.status_msg": "OK", + "http.url": "https://datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1 + }, + "name": "requests.request", + "parent": "aws.lambda ", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request GET / https://www.datadoghq.com/", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.p.tid": "", + "_dd.svc_src": "requests", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.status_msg": "OK", + "http.url": "https://www.datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "www.datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1 + }, + "name": "requests.request", + "parent": "requests.request GET / https://datadoghq.com/", + "resource": "GET /", + "service": "requests", + "type": "http" + } +] diff --git a/tests/integration/expected/spans/default/async-metrics/http-api.json b/tests/integration/expected/spans/default/async-metrics/http-api.json new file mode 100644 index 00000000..0b9b001a --- /dev/null +++ b/tests/integration/expected/spans/default/async-metrics/http-api.json @@ -0,0 +1,129 @@ +[ + { + "error": 0, + "label": "aws.httpapi GET /httpapi/get https://x02yirxc7a.execute-api.eu-west-1.amazonaws.com/httpapi/get", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.p.dm": "-0", + "_dd.p.tid": "", + "_dd.peer.service.source": "peer.service", + "_dd.svc_src": "m", + "_dd.tags.process": "entrypoint.basedir:runtime,entrypoint.name:bootstrap,entrypoint.type:script,entrypoint.workdir:task,svc.user:true", + "_inferred_span.synchronicity": "sync", + "_inferred_span.tag_source": "self", + "apiid": "x02yirxc7a", + "apiname": "x02yirxc7a", + "dd_resource_key": "arn:aws:apigateway:eu-west-1::/restapis/x02yirxc7a/stages/$default", + "endpoint": "/httpapi/get", + "http.method": "GET", + "http.protocol": "HTTP/1.1", + "http.route": "/httpapi/get", + "http.source_ip": "38.122.226.210", + "http.status_code": "200", + "http.url": "https://x02yirxc7a.execute-api.eu-west-1.amazonaws.com/httpapi/get", + "http.useragent": "curl/7.64.1", + "language": "python", + "peer.service": "integration-tests-python", + "request_id": "", + "resource_names": "GET /httpapi/get", + "runtime-id": "", + "stage": "$default" + }, + "metrics": { + "_dd._inferred_span": 1.0, + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "aws.httpapi", + "parent": null, + "resource": "GET /httpapi/get", + "service": "x02yirxc7a.execute-api.eu-west-1.amazonaws.com", + "type": "web" + }, + { + "error": 0, + "label": "aws.lambda https://x02yirxc7a.execute-api.eu-west-1.amazonaws.com/httpapi/get", + "meta": { + "_dd.origin": "lambda", + "_dd.svc_src": "m", + "cold_start": "false", + "datadog_lambda": "", + "dd_trace": "", + "function_arn": "arn:aws:lambda:eu-west-1::function:", + "function_trigger.event_source": "api-gateway", + "function_trigger.event_source_arn": "arn:aws:apigateway:eu-west-1::/restapis/x02yirxc7a/stages/$default", + "function_version": "$LATEST", + "functionname": "", + "http.method": "GET", + "http.route": "/httpapi/get", + "http.status_code": "200", + "http.url": "https://x02yirxc7a.execute-api.eu-west-1.amazonaws.com/httpapi/get", + "request_id": "", + "resource_names": "", + "span.kind": "server", + "span.name": "aws.lambda" + }, + "metrics": { + "_dd.top_level": 1 + }, + "name": "aws.lambda", + "parent": "aws.httpapi GET /httpapi/get https://x02yirxc7a.execute-api.eu-west-1.amazonaws.com/httpapi/get", + "resource": "", + "service": "integration-tests-python", + "type": "serverless" + }, + { + "error": 0, + "label": "requests.request GET / https://datadoghq.com/", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.svc_src": "requests", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.status_msg": "OK", + "http.url": "https://datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1 + }, + "name": "requests.request", + "parent": "aws.lambda https://x02yirxc7a.execute-api.eu-west-1.amazonaws.com/httpapi/get", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request GET / https://www.datadoghq.com/", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.p.tid": "", + "_dd.svc_src": "requests", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.status_msg": "OK", + "http.url": "https://www.datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "www.datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1 + }, + "name": "requests.request", + "parent": "requests.request GET / https://datadoghq.com/", + "resource": "GET /", + "service": "requests", + "type": "http" + } +] diff --git a/tests/integration/expected/spans/default/async-metrics/kinesis.json b/tests/integration/expected/spans/default/async-metrics/kinesis.json new file mode 100644 index 00000000..a50e0fb1 --- /dev/null +++ b/tests/integration/expected/spans/default/async-metrics/kinesis.json @@ -0,0 +1,122 @@ +[ + { + "error": 0, + "label": "aws.kinesis EXAMPLE", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.p.dm": "-0", + "_dd.p.tid": "", + "_dd.peer.service.source": "peer.service", + "_dd.svc_src": "m", + "_dd.tags.process": "entrypoint.basedir:runtime,entrypoint.name:bootstrap,entrypoint.type:script,entrypoint.workdir:task,svc.user:true", + "_inferred_span.synchronicity": "async", + "_inferred_span.tag_source": "self", + "dd_resource_key": "arn:aws:kinesis:EXAMPLE", + "event_id": "shardId-000000000000:49545115243490985018280067714973144582180062593244200961", + "event_name": "aws:kinesis:record", + "event_source_arn": "arn:aws:kinesis:EXAMPLE", + "event_version": "1.0", + "language": "python", + "operation_name": "aws.kinesis", + "partition_key": "partitionKey-03", + "peer.service": "integration-tests-python", + "resource_names": "EXAMPLE", + "runtime-id": "", + "shardid": "shardId-000000000000", + "span.kind": "server", + "streamname": "EXAMPLE" + }, + "metrics": { + "_dd._inferred_span": 1.0, + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "aws.kinesis", + "parent": null, + "resource": "EXAMPLE", + "service": "EXAMPLE", + "type": "web" + }, + { + "error": 0, + "label": "aws.lambda ", + "meta": { + "_dd.origin": "lambda", + "_dd.svc_src": "m", + "cold_start": "false", + "datadog_lambda": "", + "dd_trace": "", + "function_arn": "arn:aws:lambda:eu-west-1::function:", + "function_trigger.event_source": "kinesis", + "function_trigger.event_source_arn": "arn:aws:kinesis:EXAMPLE", + "function_version": "$LATEST", + "functionname": "", + "request_id": "", + "resource_names": "", + "span.kind": "server", + "span.name": "aws.lambda" + }, + "metrics": { + "_dd.top_level": 1 + }, + "name": "aws.lambda", + "parent": "aws.kinesis EXAMPLE", + "resource": "", + "service": "integration-tests-python", + "type": "serverless" + }, + { + "error": 0, + "label": "requests.request GET / https://datadoghq.com/", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.svc_src": "requests", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.status_msg": "OK", + "http.url": "https://datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1 + }, + "name": "requests.request", + "parent": "aws.lambda ", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request GET / https://www.datadoghq.com/", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.p.tid": "", + "_dd.svc_src": "requests", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.status_msg": "OK", + "http.url": "https://www.datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "www.datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1 + }, + "name": "requests.request", + "parent": "requests.request GET / https://datadoghq.com/", + "resource": "GET /", + "service": "requests", + "type": "http" + } +] diff --git a/tests/integration/expected/spans/default/async-metrics/s3.json b/tests/integration/expected/spans/default/async-metrics/s3.json new file mode 100644 index 00000000..dd46eb6d --- /dev/null +++ b/tests/integration/expected/spans/default/async-metrics/s3.json @@ -0,0 +1,133 @@ +[ + { + "error": 0, + "label": "aws.lambda ", + "meta": { + "_dd.origin": "lambda", + "_dd.svc_src": "m", + "cold_start": "false", + "datadog_lambda": "", + "dd_trace": "", + "function_arn": "arn:aws:lambda:eu-west-1::function:", + "function_trigger.event_source": "s3", + "function_trigger.event_source_arn": "arn:aws:s3:::example-bucket", + "function_version": "$LATEST", + "functionname": "", + "request_id": "", + "resource_names": "", + "span.kind": "server", + "span.name": "aws.lambda" + }, + "metrics": { + "_dd.top_level": 1 + }, + "name": "aws.lambda", + "parent": "aws.s3 example-bucket", + "resource": "", + "service": "integration-tests-python", + "type": "serverless" + }, + { + "error": 0, + "label": "aws.s3 example-bucket", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.p.dm": "-0", + "_dd.p.tid": "", + "_dd.peer.service.source": "peer.service", + "_dd.svc_src": "m", + "_dd.tags.process": "entrypoint.basedir:runtime,entrypoint.name:bootstrap,entrypoint.type:script,entrypoint.workdir:task,svc.user:true", + "_inferred_span.synchronicity": "async", + "_inferred_span.tag_source": "self", + "bucket_arn": "arn:aws:s3:::example-bucket", + "bucketname": "example-bucket", + "dd_resource_key": "arn:aws:s3:::example-bucket", + "event_name": "ObjectCreated:Put", + "language": "python", + "object_etag": "0123456789abcdef0123456789abcdef", + "object_key": "test/key", + "object_size": "1024", + "operation_name": "aws.s3", + "peer.service": "integration-tests-python", + "resource_names": "example-bucket", + "runtime-id": "", + "span.kind": "server" + }, + "metrics": { + "_dd._inferred_span": 1.0, + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "aws.s3", + "parent": null, + "resource": "example-bucket", + "service": "example-bucket", + "span_links": [ + { + "attributes": { + "link.kind": "span-pointer", + "ptr.dir": "u", + "ptr.hash": "1dc3e5d00dae48c1f07d95371a747788", + "ptr.kind": "aws.s3.object" + }, + "span_id": "0000000000000000", + "trace_id": "00000000000000000000000000000000" + } + ], + "type": "web" + }, + { + "error": 0, + "label": "requests.request GET / https://datadoghq.com/", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.svc_src": "requests", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.status_msg": "OK", + "http.url": "https://datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1 + }, + "name": "requests.request", + "parent": "aws.lambda ", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request GET / https://www.datadoghq.com/", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.p.tid": "", + "_dd.svc_src": "requests", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.status_msg": "OK", + "http.url": "https://www.datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "www.datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1 + }, + "name": "requests.request", + "parent": "requests.request GET / https://datadoghq.com/", + "resource": "GET /", + "service": "requests", + "type": "http" + } +] diff --git a/tests/integration/expected/spans/default/async-metrics/sns.json b/tests/integration/expected/spans/default/async-metrics/sns.json new file mode 100644 index 00000000..3313f6e1 --- /dev/null +++ b/tests/integration/expected/spans/default/async-metrics/sns.json @@ -0,0 +1,120 @@ +[ + { + "error": 0, + "label": "aws.lambda ", + "meta": { + "_dd.origin": "lambda", + "_dd.svc_src": "m", + "cold_start": "false", + "datadog_lambda": "", + "dd_trace": "", + "function_arn": "arn:aws:lambda:eu-west-1::function:", + "function_trigger.event_source": "sns", + "function_trigger.event_source_arn": "arn:aws:sns:us-east-2:123456789012:sns-lambda", + "function_version": "$LATEST", + "functionname": "", + "request_id": "", + "resource_names": "", + "span.kind": "server", + "span.name": "aws.lambda" + }, + "metrics": { + "_dd.top_level": 1 + }, + "name": "aws.lambda", + "parent": "aws.sns sns-lambda", + "resource": "", + "service": "integration-tests-python", + "type": "serverless" + }, + { + "error": 0, + "label": "aws.sns sns-lambda", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.p.dm": "-0", + "_dd.p.tid": "", + "_dd.peer.service.source": "peer.service", + "_dd.svc_src": "m", + "_dd.tags.process": "entrypoint.basedir:runtime,entrypoint.name:bootstrap,entrypoint.type:script,entrypoint.workdir:task,svc.user:true", + "_inferred_span.synchronicity": "async", + "_inferred_span.tag_source": "self", + "dd_resource_key": "arn:aws:sns:us-east-2:123456789012:sns-lambda", + "language": "python", + "message_id": "95df01b4-ee98-5cb9-9903-4c221d41eb5e", + "operation_name": "aws.sns", + "peer.service": "integration-tests-python", + "resource_names": "sns-lambda", + "runtime-id": "", + "span.kind": "server", + "subject": "TestInvoke", + "topic_arn": "arn:aws:sns:us-east-2:123456789012:sns-lambda", + "topicname": "sns-lambda", + "type": "Notification" + }, + "metrics": { + "_dd._inferred_span": 1.0, + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "aws.sns", + "parent": null, + "resource": "sns-lambda", + "service": "sns-lambda", + "type": "web" + }, + { + "error": 0, + "label": "requests.request GET / https://datadoghq.com/", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.svc_src": "requests", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.status_msg": "OK", + "http.url": "https://datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1 + }, + "name": "requests.request", + "parent": "aws.lambda ", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request GET / https://www.datadoghq.com/", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.p.tid": "", + "_dd.svc_src": "requests", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.status_msg": "OK", + "http.url": "https://www.datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "www.datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1 + }, + "name": "requests.request", + "parent": "requests.request GET / https://datadoghq.com/", + "resource": "GET /", + "service": "requests", + "type": "http" + } +] diff --git a/tests/integration/expected/spans/default/async-metrics/sqs.json b/tests/integration/expected/spans/default/async-metrics/sqs.json new file mode 100644 index 00000000..1d8a7d70 --- /dev/null +++ b/tests/integration/expected/spans/default/async-metrics/sqs.json @@ -0,0 +1,119 @@ +[ + { + "error": 0, + "label": "aws.lambda ", + "meta": { + "_dd.origin": "lambda", + "_dd.svc_src": "m", + "cold_start": "false", + "datadog_lambda": "", + "dd_trace": "", + "function_arn": "arn:aws:lambda:eu-west-1::function:", + "function_trigger.event_source": "sqs", + "function_trigger.event_source_arn": "arn:aws:sqs:us-east-2:123456789012:my-queue", + "function_version": "$LATEST", + "functionname": "", + "request_id": "", + "resource_names": "", + "span.kind": "server", + "span.name": "aws.lambda" + }, + "metrics": { + "_dd.top_level": 1 + }, + "name": "aws.lambda", + "parent": "aws.sqs my-queue", + "resource": "", + "service": "integration-tests-python", + "type": "serverless" + }, + { + "error": 0, + "label": "aws.sqs my-queue", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.p.dm": "-0", + "_dd.p.tid": "", + "_dd.peer.service.source": "peer.service", + "_dd.svc_src": "m", + "_dd.tags.process": "entrypoint.basedir:runtime,entrypoint.name:bootstrap,entrypoint.type:script,entrypoint.workdir:task,svc.user:true", + "_inferred_span.synchronicity": "async", + "_inferred_span.tag_source": "self", + "dd_resource_key": "arn:aws:sqs:us-east-2:123456789012:my-queue", + "event_source_arn": "arn:aws:sqs:us-east-2:123456789012:my-queue", + "language": "python", + "operation_name": "aws.sqs", + "peer.service": "integration-tests-python", + "queuename": "my-queue", + "receipt_handle": "AQEBwJnKyrHigUMZj6rYigCgxlaS3SLy0a...", + "resource_names": "my-queue", + "runtime-id": "", + "sender_id": "AIDAIENQZJOLO23YVJ4VO", + "span.kind": "server" + }, + "metrics": { + "_dd._inferred_span": 1.0, + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "aws.sqs", + "parent": null, + "resource": "my-queue", + "service": "my-queue", + "type": "web" + }, + { + "error": 0, + "label": "requests.request GET / https://datadoghq.com/", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.svc_src": "requests", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.status_msg": "OK", + "http.url": "https://datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1 + }, + "name": "requests.request", + "parent": "aws.lambda ", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request GET / https://www.datadoghq.com/", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.p.tid": "", + "_dd.svc_src": "requests", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.status_msg": "OK", + "http.url": "https://www.datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "www.datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1 + }, + "name": "requests.request", + "parent": "requests.request GET / https://datadoghq.com/", + "resource": "GET /", + "service": "requests", + "type": "http" + } +] diff --git a/tests/integration/expected/spans/default/async-metrics/websocket.json b/tests/integration/expected/spans/default/async-metrics/websocket.json new file mode 100644 index 00000000..7ec6e3b2 --- /dev/null +++ b/tests/integration/expected/spans/default/async-metrics/websocket.json @@ -0,0 +1,127 @@ +[ + { + "error": 0, + "label": "aws.apigateway.websocket $default https://p62c47itsb.execute-api.eu-west-1.amazonaws.com$default", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.p.dm": "-0", + "_dd.p.tid": "", + "_dd.peer.service.source": "peer.service", + "_dd.svc_src": "m", + "_dd.tags.process": "entrypoint.basedir:runtime,entrypoint.name:bootstrap,entrypoint.type:script,entrypoint.workdir:task,svc.user:true", + "_inferred_span.synchronicity": "sync", + "_inferred_span.tag_source": "self", + "apiid": "p62c47itsb", + "apiname": "p62c47itsb", + "connection_id": "Fc5SzcoYGjQCJlg=", + "dd_resource_key": "arn:aws:apigateway:eu-west-1::/restapis/p62c47itsb/stages/dev", + "endpoint": "$default", + "event_type": "MESSAGE", + "http.status_code": "200", + "http.url": "https://p62c47itsb.execute-api.eu-west-1.amazonaws.com$default", + "language": "python", + "message_direction": "IN", + "operation_name": "aws.apigateway.websocket", + "peer.service": "integration-tests-python", + "request_id": "", + "resource_names": "$default", + "runtime-id": "", + "span.kind": "server", + "stage": "dev" + }, + "metrics": { + "_dd._inferred_span": 1.0, + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "aws.apigateway.websocket", + "parent": null, + "resource": "$default", + "service": "p62c47itsb.execute-api.eu-west-1.amazonaws.com", + "type": "web" + }, + { + "error": 0, + "label": "aws.lambda https://p62c47itsb.execute-api.eu-west-1.amazonaws.com", + "meta": { + "_dd.origin": "lambda", + "_dd.svc_src": "m", + "cold_start": "false", + "datadog_lambda": "", + "dd_trace": "", + "function_arn": "arn:aws:lambda:eu-west-1::function:", + "function_trigger.event_source": "api-gateway", + "function_trigger.event_source_arn": "arn:aws:apigateway:eu-west-1::/restapis/p62c47itsb/stages/dev", + "function_version": "$LATEST", + "functionname": "", + "http.status_code": "200", + "http.url": "https://p62c47itsb.execute-api.eu-west-1.amazonaws.com", + "request_id": "", + "resource_names": "", + "span.kind": "server", + "span.name": "aws.lambda" + }, + "metrics": { + "_dd.top_level": 1 + }, + "name": "aws.lambda", + "parent": "aws.apigateway.websocket $default https://p62c47itsb.execute-api.eu-west-1.amazonaws.com$default", + "resource": "", + "service": "integration-tests-python", + "type": "serverless" + }, + { + "error": 0, + "label": "requests.request GET / https://datadoghq.com/", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.svc_src": "requests", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.status_msg": "OK", + "http.url": "https://datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1 + }, + "name": "requests.request", + "parent": "aws.lambda https://p62c47itsb.execute-api.eu-west-1.amazonaws.com", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request GET / https://www.datadoghq.com/", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.p.tid": "", + "_dd.svc_src": "requests", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.status_msg": "OK", + "http.url": "https://www.datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "www.datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1 + }, + "name": "requests.request", + "parent": "requests.request GET / https://datadoghq.com/", + "resource": "GET /", + "service": "requests", + "type": "http" + } +] diff --git a/tests/integration/expected/spans/default/sync-metrics/api-gateway-get.json b/tests/integration/expected/spans/default/sync-metrics/api-gateway-get.json new file mode 100644 index 00000000..225644ae --- /dev/null +++ b/tests/integration/expected/spans/default/sync-metrics/api-gateway-get.json @@ -0,0 +1,161 @@ +[ + { + "error": 0, + "label": "aws.apigateway GET / https://70ixmpl4fl.execute-api.us-east-2.amazonaws.com/", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.p.dm": "-0", + "_dd.p.tid": "", + "_dd.peer.service.source": "peer.service", + "_dd.svc_src": "m", + "_dd.tags.process": "entrypoint.basedir:runtime,entrypoint.name:bootstrap,entrypoint.type:script,entrypoint.workdir:task,svc.user:true", + "_inferred_span.synchronicity": "sync", + "_inferred_span.tag_source": "self", + "apiid": "70ixmpl4fl", + "apiname": "70ixmpl4fl", + "dd_resource_key": "arn:aws:apigateway:eu-west-1::/restapis/70ixmpl4fl/stages/Prod", + "endpoint": "/", + "http.method": "GET", + "http.route": "/", + "http.status_code": "200", + "http.url": "https://70ixmpl4fl.execute-api.us-east-2.amazonaws.com/", + "http.useragent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36", + "language": "python", + "peer.service": "integration-tests-python", + "request_id": "", + "resource_names": "GET /", + "runtime-id": "", + "span.kind": "server", + "stage": "Prod" + }, + "metrics": { + "_dd._inferred_span": 1.0, + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "aws.apigateway", + "parent": null, + "resource": "GET /", + "service": "70ixmpl4fl.execute-api.us-east-2.amazonaws.com", + "type": "web" + }, + { + "error": 0, + "label": "aws.lambda https://70ixmpl4fl.execute-api.us-east-2.amazonaws.com/Prod/", + "meta": { + "_dd.origin": "lambda", + "_dd.svc_src": "m", + "cold_start": "true", + "datadog_lambda": "", + "dd_trace": "", + "function_arn": "arn:aws:lambda:eu-west-1::function:", + "function_trigger.event_source": "api-gateway", + "function_trigger.event_source_arn": "arn:aws:apigateway:eu-west-1::/restapis/70ixmpl4fl/stages/Prod", + "function_version": "$LATEST", + "functionname": "", + "http.method": "GET", + "http.route": "/", + "http.status_code": "200", + "http.url": "https://70ixmpl4fl.execute-api.us-east-2.amazonaws.com/Prod/", + "request_id": "", + "resource_names": "", + "span.kind": "server", + "span.name": "aws.lambda" + }, + "metrics": { + "_dd.top_level": 1 + }, + "name": "aws.lambda", + "parent": "aws.apigateway GET / https://70ixmpl4fl.execute-api.us-east-2.amazonaws.com/", + "resource": "", + "service": "integration-tests-python", + "type": "serverless" + }, + { + "error": 0, + "label": "requests.request GET / https://datadoghq.com/", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.svc_src": "requests", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.status_msg": "OK", + "http.url": "https://datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1 + }, + "name": "requests.request", + "parent": "aws.lambda https://70ixmpl4fl.execute-api.us-east-2.amazonaws.com/Prod/", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request GET / https://www.datadoghq.com/", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.p.tid": "", + "_dd.svc_src": "requests", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.status_msg": "OK", + "http.url": "https://www.datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "www.datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1 + }, + "name": "requests.request", + "parent": "requests.request GET / https://datadoghq.com/", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request POST /api/v1/distribution_points https://api.datadoghq.com/api/v1/distribution_points", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.p.dm": "-0", + "_dd.p.tid": "", + "_dd.svc_src": "requests", + "_dd.tags.process": "entrypoint.basedir:runtime,entrypoint.name:bootstrap,entrypoint.type:script,entrypoint.workdir:task,svc.user:true", + "component": "requests", + "http.method": "POST", + "http.status_code": "202", + "http.status_msg": "Accepted", + "http.url": "https://api.datadoghq.com/api/v1/distribution_points", + "http.useragent": "datadogpy/X (python X; os linux; arch )", + "language": "python", + "out.host": "api.datadoghq.com", + "runtime-id": "", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "requests.request", + "parent": null, + "resource": "POST /api/v1/distribution_points", + "service": "requests", + "type": "http" + } +] diff --git a/tests/integration/expected/spans/default/sync-metrics/appsync.json b/tests/integration/expected/spans/default/sync-metrics/appsync.json new file mode 100644 index 00000000..81236526 --- /dev/null +++ b/tests/integration/expected/spans/default/sync-metrics/appsync.json @@ -0,0 +1,117 @@ +[ + { + "error": 0, + "label": "aws.lambda ", + "meta": { + "_dd.origin": "lambda", + "_dd.svc_src": "m", + "_dd.tags.process": "entrypoint.basedir:runtime,entrypoint.name:bootstrap,entrypoint.type:script,entrypoint.workdir:task,svc.user:true", + "cold_start": "false", + "datadog_lambda": "", + "dd_trace": "", + "function_arn": "arn:aws:lambda:eu-west-1::function:", + "function_version": "$LATEST", + "functionname": "", + "language": "python", + "request_id": "", + "resource_names": "", + "runtime-id": "", + "span.kind": "server", + "span.name": "aws.lambda" + }, + "metrics": { + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "aws.lambda", + "parent": null, + "resource": "", + "service": "integration-tests-python", + "type": "serverless" + }, + { + "error": 0, + "label": "requests.request GET / https://datadoghq.com/", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.svc_src": "requests", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.status_msg": "OK", + "http.url": "https://datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1 + }, + "name": "requests.request", + "parent": "aws.lambda ", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request GET / https://www.datadoghq.com/", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.svc_src": "requests", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.status_msg": "OK", + "http.url": "https://www.datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "www.datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1 + }, + "name": "requests.request", + "parent": "requests.request GET / https://datadoghq.com/", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request POST /api/v1/distribution_points https://api.datadoghq.com/api/v1/distribution_points", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.p.dm": "-0", + "_dd.p.tid": "", + "_dd.svc_src": "requests", + "_dd.tags.process": "entrypoint.basedir:runtime,entrypoint.name:bootstrap,entrypoint.type:script,entrypoint.workdir:task,svc.user:true", + "component": "requests", + "http.method": "POST", + "http.status_code": "202", + "http.status_msg": "Accepted", + "http.url": "https://api.datadoghq.com/api/v1/distribution_points", + "http.useragent": "datadogpy/X (python X; os linux; arch )", + "language": "python", + "out.host": "api.datadoghq.com", + "runtime-id": "", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "requests.request", + "parent": null, + "resource": "POST /api/v1/distribution_points", + "service": "requests", + "type": "http" + } +] diff --git a/tests/integration/expected/spans/default/sync-metrics/dynamodb.json b/tests/integration/expected/spans/default/sync-metrics/dynamodb.json new file mode 100644 index 00000000..576e7b23 --- /dev/null +++ b/tests/integration/expected/spans/default/sync-metrics/dynamodb.json @@ -0,0 +1,187 @@ +[ + { + "error": 0, + "label": "aws.dynamodb ExampleTableWithStream", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.p.dm": "-0", + "_dd.p.tid": "", + "_dd.peer.service.source": "peer.service", + "_dd.svc_src": "m", + "_dd.tags.process": "entrypoint.basedir:runtime,entrypoint.name:bootstrap,entrypoint.type:script,entrypoint.workdir:task,svc.user:true", + "_inferred_span.synchronicity": "async", + "_inferred_span.tag_source": "self", + "dd_resource_key": "arn:aws:dynamodb:us-east-1:123456789012:table/ExampleTableWithStream/stream/2015-06-27T00:48:05.899", + "event_id": "c4ca4238a0b923820dcc509a6f75849b", + "event_name": "INSERT", + "event_source_arn": "arn:aws:dynamodb:us-east-1:123456789012:table/ExampleTableWithStream/stream/2015-06-27T00:48:05.899", + "event_version": "1.1", + "language": "python", + "operation_name": "aws.dynamodb", + "peer.service": "integration-tests-python", + "resource_names": "ExampleTableWithStream", + "runtime-id": "", + "size_bytes": "26", + "span.kind": "server", + "stream_view_type": "NEW_AND_OLD_IMAGES", + "tablename": "ExampleTableWithStream" + }, + "metrics": { + "_dd._inferred_span": 1.0, + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "aws.dynamodb", + "parent": null, + "resource": "ExampleTableWithStream", + "service": "ExampleTableWithStream", + "span_links": [ + { + "attributes": { + "link.kind": "span-pointer", + "ptr.dir": "u", + "ptr.hash": "e2af34d333891f765c7f02d2da80895e", + "ptr.kind": "aws.dynamodb.item" + }, + "span_id": "0000000000000000", + "trace_id": "00000000000000000000000000000000" + }, + { + "attributes": { + "link.kind": "span-pointer", + "ptr.dir": "u", + "ptr.hash": "e2af34d333891f765c7f02d2da80895e", + "ptr.kind": "aws.dynamodb.item" + }, + "span_id": "0000000000000000", + "trace_id": "00000000000000000000000000000000" + }, + { + "attributes": { + "link.kind": "span-pointer", + "ptr.dir": "u", + "ptr.hash": "e2af34d333891f765c7f02d2da80895e", + "ptr.kind": "aws.dynamodb.item" + }, + "span_id": "0000000000000000", + "trace_id": "00000000000000000000000000000000" + } + ], + "type": "web" + }, + { + "error": 0, + "label": "aws.lambda ", + "meta": { + "_dd.origin": "lambda", + "_dd.svc_src": "m", + "cold_start": "false", + "datadog_lambda": "", + "dd_trace": "", + "function_arn": "arn:aws:lambda:eu-west-1::function:", + "function_trigger.event_source": "dynamodb", + "function_trigger.event_source_arn": "arn:aws:dynamodb:us-east-1:123456789012:table/ExampleTableWithStream/stream/2015-06-27T00:48:05.899", + "function_version": "$LATEST", + "functionname": "", + "request_id": "", + "resource_names": "", + "span.kind": "server", + "span.name": "aws.lambda" + }, + "metrics": { + "_dd.top_level": 1 + }, + "name": "aws.lambda", + "parent": "aws.dynamodb ExampleTableWithStream", + "resource": "", + "service": "integration-tests-python", + "type": "serverless" + }, + { + "error": 0, + "label": "requests.request GET / https://datadoghq.com/", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.svc_src": "requests", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.status_msg": "OK", + "http.url": "https://datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1 + }, + "name": "requests.request", + "parent": "aws.lambda ", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request GET / https://www.datadoghq.com/", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.p.tid": "", + "_dd.svc_src": "requests", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.status_msg": "OK", + "http.url": "https://www.datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "www.datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1 + }, + "name": "requests.request", + "parent": "requests.request GET / https://datadoghq.com/", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request POST /api/v1/distribution_points https://api.datadoghq.com/api/v1/distribution_points", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.p.dm": "-0", + "_dd.p.tid": "", + "_dd.svc_src": "requests", + "_dd.tags.process": "entrypoint.basedir:runtime,entrypoint.name:bootstrap,entrypoint.type:script,entrypoint.workdir:task,svc.user:true", + "component": "requests", + "http.method": "POST", + "http.status_code": "202", + "http.status_msg": "Accepted", + "http.url": "https://api.datadoghq.com/api/v1/distribution_points", + "http.useragent": "datadogpy/X (python X; os linux; arch )", + "language": "python", + "out.host": "api.datadoghq.com", + "runtime-id": "", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "requests.request", + "parent": null, + "resource": "POST /api/v1/distribution_points", + "service": "requests", + "type": "http" + } +] diff --git a/tests/integration/expected/spans/default/sync-metrics/eventbridge-custom.json b/tests/integration/expected/spans/default/sync-metrics/eventbridge-custom.json new file mode 100644 index 00000000..15ac5d79 --- /dev/null +++ b/tests/integration/expected/spans/default/sync-metrics/eventbridge-custom.json @@ -0,0 +1,147 @@ +[ + { + "error": 0, + "label": "aws.eventbridge eventbridge.custom.event.sender", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.p.dm": "-0", + "_dd.p.tid": "", + "_dd.peer.service.source": "peer.service", + "_dd.svc_src": "m", + "_dd.tags.process": "entrypoint.basedir:runtime,entrypoint.name:bootstrap,entrypoint.type:script,entrypoint.workdir:task,svc.user:true", + "_inferred_span.synchronicity": "async", + "_inferred_span.tag_source": "self", + "detail_type": "testdetail", + "language": "python", + "operation_name": "aws.eventbridge", + "peer.service": "integration-tests-python", + "resource_names": "eventbridge.custom.event.sender", + "runtime-id": "", + "span.kind": "server" + }, + "metrics": { + "_dd._inferred_span": 1.0, + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "aws.eventbridge", + "parent": null, + "resource": "eventbridge.custom.event.sender", + "service": "eventbridge.custom.event.sender", + "type": "web" + }, + { + "error": 0, + "label": "aws.lambda ", + "meta": { + "_dd.origin": "lambda", + "_dd.svc_src": "m", + "cold_start": "false", + "datadog_lambda": "", + "dd_trace": "", + "function_arn": "arn:aws:lambda:eu-west-1::function:", + "function_trigger.event_source": "eventbridge", + "function_version": "$LATEST", + "functionname": "", + "request_id": "", + "resource_names": "", + "span.kind": "server", + "span.name": "aws.lambda" + }, + "metrics": { + "_dd.top_level": 1 + }, + "name": "aws.lambda", + "parent": "aws.eventbridge eventbridge.custom.event.sender", + "resource": "", + "service": "integration-tests-python", + "type": "serverless" + }, + { + "error": 0, + "label": "requests.request GET / https://datadoghq.com/", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.svc_src": "requests", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.status_msg": "OK", + "http.url": "https://datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1 + }, + "name": "requests.request", + "parent": "aws.lambda ", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request GET / https://www.datadoghq.com/", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.p.tid": "", + "_dd.svc_src": "requests", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.status_msg": "OK", + "http.url": "https://www.datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "www.datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1 + }, + "name": "requests.request", + "parent": "requests.request GET / https://datadoghq.com/", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request POST /api/v1/distribution_points https://api.datadoghq.com/api/v1/distribution_points", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.p.dm": "-0", + "_dd.p.tid": "", + "_dd.svc_src": "requests", + "_dd.tags.process": "entrypoint.basedir:runtime,entrypoint.name:bootstrap,entrypoint.type:script,entrypoint.workdir:task,svc.user:true", + "component": "requests", + "http.method": "POST", + "http.status_code": "202", + "http.status_msg": "Accepted", + "http.url": "https://api.datadoghq.com/api/v1/distribution_points", + "http.useragent": "datadogpy/X (python X; os linux; arch )", + "language": "python", + "out.host": "api.datadoghq.com", + "runtime-id": "", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "requests.request", + "parent": null, + "resource": "POST /api/v1/distribution_points", + "service": "requests", + "type": "http" + } +] diff --git a/tests/integration/expected/spans/default/sync-metrics/http-api.json b/tests/integration/expected/spans/default/sync-metrics/http-api.json new file mode 100644 index 00000000..df113f5a --- /dev/null +++ b/tests/integration/expected/spans/default/sync-metrics/http-api.json @@ -0,0 +1,162 @@ +[ + { + "error": 0, + "label": "aws.httpapi GET /httpapi/get https://x02yirxc7a.execute-api.eu-west-1.amazonaws.com/httpapi/get", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.p.dm": "-0", + "_dd.p.tid": "", + "_dd.peer.service.source": "peer.service", + "_dd.svc_src": "m", + "_dd.tags.process": "entrypoint.basedir:runtime,entrypoint.name:bootstrap,entrypoint.type:script,entrypoint.workdir:task,svc.user:true", + "_inferred_span.synchronicity": "sync", + "_inferred_span.tag_source": "self", + "apiid": "x02yirxc7a", + "apiname": "x02yirxc7a", + "dd_resource_key": "arn:aws:apigateway:eu-west-1::/restapis/x02yirxc7a/stages/$default", + "endpoint": "/httpapi/get", + "http.method": "GET", + "http.protocol": "HTTP/1.1", + "http.route": "/httpapi/get", + "http.source_ip": "38.122.226.210", + "http.status_code": "200", + "http.url": "https://x02yirxc7a.execute-api.eu-west-1.amazonaws.com/httpapi/get", + "http.useragent": "curl/7.64.1", + "language": "python", + "peer.service": "integration-tests-python", + "request_id": "", + "resource_names": "GET /httpapi/get", + "runtime-id": "", + "stage": "$default" + }, + "metrics": { + "_dd._inferred_span": 1.0, + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "aws.httpapi", + "parent": null, + "resource": "GET /httpapi/get", + "service": "x02yirxc7a.execute-api.eu-west-1.amazonaws.com", + "type": "web" + }, + { + "error": 0, + "label": "aws.lambda https://x02yirxc7a.execute-api.eu-west-1.amazonaws.com/httpapi/get", + "meta": { + "_dd.origin": "lambda", + "_dd.svc_src": "m", + "cold_start": "false", + "datadog_lambda": "", + "dd_trace": "", + "function_arn": "arn:aws:lambda:eu-west-1::function:", + "function_trigger.event_source": "api-gateway", + "function_trigger.event_source_arn": "arn:aws:apigateway:eu-west-1::/restapis/x02yirxc7a/stages/$default", + "function_version": "$LATEST", + "functionname": "", + "http.method": "GET", + "http.route": "/httpapi/get", + "http.status_code": "200", + "http.url": "https://x02yirxc7a.execute-api.eu-west-1.amazonaws.com/httpapi/get", + "request_id": "", + "resource_names": "", + "span.kind": "server", + "span.name": "aws.lambda" + }, + "metrics": { + "_dd.top_level": 1 + }, + "name": "aws.lambda", + "parent": "aws.httpapi GET /httpapi/get https://x02yirxc7a.execute-api.eu-west-1.amazonaws.com/httpapi/get", + "resource": "", + "service": "integration-tests-python", + "type": "serverless" + }, + { + "error": 0, + "label": "requests.request GET / https://datadoghq.com/", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.svc_src": "requests", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.status_msg": "OK", + "http.url": "https://datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1 + }, + "name": "requests.request", + "parent": "aws.lambda https://x02yirxc7a.execute-api.eu-west-1.amazonaws.com/httpapi/get", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request GET / https://www.datadoghq.com/", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.p.tid": "", + "_dd.svc_src": "requests", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.status_msg": "OK", + "http.url": "https://www.datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "www.datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1 + }, + "name": "requests.request", + "parent": "requests.request GET / https://datadoghq.com/", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request POST /api/v1/distribution_points https://api.datadoghq.com/api/v1/distribution_points", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.p.dm": "-0", + "_dd.p.tid": "", + "_dd.svc_src": "requests", + "_dd.tags.process": "entrypoint.basedir:runtime,entrypoint.name:bootstrap,entrypoint.type:script,entrypoint.workdir:task,svc.user:true", + "component": "requests", + "http.method": "POST", + "http.status_code": "202", + "http.status_msg": "Accepted", + "http.url": "https://api.datadoghq.com/api/v1/distribution_points", + "http.useragent": "datadogpy/X (python X; os linux; arch )", + "language": "python", + "out.host": "api.datadoghq.com", + "runtime-id": "", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "requests.request", + "parent": null, + "resource": "POST /api/v1/distribution_points", + "service": "requests", + "type": "http" + } +] diff --git a/tests/integration/expected/spans/default/sync-metrics/kinesis.json b/tests/integration/expected/spans/default/sync-metrics/kinesis.json new file mode 100644 index 00000000..a50118fb --- /dev/null +++ b/tests/integration/expected/spans/default/sync-metrics/kinesis.json @@ -0,0 +1,155 @@ +[ + { + "error": 0, + "label": "aws.kinesis EXAMPLE", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.p.dm": "-0", + "_dd.p.tid": "", + "_dd.peer.service.source": "peer.service", + "_dd.svc_src": "m", + "_dd.tags.process": "entrypoint.basedir:runtime,entrypoint.name:bootstrap,entrypoint.type:script,entrypoint.workdir:task,svc.user:true", + "_inferred_span.synchronicity": "async", + "_inferred_span.tag_source": "self", + "dd_resource_key": "arn:aws:kinesis:EXAMPLE", + "event_id": "shardId-000000000000:49545115243490985018280067714973144582180062593244200961", + "event_name": "aws:kinesis:record", + "event_source_arn": "arn:aws:kinesis:EXAMPLE", + "event_version": "1.0", + "language": "python", + "operation_name": "aws.kinesis", + "partition_key": "partitionKey-03", + "peer.service": "integration-tests-python", + "resource_names": "EXAMPLE", + "runtime-id": "", + "shardid": "shardId-000000000000", + "span.kind": "server", + "streamname": "EXAMPLE" + }, + "metrics": { + "_dd._inferred_span": 1.0, + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "aws.kinesis", + "parent": null, + "resource": "EXAMPLE", + "service": "EXAMPLE", + "type": "web" + }, + { + "error": 0, + "label": "aws.lambda ", + "meta": { + "_dd.origin": "lambda", + "_dd.svc_src": "m", + "cold_start": "false", + "datadog_lambda": "", + "dd_trace": "", + "function_arn": "arn:aws:lambda:eu-west-1::function:", + "function_trigger.event_source": "kinesis", + "function_trigger.event_source_arn": "arn:aws:kinesis:EXAMPLE", + "function_version": "$LATEST", + "functionname": "", + "request_id": "", + "resource_names": "", + "span.kind": "server", + "span.name": "aws.lambda" + }, + "metrics": { + "_dd.top_level": 1 + }, + "name": "aws.lambda", + "parent": "aws.kinesis EXAMPLE", + "resource": "", + "service": "integration-tests-python", + "type": "serverless" + }, + { + "error": 0, + "label": "requests.request GET / https://datadoghq.com/", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.svc_src": "requests", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.status_msg": "OK", + "http.url": "https://datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1 + }, + "name": "requests.request", + "parent": "aws.lambda ", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request GET / https://www.datadoghq.com/", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.p.tid": "", + "_dd.svc_src": "requests", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.status_msg": "OK", + "http.url": "https://www.datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "www.datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1 + }, + "name": "requests.request", + "parent": "requests.request GET / https://datadoghq.com/", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request POST /api/v1/distribution_points https://api.datadoghq.com/api/v1/distribution_points", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.p.dm": "-0", + "_dd.p.tid": "", + "_dd.svc_src": "requests", + "_dd.tags.process": "entrypoint.basedir:runtime,entrypoint.name:bootstrap,entrypoint.type:script,entrypoint.workdir:task,svc.user:true", + "component": "requests", + "http.method": "POST", + "http.status_code": "202", + "http.status_msg": "Accepted", + "http.url": "https://api.datadoghq.com/api/v1/distribution_points", + "http.useragent": "datadogpy/X (python X; os linux; arch )", + "language": "python", + "out.host": "api.datadoghq.com", + "runtime-id": "", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "requests.request", + "parent": null, + "resource": "POST /api/v1/distribution_points", + "service": "requests", + "type": "http" + } +] diff --git a/tests/integration/expected/spans/default/sync-metrics/s3.json b/tests/integration/expected/spans/default/sync-metrics/s3.json new file mode 100644 index 00000000..d19992f9 --- /dev/null +++ b/tests/integration/expected/spans/default/sync-metrics/s3.json @@ -0,0 +1,166 @@ +[ + { + "error": 0, + "label": "aws.lambda ", + "meta": { + "_dd.origin": "lambda", + "_dd.svc_src": "m", + "cold_start": "false", + "datadog_lambda": "", + "dd_trace": "", + "function_arn": "arn:aws:lambda:eu-west-1::function:", + "function_trigger.event_source": "s3", + "function_trigger.event_source_arn": "arn:aws:s3:::example-bucket", + "function_version": "$LATEST", + "functionname": "", + "request_id": "", + "resource_names": "", + "span.kind": "server", + "span.name": "aws.lambda" + }, + "metrics": { + "_dd.top_level": 1 + }, + "name": "aws.lambda", + "parent": "aws.s3 example-bucket", + "resource": "", + "service": "integration-tests-python", + "type": "serverless" + }, + { + "error": 0, + "label": "aws.s3 example-bucket", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.p.dm": "-0", + "_dd.p.tid": "", + "_dd.peer.service.source": "peer.service", + "_dd.svc_src": "m", + "_dd.tags.process": "entrypoint.basedir:runtime,entrypoint.name:bootstrap,entrypoint.type:script,entrypoint.workdir:task,svc.user:true", + "_inferred_span.synchronicity": "async", + "_inferred_span.tag_source": "self", + "bucket_arn": "arn:aws:s3:::example-bucket", + "bucketname": "example-bucket", + "dd_resource_key": "arn:aws:s3:::example-bucket", + "event_name": "ObjectCreated:Put", + "language": "python", + "object_etag": "0123456789abcdef0123456789abcdef", + "object_key": "test/key", + "object_size": "1024", + "operation_name": "aws.s3", + "peer.service": "integration-tests-python", + "resource_names": "example-bucket", + "runtime-id": "", + "span.kind": "server" + }, + "metrics": { + "_dd._inferred_span": 1.0, + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "aws.s3", + "parent": null, + "resource": "example-bucket", + "service": "example-bucket", + "span_links": [ + { + "attributes": { + "link.kind": "span-pointer", + "ptr.dir": "u", + "ptr.hash": "1dc3e5d00dae48c1f07d95371a747788", + "ptr.kind": "aws.s3.object" + }, + "span_id": "0000000000000000", + "trace_id": "00000000000000000000000000000000" + } + ], + "type": "web" + }, + { + "error": 0, + "label": "requests.request GET / https://datadoghq.com/", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.svc_src": "requests", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.status_msg": "OK", + "http.url": "https://datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1 + }, + "name": "requests.request", + "parent": "aws.lambda ", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request GET / https://www.datadoghq.com/", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.p.tid": "", + "_dd.svc_src": "requests", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.status_msg": "OK", + "http.url": "https://www.datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "www.datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1 + }, + "name": "requests.request", + "parent": "requests.request GET / https://datadoghq.com/", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request POST /api/v1/distribution_points https://api.datadoghq.com/api/v1/distribution_points", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.p.dm": "-0", + "_dd.p.tid": "", + "_dd.svc_src": "requests", + "_dd.tags.process": "entrypoint.basedir:runtime,entrypoint.name:bootstrap,entrypoint.type:script,entrypoint.workdir:task,svc.user:true", + "component": "requests", + "http.method": "POST", + "http.status_code": "202", + "http.status_msg": "Accepted", + "http.url": "https://api.datadoghq.com/api/v1/distribution_points", + "http.useragent": "datadogpy/X (python X; os linux; arch )", + "language": "python", + "out.host": "api.datadoghq.com", + "runtime-id": "", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "requests.request", + "parent": null, + "resource": "POST /api/v1/distribution_points", + "service": "requests", + "type": "http" + } +] diff --git a/tests/integration/expected/spans/default/sync-metrics/sns.json b/tests/integration/expected/spans/default/sync-metrics/sns.json new file mode 100644 index 00000000..feb91450 --- /dev/null +++ b/tests/integration/expected/spans/default/sync-metrics/sns.json @@ -0,0 +1,153 @@ +[ + { + "error": 0, + "label": "aws.lambda ", + "meta": { + "_dd.origin": "lambda", + "_dd.svc_src": "m", + "cold_start": "false", + "datadog_lambda": "", + "dd_trace": "", + "function_arn": "arn:aws:lambda:eu-west-1::function:", + "function_trigger.event_source": "sns", + "function_trigger.event_source_arn": "arn:aws:sns:us-east-2:123456789012:sns-lambda", + "function_version": "$LATEST", + "functionname": "", + "request_id": "", + "resource_names": "", + "span.kind": "server", + "span.name": "aws.lambda" + }, + "metrics": { + "_dd.top_level": 1 + }, + "name": "aws.lambda", + "parent": "aws.sns sns-lambda", + "resource": "", + "service": "integration-tests-python", + "type": "serverless" + }, + { + "error": 0, + "label": "aws.sns sns-lambda", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.p.dm": "-0", + "_dd.p.tid": "", + "_dd.peer.service.source": "peer.service", + "_dd.svc_src": "m", + "_dd.tags.process": "entrypoint.basedir:runtime,entrypoint.name:bootstrap,entrypoint.type:script,entrypoint.workdir:task,svc.user:true", + "_inferred_span.synchronicity": "async", + "_inferred_span.tag_source": "self", + "dd_resource_key": "arn:aws:sns:us-east-2:123456789012:sns-lambda", + "language": "python", + "message_id": "95df01b4-ee98-5cb9-9903-4c221d41eb5e", + "operation_name": "aws.sns", + "peer.service": "integration-tests-python", + "resource_names": "sns-lambda", + "runtime-id": "", + "span.kind": "server", + "subject": "TestInvoke", + "topic_arn": "arn:aws:sns:us-east-2:123456789012:sns-lambda", + "topicname": "sns-lambda", + "type": "Notification" + }, + "metrics": { + "_dd._inferred_span": 1.0, + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "aws.sns", + "parent": null, + "resource": "sns-lambda", + "service": "sns-lambda", + "type": "web" + }, + { + "error": 0, + "label": "requests.request GET / https://datadoghq.com/", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.svc_src": "requests", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.status_msg": "OK", + "http.url": "https://datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1 + }, + "name": "requests.request", + "parent": "aws.lambda ", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request GET / https://www.datadoghq.com/", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.p.tid": "", + "_dd.svc_src": "requests", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.status_msg": "OK", + "http.url": "https://www.datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "www.datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1 + }, + "name": "requests.request", + "parent": "requests.request GET / https://datadoghq.com/", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request POST /api/v1/distribution_points https://api.datadoghq.com/api/v1/distribution_points", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.p.dm": "-0", + "_dd.p.tid": "", + "_dd.svc_src": "requests", + "_dd.tags.process": "entrypoint.basedir:runtime,entrypoint.name:bootstrap,entrypoint.type:script,entrypoint.workdir:task,svc.user:true", + "component": "requests", + "http.method": "POST", + "http.status_code": "202", + "http.status_msg": "Accepted", + "http.url": "https://api.datadoghq.com/api/v1/distribution_points", + "http.useragent": "datadogpy/X (python X; os linux; arch )", + "language": "python", + "out.host": "api.datadoghq.com", + "runtime-id": "", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "requests.request", + "parent": null, + "resource": "POST /api/v1/distribution_points", + "service": "requests", + "type": "http" + } +] diff --git a/tests/integration/expected/spans/default/sync-metrics/sqs.json b/tests/integration/expected/spans/default/sync-metrics/sqs.json new file mode 100644 index 00000000..bc0832a2 --- /dev/null +++ b/tests/integration/expected/spans/default/sync-metrics/sqs.json @@ -0,0 +1,152 @@ +[ + { + "error": 0, + "label": "aws.lambda ", + "meta": { + "_dd.origin": "lambda", + "_dd.svc_src": "m", + "cold_start": "false", + "datadog_lambda": "", + "dd_trace": "", + "function_arn": "arn:aws:lambda:eu-west-1::function:", + "function_trigger.event_source": "sqs", + "function_trigger.event_source_arn": "arn:aws:sqs:us-east-2:123456789012:my-queue", + "function_version": "$LATEST", + "functionname": "", + "request_id": "", + "resource_names": "", + "span.kind": "server", + "span.name": "aws.lambda" + }, + "metrics": { + "_dd.top_level": 1 + }, + "name": "aws.lambda", + "parent": "aws.sqs my-queue", + "resource": "", + "service": "integration-tests-python", + "type": "serverless" + }, + { + "error": 0, + "label": "aws.sqs my-queue", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.p.dm": "-0", + "_dd.p.tid": "", + "_dd.peer.service.source": "peer.service", + "_dd.svc_src": "m", + "_dd.tags.process": "entrypoint.basedir:runtime,entrypoint.name:bootstrap,entrypoint.type:script,entrypoint.workdir:task,svc.user:true", + "_inferred_span.synchronicity": "async", + "_inferred_span.tag_source": "self", + "dd_resource_key": "arn:aws:sqs:us-east-2:123456789012:my-queue", + "event_source_arn": "arn:aws:sqs:us-east-2:123456789012:my-queue", + "language": "python", + "operation_name": "aws.sqs", + "peer.service": "integration-tests-python", + "queuename": "my-queue", + "receipt_handle": "AQEBwJnKyrHigUMZj6rYigCgxlaS3SLy0a...", + "resource_names": "my-queue", + "runtime-id": "", + "sender_id": "AIDAIENQZJOLO23YVJ4VO", + "span.kind": "server" + }, + "metrics": { + "_dd._inferred_span": 1.0, + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "aws.sqs", + "parent": null, + "resource": "my-queue", + "service": "my-queue", + "type": "web" + }, + { + "error": 0, + "label": "requests.request GET / https://datadoghq.com/", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.svc_src": "requests", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.status_msg": "OK", + "http.url": "https://datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1 + }, + "name": "requests.request", + "parent": "aws.lambda ", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request GET / https://www.datadoghq.com/", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.p.tid": "", + "_dd.svc_src": "requests", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.status_msg": "OK", + "http.url": "https://www.datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "www.datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1 + }, + "name": "requests.request", + "parent": "requests.request GET / https://datadoghq.com/", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request POST /api/v1/distribution_points https://api.datadoghq.com/api/v1/distribution_points", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.p.dm": "-0", + "_dd.p.tid": "", + "_dd.svc_src": "requests", + "_dd.tags.process": "entrypoint.basedir:runtime,entrypoint.name:bootstrap,entrypoint.type:script,entrypoint.workdir:task,svc.user:true", + "component": "requests", + "http.method": "POST", + "http.status_code": "202", + "http.status_msg": "Accepted", + "http.url": "https://api.datadoghq.com/api/v1/distribution_points", + "http.useragent": "datadogpy/X (python X; os linux; arch )", + "language": "python", + "out.host": "api.datadoghq.com", + "runtime-id": "", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "requests.request", + "parent": null, + "resource": "POST /api/v1/distribution_points", + "service": "requests", + "type": "http" + } +] diff --git a/tests/integration/expected/spans/default/sync-metrics/websocket.json b/tests/integration/expected/spans/default/sync-metrics/websocket.json new file mode 100644 index 00000000..2ada09cc --- /dev/null +++ b/tests/integration/expected/spans/default/sync-metrics/websocket.json @@ -0,0 +1,160 @@ +[ + { + "error": 0, + "label": "aws.apigateway.websocket $default https://p62c47itsb.execute-api.eu-west-1.amazonaws.com$default", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.p.dm": "-0", + "_dd.p.tid": "", + "_dd.peer.service.source": "peer.service", + "_dd.svc_src": "m", + "_dd.tags.process": "entrypoint.basedir:runtime,entrypoint.name:bootstrap,entrypoint.type:script,entrypoint.workdir:task,svc.user:true", + "_inferred_span.synchronicity": "sync", + "_inferred_span.tag_source": "self", + "apiid": "p62c47itsb", + "apiname": "p62c47itsb", + "connection_id": "Fc5SzcoYGjQCJlg=", + "dd_resource_key": "arn:aws:apigateway:eu-west-1::/restapis/p62c47itsb/stages/dev", + "endpoint": "$default", + "event_type": "MESSAGE", + "http.status_code": "200", + "http.url": "https://p62c47itsb.execute-api.eu-west-1.amazonaws.com$default", + "language": "python", + "message_direction": "IN", + "operation_name": "aws.apigateway.websocket", + "peer.service": "integration-tests-python", + "request_id": "", + "resource_names": "$default", + "runtime-id": "", + "span.kind": "server", + "stage": "dev" + }, + "metrics": { + "_dd._inferred_span": 1.0, + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "aws.apigateway.websocket", + "parent": null, + "resource": "$default", + "service": "p62c47itsb.execute-api.eu-west-1.amazonaws.com", + "type": "web" + }, + { + "error": 0, + "label": "aws.lambda https://p62c47itsb.execute-api.eu-west-1.amazonaws.com", + "meta": { + "_dd.origin": "lambda", + "_dd.svc_src": "m", + "cold_start": "false", + "datadog_lambda": "", + "dd_trace": "", + "function_arn": "arn:aws:lambda:eu-west-1::function:", + "function_trigger.event_source": "api-gateway", + "function_trigger.event_source_arn": "arn:aws:apigateway:eu-west-1::/restapis/p62c47itsb/stages/dev", + "function_version": "$LATEST", + "functionname": "", + "http.status_code": "200", + "http.url": "https://p62c47itsb.execute-api.eu-west-1.amazonaws.com", + "request_id": "", + "resource_names": "", + "span.kind": "server", + "span.name": "aws.lambda" + }, + "metrics": { + "_dd.top_level": 1 + }, + "name": "aws.lambda", + "parent": "aws.apigateway.websocket $default https://p62c47itsb.execute-api.eu-west-1.amazonaws.com$default", + "resource": "", + "service": "integration-tests-python", + "type": "serverless" + }, + { + "error": 0, + "label": "requests.request GET / https://datadoghq.com/", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.svc_src": "requests", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.status_msg": "OK", + "http.url": "https://datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1 + }, + "name": "requests.request", + "parent": "aws.lambda https://p62c47itsb.execute-api.eu-west-1.amazonaws.com", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request GET / https://www.datadoghq.com/", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.p.tid": "", + "_dd.svc_src": "requests", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.status_msg": "OK", + "http.url": "https://www.datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "www.datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1 + }, + "name": "requests.request", + "parent": "requests.request GET / https://datadoghq.com/", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request POST /api/v1/distribution_points https://api.datadoghq.com/api/v1/distribution_points", + "meta": { + "_dd.base_service": "integration-tests-python", + "_dd.origin": "lambda", + "_dd.p.dm": "-0", + "_dd.p.tid": "", + "_dd.svc_src": "requests", + "_dd.tags.process": "entrypoint.basedir:runtime,entrypoint.name:bootstrap,entrypoint.type:script,entrypoint.workdir:task,svc.user:true", + "component": "requests", + "http.method": "POST", + "http.status_code": "202", + "http.status_msg": "Accepted", + "http.url": "https://api.datadoghq.com/api/v1/distribution_points", + "http.useragent": "datadogpy/X (python X; os linux; arch )", + "language": "python", + "out.host": "api.datadoghq.com", + "runtime-id": "", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "requests.request", + "parent": null, + "resource": "POST /api/v1/distribution_points", + "service": "requests", + "type": "http" + } +] diff --git a/tests/integration/expected/spans/python38/async-metrics/api-gateway-get.json b/tests/integration/expected/spans/python38/async-metrics/api-gateway-get.json new file mode 100644 index 00000000..e716f216 --- /dev/null +++ b/tests/integration/expected/spans/python38/async-metrics/api-gateway-get.json @@ -0,0 +1,118 @@ +[ + { + "error": 0, + "label": "aws.apigateway GET / https://70ixmpl4fl.execute-api.us-east-2.amazonaws.com/", + "meta": { + "_dd.origin": "lambda", + "_dd.p.dm": "-0", + "_dd.p.tid": "", + "_dd.peer.service.source": "peer.service", + "_inferred_span.synchronicity": "sync", + "_inferred_span.tag_source": "self", + "apiid": "70ixmpl4fl", + "apiname": "70ixmpl4fl", + "dd_resource_key": "arn:aws:apigateway:eu-west-1::/restapis/70ixmpl4fl/stages/Prod", + "endpoint": "/", + "http.method": "GET", + "http.route": "/", + "http.status_code": "200", + "http.url": "https://70ixmpl4fl.execute-api.us-east-2.amazonaws.com/", + "http.useragent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36", + "language": "python", + "peer.service": "integration-tests-python", + "request_id": "", + "resource_names": "GET /", + "runtime-id": "", + "span.kind": "server", + "stage": "Prod" + }, + "metrics": { + "_dd._inferred_span": 1.0, + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "aws.apigateway", + "parent": null, + "resource": "GET /", + "service": "70ixmpl4fl.execute-api.us-east-2.amazonaws.com", + "type": "web" + }, + { + "error": 0, + "label": "aws.lambda https://70ixmpl4fl.execute-api.us-east-2.amazonaws.com/Prod/", + "meta": { + "_dd.origin": "lambda", + "cold_start": "true", + "datadog_lambda": "", + "dd_trace": "", + "function_arn": "arn:aws:lambda:eu-west-1::function:", + "function_trigger.event_source": "api-gateway", + "function_trigger.event_source_arn": "arn:aws:apigateway:eu-west-1::/restapis/70ixmpl4fl/stages/Prod", + "function_version": "$LATEST", + "functionname": "", + "http.method": "GET", + "http.route": "/", + "http.status_code": "200", + "http.url": "https://70ixmpl4fl.execute-api.us-east-2.amazonaws.com/Prod/", + "request_id": "", + "resource_names": "", + "span.kind": "server", + "span.name": "aws.lambda" + }, + "metrics": { + "_dd.top_level": 1 + }, + "name": "aws.lambda", + "parent": "aws.apigateway GET / https://70ixmpl4fl.execute-api.us-east-2.amazonaws.com/", + "resource": "", + "service": "integration-tests-python", + "type": "serverless" + }, + { + "error": 0, + "label": "requests.request GET / https://datadoghq.com/", + "meta": { + "_dd.origin": "lambda", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.url": "https://datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1 + }, + "name": "requests.request", + "parent": "aws.lambda https://70ixmpl4fl.execute-api.us-east-2.amazonaws.com/Prod/", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request GET / https://www.datadoghq.com/", + "meta": { + "_dd.origin": "lambda", + "_dd.p.tid": "", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.url": "https://www.datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "www.datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1 + }, + "name": "requests.request", + "parent": "requests.request GET / https://datadoghq.com/", + "resource": "GET /", + "service": "requests", + "type": "http" + } +] diff --git a/tests/integration/expected/spans/python38/async-metrics/appsync.json b/tests/integration/expected/spans/python38/async-metrics/appsync.json new file mode 100644 index 00000000..7cc40807 --- /dev/null +++ b/tests/integration/expected/spans/python38/async-metrics/appsync.json @@ -0,0 +1,76 @@ +[ + { + "error": 0, + "label": "aws.lambda ", + "meta": { + "_dd.origin": "lambda", + "cold_start": "false", + "datadog_lambda": "", + "dd_trace": "", + "function_arn": "arn:aws:lambda:eu-west-1::function:", + "function_version": "$LATEST", + "functionname": "", + "language": "python", + "request_id": "", + "resource_names": "", + "runtime-id": "", + "span.kind": "server", + "span.name": "aws.lambda" + }, + "metrics": { + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "aws.lambda", + "parent": null, + "resource": "", + "service": "integration-tests-python", + "type": "serverless" + }, + { + "error": 0, + "label": "requests.request GET / https://datadoghq.com/", + "meta": { + "_dd.origin": "lambda", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.url": "https://datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1 + }, + "name": "requests.request", + "parent": "aws.lambda ", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request GET / https://www.datadoghq.com/", + "meta": { + "_dd.origin": "lambda", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.url": "https://www.datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "www.datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1 + }, + "name": "requests.request", + "parent": "requests.request GET / https://datadoghq.com/", + "resource": "GET /", + "service": "requests", + "type": "http" + } +] diff --git a/tests/integration/expected/spans/python38/async-metrics/dynamodb.json b/tests/integration/expected/spans/python38/async-metrics/dynamodb.json new file mode 100644 index 00000000..9da2ed69 --- /dev/null +++ b/tests/integration/expected/spans/python38/async-metrics/dynamodb.json @@ -0,0 +1,144 @@ +[ + { + "error": 0, + "label": "aws.dynamodb ExampleTableWithStream", + "meta": { + "_dd.origin": "lambda", + "_dd.p.dm": "-0", + "_dd.p.tid": "", + "_dd.peer.service.source": "peer.service", + "_inferred_span.synchronicity": "async", + "_inferred_span.tag_source": "self", + "dd_resource_key": "arn:aws:dynamodb:us-east-1:123456789012:table/ExampleTableWithStream/stream/2015-06-27T00:48:05.899", + "event_id": "c4ca4238a0b923820dcc509a6f75849b", + "event_name": "INSERT", + "event_source_arn": "arn:aws:dynamodb:us-east-1:123456789012:table/ExampleTableWithStream/stream/2015-06-27T00:48:05.899", + "event_version": "1.1", + "language": "python", + "operation_name": "aws.dynamodb", + "peer.service": "integration-tests-python", + "resource_names": "ExampleTableWithStream", + "runtime-id": "", + "size_bytes": "26", + "span.kind": "server", + "stream_view_type": "NEW_AND_OLD_IMAGES", + "tablename": "ExampleTableWithStream" + }, + "metrics": { + "_dd._inferred_span": 1.0, + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "aws.dynamodb", + "parent": null, + "resource": "ExampleTableWithStream", + "service": "ExampleTableWithStream", + "span_links": [ + { + "attributes": { + "link.kind": "span-pointer", + "ptr.dir": "u", + "ptr.hash": "e2af34d333891f765c7f02d2da80895e", + "ptr.kind": "aws.dynamodb.item" + }, + "span_id": "0000000000000000", + "trace_id": "00000000000000000000000000000000" + }, + { + "attributes": { + "link.kind": "span-pointer", + "ptr.dir": "u", + "ptr.hash": "e2af34d333891f765c7f02d2da80895e", + "ptr.kind": "aws.dynamodb.item" + }, + "span_id": "0000000000000000", + "trace_id": "00000000000000000000000000000000" + }, + { + "attributes": { + "link.kind": "span-pointer", + "ptr.dir": "u", + "ptr.hash": "e2af34d333891f765c7f02d2da80895e", + "ptr.kind": "aws.dynamodb.item" + }, + "span_id": "0000000000000000", + "trace_id": "00000000000000000000000000000000" + } + ], + "type": "web" + }, + { + "error": 0, + "label": "aws.lambda ", + "meta": { + "_dd.origin": "lambda", + "cold_start": "false", + "datadog_lambda": "", + "dd_trace": "", + "function_arn": "arn:aws:lambda:eu-west-1::function:", + "function_trigger.event_source": "dynamodb", + "function_trigger.event_source_arn": "arn:aws:dynamodb:us-east-1:123456789012:table/ExampleTableWithStream/stream/2015-06-27T00:48:05.899", + "function_version": "$LATEST", + "functionname": "", + "request_id": "", + "resource_names": "", + "span.kind": "server", + "span.name": "aws.lambda" + }, + "metrics": { + "_dd.top_level": 1 + }, + "name": "aws.lambda", + "parent": "aws.dynamodb ExampleTableWithStream", + "resource": "", + "service": "integration-tests-python", + "type": "serverless" + }, + { + "error": 0, + "label": "requests.request GET / https://datadoghq.com/", + "meta": { + "_dd.origin": "lambda", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.url": "https://datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1 + }, + "name": "requests.request", + "parent": "aws.lambda ", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request GET / https://www.datadoghq.com/", + "meta": { + "_dd.origin": "lambda", + "_dd.p.tid": "", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.url": "https://www.datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "www.datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1 + }, + "name": "requests.request", + "parent": "requests.request GET / https://datadoghq.com/", + "resource": "GET /", + "service": "requests", + "type": "http" + } +] diff --git a/tests/integration/expected/spans/python38/async-metrics/eventbridge-custom.json b/tests/integration/expected/spans/python38/async-metrics/eventbridge-custom.json new file mode 100644 index 00000000..c3063bda --- /dev/null +++ b/tests/integration/expected/spans/python38/async-metrics/eventbridge-custom.json @@ -0,0 +1,104 @@ +[ + { + "error": 0, + "label": "aws.eventbridge eventbridge.custom.event.sender", + "meta": { + "_dd.origin": "lambda", + "_dd.p.dm": "-0", + "_dd.p.tid": "", + "_dd.peer.service.source": "peer.service", + "_inferred_span.synchronicity": "async", + "_inferred_span.tag_source": "self", + "detail_type": "testdetail", + "language": "python", + "operation_name": "aws.eventbridge", + "peer.service": "integration-tests-python", + "resource_names": "eventbridge.custom.event.sender", + "runtime-id": "", + "span.kind": "server" + }, + "metrics": { + "_dd._inferred_span": 1.0, + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "aws.eventbridge", + "parent": null, + "resource": "eventbridge.custom.event.sender", + "service": "eventbridge.custom.event.sender", + "type": "web" + }, + { + "error": 0, + "label": "aws.lambda ", + "meta": { + "_dd.origin": "lambda", + "cold_start": "false", + "datadog_lambda": "", + "dd_trace": "", + "function_arn": "arn:aws:lambda:eu-west-1::function:", + "function_trigger.event_source": "eventbridge", + "function_version": "$LATEST", + "functionname": "", + "request_id": "", + "resource_names": "", + "span.kind": "server", + "span.name": "aws.lambda" + }, + "metrics": { + "_dd.top_level": 1 + }, + "name": "aws.lambda", + "parent": "aws.eventbridge eventbridge.custom.event.sender", + "resource": "", + "service": "integration-tests-python", + "type": "serverless" + }, + { + "error": 0, + "label": "requests.request GET / https://datadoghq.com/", + "meta": { + "_dd.origin": "lambda", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.url": "https://datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1 + }, + "name": "requests.request", + "parent": "aws.lambda ", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request GET / https://www.datadoghq.com/", + "meta": { + "_dd.origin": "lambda", + "_dd.p.tid": "", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.url": "https://www.datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "www.datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1 + }, + "name": "requests.request", + "parent": "requests.request GET / https://datadoghq.com/", + "resource": "GET /", + "service": "requests", + "type": "http" + } +] diff --git a/tests/integration/expected/spans/python38/async-metrics/http-api.json b/tests/integration/expected/spans/python38/async-metrics/http-api.json new file mode 100644 index 00000000..8dddfa9d --- /dev/null +++ b/tests/integration/expected/spans/python38/async-metrics/http-api.json @@ -0,0 +1,119 @@ +[ + { + "error": 0, + "label": "aws.httpapi GET /httpapi/get https://x02yirxc7a.execute-api.eu-west-1.amazonaws.com/httpapi/get", + "meta": { + "_dd.origin": "lambda", + "_dd.p.dm": "-0", + "_dd.p.tid": "", + "_dd.peer.service.source": "peer.service", + "_inferred_span.synchronicity": "sync", + "_inferred_span.tag_source": "self", + "apiid": "x02yirxc7a", + "apiname": "x02yirxc7a", + "dd_resource_key": "arn:aws:apigateway:eu-west-1::/restapis/x02yirxc7a/stages/$default", + "endpoint": "/httpapi/get", + "http.method": "GET", + "http.protocol": "HTTP/1.1", + "http.route": "/httpapi/get", + "http.source_ip": "38.122.226.210", + "http.status_code": "200", + "http.url": "https://x02yirxc7a.execute-api.eu-west-1.amazonaws.com/httpapi/get", + "http.useragent": "curl/7.64.1", + "language": "python", + "peer.service": "integration-tests-python", + "request_id": "", + "resource_names": "GET /httpapi/get", + "runtime-id": "", + "stage": "$default" + }, + "metrics": { + "_dd._inferred_span": 1.0, + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "aws.httpapi", + "parent": null, + "resource": "GET /httpapi/get", + "service": "x02yirxc7a.execute-api.eu-west-1.amazonaws.com", + "type": "web" + }, + { + "error": 0, + "label": "aws.lambda https://x02yirxc7a.execute-api.eu-west-1.amazonaws.com/httpapi/get", + "meta": { + "_dd.origin": "lambda", + "cold_start": "false", + "datadog_lambda": "", + "dd_trace": "", + "function_arn": "arn:aws:lambda:eu-west-1::function:", + "function_trigger.event_source": "api-gateway", + "function_trigger.event_source_arn": "arn:aws:apigateway:eu-west-1::/restapis/x02yirxc7a/stages/$default", + "function_version": "$LATEST", + "functionname": "", + "http.method": "GET", + "http.route": "/httpapi/get", + "http.status_code": "200", + "http.url": "https://x02yirxc7a.execute-api.eu-west-1.amazonaws.com/httpapi/get", + "request_id": "", + "resource_names": "", + "span.kind": "server", + "span.name": "aws.lambda" + }, + "metrics": { + "_dd.top_level": 1 + }, + "name": "aws.lambda", + "parent": "aws.httpapi GET /httpapi/get https://x02yirxc7a.execute-api.eu-west-1.amazonaws.com/httpapi/get", + "resource": "", + "service": "integration-tests-python", + "type": "serverless" + }, + { + "error": 0, + "label": "requests.request GET / https://datadoghq.com/", + "meta": { + "_dd.origin": "lambda", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.url": "https://datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1 + }, + "name": "requests.request", + "parent": "aws.lambda https://x02yirxc7a.execute-api.eu-west-1.amazonaws.com/httpapi/get", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request GET / https://www.datadoghq.com/", + "meta": { + "_dd.origin": "lambda", + "_dd.p.tid": "", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.url": "https://www.datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "www.datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1 + }, + "name": "requests.request", + "parent": "requests.request GET / https://datadoghq.com/", + "resource": "GET /", + "service": "requests", + "type": "http" + } +] diff --git a/tests/integration/expected/spans/python38/async-metrics/kinesis.json b/tests/integration/expected/spans/python38/async-metrics/kinesis.json new file mode 100644 index 00000000..ba7edd1e --- /dev/null +++ b/tests/integration/expected/spans/python38/async-metrics/kinesis.json @@ -0,0 +1,112 @@ +[ + { + "error": 0, + "label": "aws.kinesis EXAMPLE", + "meta": { + "_dd.origin": "lambda", + "_dd.p.dm": "-0", + "_dd.p.tid": "", + "_dd.peer.service.source": "peer.service", + "_inferred_span.synchronicity": "async", + "_inferred_span.tag_source": "self", + "dd_resource_key": "arn:aws:kinesis:EXAMPLE", + "event_id": "shardId-000000000000:49545115243490985018280067714973144582180062593244200961", + "event_name": "aws:kinesis:record", + "event_source_arn": "arn:aws:kinesis:EXAMPLE", + "event_version": "1.0", + "language": "python", + "operation_name": "aws.kinesis", + "partition_key": "partitionKey-03", + "peer.service": "integration-tests-python", + "resource_names": "EXAMPLE", + "runtime-id": "", + "shardid": "shardId-000000000000", + "span.kind": "server", + "streamname": "EXAMPLE" + }, + "metrics": { + "_dd._inferred_span": 1.0, + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "aws.kinesis", + "parent": null, + "resource": "EXAMPLE", + "service": "EXAMPLE", + "type": "web" + }, + { + "error": 0, + "label": "aws.lambda ", + "meta": { + "_dd.origin": "lambda", + "cold_start": "false", + "datadog_lambda": "", + "dd_trace": "", + "function_arn": "arn:aws:lambda:eu-west-1::function:", + "function_trigger.event_source": "kinesis", + "function_trigger.event_source_arn": "arn:aws:kinesis:EXAMPLE", + "function_version": "$LATEST", + "functionname": "", + "request_id": "", + "resource_names": "", + "span.kind": "server", + "span.name": "aws.lambda" + }, + "metrics": { + "_dd.top_level": 1 + }, + "name": "aws.lambda", + "parent": "aws.kinesis EXAMPLE", + "resource": "", + "service": "integration-tests-python", + "type": "serverless" + }, + { + "error": 0, + "label": "requests.request GET / https://datadoghq.com/", + "meta": { + "_dd.origin": "lambda", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.url": "https://datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1 + }, + "name": "requests.request", + "parent": "aws.lambda ", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request GET / https://www.datadoghq.com/", + "meta": { + "_dd.origin": "lambda", + "_dd.p.tid": "", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.url": "https://www.datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "www.datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1 + }, + "name": "requests.request", + "parent": "requests.request GET / https://datadoghq.com/", + "resource": "GET /", + "service": "requests", + "type": "http" + } +] diff --git a/tests/integration/expected/spans/python38/async-metrics/s3.json b/tests/integration/expected/spans/python38/async-metrics/s3.json new file mode 100644 index 00000000..ab6b746b --- /dev/null +++ b/tests/integration/expected/spans/python38/async-metrics/s3.json @@ -0,0 +1,123 @@ +[ + { + "error": 0, + "label": "aws.lambda ", + "meta": { + "_dd.origin": "lambda", + "cold_start": "false", + "datadog_lambda": "", + "dd_trace": "", + "function_arn": "arn:aws:lambda:eu-west-1::function:", + "function_trigger.event_source": "s3", + "function_trigger.event_source_arn": "arn:aws:s3:::example-bucket", + "function_version": "$LATEST", + "functionname": "", + "request_id": "", + "resource_names": "", + "span.kind": "server", + "span.name": "aws.lambda" + }, + "metrics": { + "_dd.top_level": 1 + }, + "name": "aws.lambda", + "parent": "aws.s3 example-bucket", + "resource": "", + "service": "integration-tests-python", + "type": "serverless" + }, + { + "error": 0, + "label": "aws.s3 example-bucket", + "meta": { + "_dd.origin": "lambda", + "_dd.p.dm": "-0", + "_dd.p.tid": "", + "_dd.peer.service.source": "peer.service", + "_inferred_span.synchronicity": "async", + "_inferred_span.tag_source": "self", + "bucket_arn": "arn:aws:s3:::example-bucket", + "bucketname": "example-bucket", + "dd_resource_key": "arn:aws:s3:::example-bucket", + "event_name": "ObjectCreated:Put", + "language": "python", + "object_etag": "0123456789abcdef0123456789abcdef", + "object_key": "test/key", + "object_size": "1024", + "operation_name": "aws.s3", + "peer.service": "integration-tests-python", + "resource_names": "example-bucket", + "runtime-id": "", + "span.kind": "server" + }, + "metrics": { + "_dd._inferred_span": 1.0, + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "aws.s3", + "parent": null, + "resource": "example-bucket", + "service": "example-bucket", + "span_links": [ + { + "attributes": { + "link.kind": "span-pointer", + "ptr.dir": "u", + "ptr.hash": "1dc3e5d00dae48c1f07d95371a747788", + "ptr.kind": "aws.s3.object" + }, + "span_id": "0000000000000000", + "trace_id": "00000000000000000000000000000000" + } + ], + "type": "web" + }, + { + "error": 0, + "label": "requests.request GET / https://datadoghq.com/", + "meta": { + "_dd.origin": "lambda", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.url": "https://datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1 + }, + "name": "requests.request", + "parent": "aws.lambda ", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request GET / https://www.datadoghq.com/", + "meta": { + "_dd.origin": "lambda", + "_dd.p.tid": "", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.url": "https://www.datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "www.datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1 + }, + "name": "requests.request", + "parent": "requests.request GET / https://datadoghq.com/", + "resource": "GET /", + "service": "requests", + "type": "http" + } +] diff --git a/tests/integration/expected/spans/python38/async-metrics/sns.json b/tests/integration/expected/spans/python38/async-metrics/sns.json new file mode 100644 index 00000000..16de9a83 --- /dev/null +++ b/tests/integration/expected/spans/python38/async-metrics/sns.json @@ -0,0 +1,110 @@ +[ + { + "error": 0, + "label": "aws.lambda ", + "meta": { + "_dd.origin": "lambda", + "cold_start": "false", + "datadog_lambda": "", + "dd_trace": "", + "function_arn": "arn:aws:lambda:eu-west-1::function:", + "function_trigger.event_source": "sns", + "function_trigger.event_source_arn": "arn:aws:sns:us-east-2:123456789012:sns-lambda", + "function_version": "$LATEST", + "functionname": "", + "request_id": "", + "resource_names": "", + "span.kind": "server", + "span.name": "aws.lambda" + }, + "metrics": { + "_dd.top_level": 1 + }, + "name": "aws.lambda", + "parent": "aws.sns sns-lambda", + "resource": "", + "service": "integration-tests-python", + "type": "serverless" + }, + { + "error": 0, + "label": "aws.sns sns-lambda", + "meta": { + "_dd.origin": "lambda", + "_dd.p.dm": "-0", + "_dd.p.tid": "", + "_dd.peer.service.source": "peer.service", + "_inferred_span.synchronicity": "async", + "_inferred_span.tag_source": "self", + "dd_resource_key": "arn:aws:sns:us-east-2:123456789012:sns-lambda", + "language": "python", + "message_id": "95df01b4-ee98-5cb9-9903-4c221d41eb5e", + "operation_name": "aws.sns", + "peer.service": "integration-tests-python", + "resource_names": "sns-lambda", + "runtime-id": "", + "span.kind": "server", + "subject": "TestInvoke", + "topic_arn": "arn:aws:sns:us-east-2:123456789012:sns-lambda", + "topicname": "sns-lambda", + "type": "Notification" + }, + "metrics": { + "_dd._inferred_span": 1.0, + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "aws.sns", + "parent": null, + "resource": "sns-lambda", + "service": "sns-lambda", + "type": "web" + }, + { + "error": 0, + "label": "requests.request GET / https://datadoghq.com/", + "meta": { + "_dd.origin": "lambda", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.url": "https://datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1 + }, + "name": "requests.request", + "parent": "aws.lambda ", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request GET / https://www.datadoghq.com/", + "meta": { + "_dd.origin": "lambda", + "_dd.p.tid": "", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.url": "https://www.datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "www.datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1 + }, + "name": "requests.request", + "parent": "requests.request GET / https://datadoghq.com/", + "resource": "GET /", + "service": "requests", + "type": "http" + } +] diff --git a/tests/integration/expected/spans/python38/async-metrics/sqs.json b/tests/integration/expected/spans/python38/async-metrics/sqs.json new file mode 100644 index 00000000..fc5c4f8d --- /dev/null +++ b/tests/integration/expected/spans/python38/async-metrics/sqs.json @@ -0,0 +1,109 @@ +[ + { + "error": 0, + "label": "aws.lambda ", + "meta": { + "_dd.origin": "lambda", + "cold_start": "false", + "datadog_lambda": "", + "dd_trace": "", + "function_arn": "arn:aws:lambda:eu-west-1::function:", + "function_trigger.event_source": "sqs", + "function_trigger.event_source_arn": "arn:aws:sqs:us-east-2:123456789012:my-queue", + "function_version": "$LATEST", + "functionname": "", + "request_id": "", + "resource_names": "", + "span.kind": "server", + "span.name": "aws.lambda" + }, + "metrics": { + "_dd.top_level": 1 + }, + "name": "aws.lambda", + "parent": "aws.sqs my-queue", + "resource": "", + "service": "integration-tests-python", + "type": "serverless" + }, + { + "error": 0, + "label": "aws.sqs my-queue", + "meta": { + "_dd.origin": "lambda", + "_dd.p.dm": "-0", + "_dd.p.tid": "", + "_dd.peer.service.source": "peer.service", + "_inferred_span.synchronicity": "async", + "_inferred_span.tag_source": "self", + "dd_resource_key": "arn:aws:sqs:us-east-2:123456789012:my-queue", + "event_source_arn": "arn:aws:sqs:us-east-2:123456789012:my-queue", + "language": "python", + "operation_name": "aws.sqs", + "peer.service": "integration-tests-python", + "queuename": "my-queue", + "receipt_handle": "AQEBwJnKyrHigUMZj6rYigCgxlaS3SLy0a...", + "resource_names": "my-queue", + "runtime-id": "", + "sender_id": "AIDAIENQZJOLO23YVJ4VO", + "span.kind": "server" + }, + "metrics": { + "_dd._inferred_span": 1.0, + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "aws.sqs", + "parent": null, + "resource": "my-queue", + "service": "my-queue", + "type": "web" + }, + { + "error": 0, + "label": "requests.request GET / https://datadoghq.com/", + "meta": { + "_dd.origin": "lambda", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.url": "https://datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1 + }, + "name": "requests.request", + "parent": "aws.lambda ", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request GET / https://www.datadoghq.com/", + "meta": { + "_dd.origin": "lambda", + "_dd.p.tid": "", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.url": "https://www.datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "www.datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1 + }, + "name": "requests.request", + "parent": "requests.request GET / https://datadoghq.com/", + "resource": "GET /", + "service": "requests", + "type": "http" + } +] diff --git a/tests/integration/expected/spans/python38/async-metrics/websocket.json b/tests/integration/expected/spans/python38/async-metrics/websocket.json new file mode 100644 index 00000000..b4073f11 --- /dev/null +++ b/tests/integration/expected/spans/python38/async-metrics/websocket.json @@ -0,0 +1,117 @@ +[ + { + "error": 0, + "label": "aws.apigateway.websocket $default https://p62c47itsb.execute-api.eu-west-1.amazonaws.com$default", + "meta": { + "_dd.origin": "lambda", + "_dd.p.dm": "-0", + "_dd.p.tid": "", + "_dd.peer.service.source": "peer.service", + "_inferred_span.synchronicity": "sync", + "_inferred_span.tag_source": "self", + "apiid": "p62c47itsb", + "apiname": "p62c47itsb", + "connection_id": "Fc5SzcoYGjQCJlg=", + "dd_resource_key": "arn:aws:apigateway:eu-west-1::/restapis/p62c47itsb/stages/dev", + "endpoint": "$default", + "event_type": "MESSAGE", + "http.status_code": "200", + "http.url": "https://p62c47itsb.execute-api.eu-west-1.amazonaws.com$default", + "language": "python", + "message_direction": "IN", + "operation_name": "aws.apigateway.websocket", + "peer.service": "integration-tests-python", + "request_id": "", + "resource_names": "$default", + "runtime-id": "", + "span.kind": "server", + "stage": "dev" + }, + "metrics": { + "_dd._inferred_span": 1.0, + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "aws.apigateway.websocket", + "parent": null, + "resource": "$default", + "service": "p62c47itsb.execute-api.eu-west-1.amazonaws.com", + "type": "web" + }, + { + "error": 0, + "label": "aws.lambda https://p62c47itsb.execute-api.eu-west-1.amazonaws.com", + "meta": { + "_dd.origin": "lambda", + "cold_start": "false", + "datadog_lambda": "", + "dd_trace": "", + "function_arn": "arn:aws:lambda:eu-west-1::function:", + "function_trigger.event_source": "api-gateway", + "function_trigger.event_source_arn": "arn:aws:apigateway:eu-west-1::/restapis/p62c47itsb/stages/dev", + "function_version": "$LATEST", + "functionname": "", + "http.status_code": "200", + "http.url": "https://p62c47itsb.execute-api.eu-west-1.amazonaws.com", + "request_id": "", + "resource_names": "", + "span.kind": "server", + "span.name": "aws.lambda" + }, + "metrics": { + "_dd.top_level": 1 + }, + "name": "aws.lambda", + "parent": "aws.apigateway.websocket $default https://p62c47itsb.execute-api.eu-west-1.amazonaws.com$default", + "resource": "", + "service": "integration-tests-python", + "type": "serverless" + }, + { + "error": 0, + "label": "requests.request GET / https://datadoghq.com/", + "meta": { + "_dd.origin": "lambda", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.url": "https://datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1 + }, + "name": "requests.request", + "parent": "aws.lambda https://p62c47itsb.execute-api.eu-west-1.amazonaws.com", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request GET / https://www.datadoghq.com/", + "meta": { + "_dd.origin": "lambda", + "_dd.p.tid": "", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.url": "https://www.datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "www.datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1 + }, + "name": "requests.request", + "parent": "requests.request GET / https://datadoghq.com/", + "resource": "GET /", + "service": "requests", + "type": "http" + } +] diff --git a/tests/integration/expected/spans/python38/sync-metrics/api-gateway-get.json b/tests/integration/expected/spans/python38/sync-metrics/api-gateway-get.json new file mode 100644 index 00000000..ace3ee7a --- /dev/null +++ b/tests/integration/expected/spans/python38/sync-metrics/api-gateway-get.json @@ -0,0 +1,147 @@ +[ + { + "error": 0, + "label": "aws.apigateway GET / https://70ixmpl4fl.execute-api.us-east-2.amazonaws.com/", + "meta": { + "_dd.origin": "lambda", + "_dd.p.dm": "-0", + "_dd.p.tid": "", + "_dd.peer.service.source": "peer.service", + "_inferred_span.synchronicity": "sync", + "_inferred_span.tag_source": "self", + "apiid": "70ixmpl4fl", + "apiname": "70ixmpl4fl", + "dd_resource_key": "arn:aws:apigateway:eu-west-1::/restapis/70ixmpl4fl/stages/Prod", + "endpoint": "/", + "http.method": "GET", + "http.route": "/", + "http.status_code": "200", + "http.url": "https://70ixmpl4fl.execute-api.us-east-2.amazonaws.com/", + "http.useragent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36", + "language": "python", + "peer.service": "integration-tests-python", + "request_id": "", + "resource_names": "GET /", + "runtime-id": "", + "span.kind": "server", + "stage": "Prod" + }, + "metrics": { + "_dd._inferred_span": 1.0, + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "aws.apigateway", + "parent": null, + "resource": "GET /", + "service": "70ixmpl4fl.execute-api.us-east-2.amazonaws.com", + "type": "web" + }, + { + "error": 0, + "label": "aws.lambda https://70ixmpl4fl.execute-api.us-east-2.amazonaws.com/Prod/", + "meta": { + "_dd.origin": "lambda", + "cold_start": "true", + "datadog_lambda": "", + "dd_trace": "", + "function_arn": "arn:aws:lambda:eu-west-1::function:", + "function_trigger.event_source": "api-gateway", + "function_trigger.event_source_arn": "arn:aws:apigateway:eu-west-1::/restapis/70ixmpl4fl/stages/Prod", + "function_version": "$LATEST", + "functionname": "", + "http.method": "GET", + "http.route": "/", + "http.status_code": "200", + "http.url": "https://70ixmpl4fl.execute-api.us-east-2.amazonaws.com/Prod/", + "request_id": "", + "resource_names": "", + "span.kind": "server", + "span.name": "aws.lambda" + }, + "metrics": { + "_dd.top_level": 1 + }, + "name": "aws.lambda", + "parent": "aws.apigateway GET / https://70ixmpl4fl.execute-api.us-east-2.amazonaws.com/", + "resource": "", + "service": "integration-tests-python", + "type": "serverless" + }, + { + "error": 0, + "label": "requests.request GET / https://datadoghq.com/", + "meta": { + "_dd.origin": "lambda", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.url": "https://datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1 + }, + "name": "requests.request", + "parent": "aws.lambda https://70ixmpl4fl.execute-api.us-east-2.amazonaws.com/Prod/", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request GET / https://www.datadoghq.com/", + "meta": { + "_dd.origin": "lambda", + "_dd.p.tid": "", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.url": "https://www.datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "www.datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1 + }, + "name": "requests.request", + "parent": "requests.request GET / https://datadoghq.com/", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request POST /api/v1/distribution_points https://api.datadoghq.com/api/v1/distribution_points", + "meta": { + "_dd.origin": "lambda", + "_dd.p.dm": "-0", + "_dd.p.tid": "", + "component": "requests", + "http.method": "POST", + "http.status_code": "202", + "http.url": "https://api.datadoghq.com/api/v1/distribution_points", + "http.useragent": "datadogpy/X (python X; os linux; arch )", + "language": "python", + "out.host": "api.datadoghq.com", + "runtime-id": "", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "requests.request", + "parent": null, + "resource": "POST /api/v1/distribution_points", + "service": "requests", + "type": "http" + } +] diff --git a/tests/integration/expected/spans/python38/sync-metrics/appsync.json b/tests/integration/expected/spans/python38/sync-metrics/appsync.json new file mode 100644 index 00000000..18a6db54 --- /dev/null +++ b/tests/integration/expected/spans/python38/sync-metrics/appsync.json @@ -0,0 +1,105 @@ +[ + { + "error": 0, + "label": "aws.lambda ", + "meta": { + "_dd.origin": "lambda", + "cold_start": "false", + "datadog_lambda": "", + "dd_trace": "", + "function_arn": "arn:aws:lambda:eu-west-1::function:", + "function_version": "$LATEST", + "functionname": "", + "language": "python", + "request_id": "", + "resource_names": "", + "runtime-id": "", + "span.kind": "server", + "span.name": "aws.lambda" + }, + "metrics": { + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "aws.lambda", + "parent": null, + "resource": "", + "service": "integration-tests-python", + "type": "serverless" + }, + { + "error": 0, + "label": "requests.request GET / https://datadoghq.com/", + "meta": { + "_dd.origin": "lambda", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.url": "https://datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1 + }, + "name": "requests.request", + "parent": "aws.lambda ", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request GET / https://www.datadoghq.com/", + "meta": { + "_dd.origin": "lambda", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.url": "https://www.datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "www.datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1 + }, + "name": "requests.request", + "parent": "requests.request GET / https://datadoghq.com/", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request POST /api/v1/distribution_points https://api.datadoghq.com/api/v1/distribution_points", + "meta": { + "_dd.origin": "lambda", + "_dd.p.dm": "-0", + "_dd.p.tid": "", + "component": "requests", + "http.method": "POST", + "http.status_code": "202", + "http.url": "https://api.datadoghq.com/api/v1/distribution_points", + "http.useragent": "datadogpy/X (python X; os linux; arch )", + "language": "python", + "out.host": "api.datadoghq.com", + "runtime-id": "", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "requests.request", + "parent": null, + "resource": "POST /api/v1/distribution_points", + "service": "requests", + "type": "http" + } +] diff --git a/tests/integration/expected/spans/python38/sync-metrics/dynamodb.json b/tests/integration/expected/spans/python38/sync-metrics/dynamodb.json new file mode 100644 index 00000000..610c3b5f --- /dev/null +++ b/tests/integration/expected/spans/python38/sync-metrics/dynamodb.json @@ -0,0 +1,173 @@ +[ + { + "error": 0, + "label": "aws.dynamodb ExampleTableWithStream", + "meta": { + "_dd.origin": "lambda", + "_dd.p.dm": "-0", + "_dd.p.tid": "", + "_dd.peer.service.source": "peer.service", + "_inferred_span.synchronicity": "async", + "_inferred_span.tag_source": "self", + "dd_resource_key": "arn:aws:dynamodb:us-east-1:123456789012:table/ExampleTableWithStream/stream/2015-06-27T00:48:05.899", + "event_id": "c4ca4238a0b923820dcc509a6f75849b", + "event_name": "INSERT", + "event_source_arn": "arn:aws:dynamodb:us-east-1:123456789012:table/ExampleTableWithStream/stream/2015-06-27T00:48:05.899", + "event_version": "1.1", + "language": "python", + "operation_name": "aws.dynamodb", + "peer.service": "integration-tests-python", + "resource_names": "ExampleTableWithStream", + "runtime-id": "", + "size_bytes": "26", + "span.kind": "server", + "stream_view_type": "NEW_AND_OLD_IMAGES", + "tablename": "ExampleTableWithStream" + }, + "metrics": { + "_dd._inferred_span": 1.0, + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "aws.dynamodb", + "parent": null, + "resource": "ExampleTableWithStream", + "service": "ExampleTableWithStream", + "span_links": [ + { + "attributes": { + "link.kind": "span-pointer", + "ptr.dir": "u", + "ptr.hash": "e2af34d333891f765c7f02d2da80895e", + "ptr.kind": "aws.dynamodb.item" + }, + "span_id": "0000000000000000", + "trace_id": "00000000000000000000000000000000" + }, + { + "attributes": { + "link.kind": "span-pointer", + "ptr.dir": "u", + "ptr.hash": "e2af34d333891f765c7f02d2da80895e", + "ptr.kind": "aws.dynamodb.item" + }, + "span_id": "0000000000000000", + "trace_id": "00000000000000000000000000000000" + }, + { + "attributes": { + "link.kind": "span-pointer", + "ptr.dir": "u", + "ptr.hash": "e2af34d333891f765c7f02d2da80895e", + "ptr.kind": "aws.dynamodb.item" + }, + "span_id": "0000000000000000", + "trace_id": "00000000000000000000000000000000" + } + ], + "type": "web" + }, + { + "error": 0, + "label": "aws.lambda ", + "meta": { + "_dd.origin": "lambda", + "cold_start": "false", + "datadog_lambda": "", + "dd_trace": "", + "function_arn": "arn:aws:lambda:eu-west-1::function:", + "function_trigger.event_source": "dynamodb", + "function_trigger.event_source_arn": "arn:aws:dynamodb:us-east-1:123456789012:table/ExampleTableWithStream/stream/2015-06-27T00:48:05.899", + "function_version": "$LATEST", + "functionname": "", + "request_id": "", + "resource_names": "", + "span.kind": "server", + "span.name": "aws.lambda" + }, + "metrics": { + "_dd.top_level": 1 + }, + "name": "aws.lambda", + "parent": "aws.dynamodb ExampleTableWithStream", + "resource": "", + "service": "integration-tests-python", + "type": "serverless" + }, + { + "error": 0, + "label": "requests.request GET / https://datadoghq.com/", + "meta": { + "_dd.origin": "lambda", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.url": "https://datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1 + }, + "name": "requests.request", + "parent": "aws.lambda ", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request GET / https://www.datadoghq.com/", + "meta": { + "_dd.origin": "lambda", + "_dd.p.tid": "", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.url": "https://www.datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "www.datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1 + }, + "name": "requests.request", + "parent": "requests.request GET / https://datadoghq.com/", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request POST /api/v1/distribution_points https://api.datadoghq.com/api/v1/distribution_points", + "meta": { + "_dd.origin": "lambda", + "_dd.p.dm": "-0", + "_dd.p.tid": "", + "component": "requests", + "http.method": "POST", + "http.status_code": "202", + "http.url": "https://api.datadoghq.com/api/v1/distribution_points", + "http.useragent": "datadogpy/X (python X; os linux; arch )", + "language": "python", + "out.host": "api.datadoghq.com", + "runtime-id": "", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "requests.request", + "parent": null, + "resource": "POST /api/v1/distribution_points", + "service": "requests", + "type": "http" + } +] diff --git a/tests/integration/expected/spans/python38/sync-metrics/eventbridge-custom.json b/tests/integration/expected/spans/python38/sync-metrics/eventbridge-custom.json new file mode 100644 index 00000000..6d1b1262 --- /dev/null +++ b/tests/integration/expected/spans/python38/sync-metrics/eventbridge-custom.json @@ -0,0 +1,133 @@ +[ + { + "error": 0, + "label": "aws.eventbridge eventbridge.custom.event.sender", + "meta": { + "_dd.origin": "lambda", + "_dd.p.dm": "-0", + "_dd.p.tid": "", + "_dd.peer.service.source": "peer.service", + "_inferred_span.synchronicity": "async", + "_inferred_span.tag_source": "self", + "detail_type": "testdetail", + "language": "python", + "operation_name": "aws.eventbridge", + "peer.service": "integration-tests-python", + "resource_names": "eventbridge.custom.event.sender", + "runtime-id": "", + "span.kind": "server" + }, + "metrics": { + "_dd._inferred_span": 1.0, + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "aws.eventbridge", + "parent": null, + "resource": "eventbridge.custom.event.sender", + "service": "eventbridge.custom.event.sender", + "type": "web" + }, + { + "error": 0, + "label": "aws.lambda ", + "meta": { + "_dd.origin": "lambda", + "cold_start": "false", + "datadog_lambda": "", + "dd_trace": "", + "function_arn": "arn:aws:lambda:eu-west-1::function:", + "function_trigger.event_source": "eventbridge", + "function_version": "$LATEST", + "functionname": "", + "request_id": "", + "resource_names": "", + "span.kind": "server", + "span.name": "aws.lambda" + }, + "metrics": { + "_dd.top_level": 1 + }, + "name": "aws.lambda", + "parent": "aws.eventbridge eventbridge.custom.event.sender", + "resource": "", + "service": "integration-tests-python", + "type": "serverless" + }, + { + "error": 0, + "label": "requests.request GET / https://datadoghq.com/", + "meta": { + "_dd.origin": "lambda", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.url": "https://datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1 + }, + "name": "requests.request", + "parent": "aws.lambda ", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request GET / https://www.datadoghq.com/", + "meta": { + "_dd.origin": "lambda", + "_dd.p.tid": "", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.url": "https://www.datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "www.datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1 + }, + "name": "requests.request", + "parent": "requests.request GET / https://datadoghq.com/", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request POST /api/v1/distribution_points https://api.datadoghq.com/api/v1/distribution_points", + "meta": { + "_dd.origin": "lambda", + "_dd.p.dm": "-0", + "_dd.p.tid": "", + "component": "requests", + "http.method": "POST", + "http.status_code": "202", + "http.url": "https://api.datadoghq.com/api/v1/distribution_points", + "http.useragent": "datadogpy/X (python X; os linux; arch )", + "language": "python", + "out.host": "api.datadoghq.com", + "runtime-id": "", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "requests.request", + "parent": null, + "resource": "POST /api/v1/distribution_points", + "service": "requests", + "type": "http" + } +] diff --git a/tests/integration/expected/spans/python38/sync-metrics/http-api.json b/tests/integration/expected/spans/python38/sync-metrics/http-api.json new file mode 100644 index 00000000..f26d7b8b --- /dev/null +++ b/tests/integration/expected/spans/python38/sync-metrics/http-api.json @@ -0,0 +1,148 @@ +[ + { + "error": 0, + "label": "aws.httpapi GET /httpapi/get https://x02yirxc7a.execute-api.eu-west-1.amazonaws.com/httpapi/get", + "meta": { + "_dd.origin": "lambda", + "_dd.p.dm": "-0", + "_dd.p.tid": "", + "_dd.peer.service.source": "peer.service", + "_inferred_span.synchronicity": "sync", + "_inferred_span.tag_source": "self", + "apiid": "x02yirxc7a", + "apiname": "x02yirxc7a", + "dd_resource_key": "arn:aws:apigateway:eu-west-1::/restapis/x02yirxc7a/stages/$default", + "endpoint": "/httpapi/get", + "http.method": "GET", + "http.protocol": "HTTP/1.1", + "http.route": "/httpapi/get", + "http.source_ip": "38.122.226.210", + "http.status_code": "200", + "http.url": "https://x02yirxc7a.execute-api.eu-west-1.amazonaws.com/httpapi/get", + "http.useragent": "curl/7.64.1", + "language": "python", + "peer.service": "integration-tests-python", + "request_id": "", + "resource_names": "GET /httpapi/get", + "runtime-id": "", + "stage": "$default" + }, + "metrics": { + "_dd._inferred_span": 1.0, + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "aws.httpapi", + "parent": null, + "resource": "GET /httpapi/get", + "service": "x02yirxc7a.execute-api.eu-west-1.amazonaws.com", + "type": "web" + }, + { + "error": 0, + "label": "aws.lambda https://x02yirxc7a.execute-api.eu-west-1.amazonaws.com/httpapi/get", + "meta": { + "_dd.origin": "lambda", + "cold_start": "false", + "datadog_lambda": "", + "dd_trace": "", + "function_arn": "arn:aws:lambda:eu-west-1::function:", + "function_trigger.event_source": "api-gateway", + "function_trigger.event_source_arn": "arn:aws:apigateway:eu-west-1::/restapis/x02yirxc7a/stages/$default", + "function_version": "$LATEST", + "functionname": "", + "http.method": "GET", + "http.route": "/httpapi/get", + "http.status_code": "200", + "http.url": "https://x02yirxc7a.execute-api.eu-west-1.amazonaws.com/httpapi/get", + "request_id": "", + "resource_names": "", + "span.kind": "server", + "span.name": "aws.lambda" + }, + "metrics": { + "_dd.top_level": 1 + }, + "name": "aws.lambda", + "parent": "aws.httpapi GET /httpapi/get https://x02yirxc7a.execute-api.eu-west-1.amazonaws.com/httpapi/get", + "resource": "", + "service": "integration-tests-python", + "type": "serverless" + }, + { + "error": 0, + "label": "requests.request GET / https://datadoghq.com/", + "meta": { + "_dd.origin": "lambda", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.url": "https://datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1 + }, + "name": "requests.request", + "parent": "aws.lambda https://x02yirxc7a.execute-api.eu-west-1.amazonaws.com/httpapi/get", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request GET / https://www.datadoghq.com/", + "meta": { + "_dd.origin": "lambda", + "_dd.p.tid": "", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.url": "https://www.datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "www.datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1 + }, + "name": "requests.request", + "parent": "requests.request GET / https://datadoghq.com/", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request POST /api/v1/distribution_points https://api.datadoghq.com/api/v1/distribution_points", + "meta": { + "_dd.origin": "lambda", + "_dd.p.dm": "-0", + "_dd.p.tid": "", + "component": "requests", + "http.method": "POST", + "http.status_code": "202", + "http.url": "https://api.datadoghq.com/api/v1/distribution_points", + "http.useragent": "datadogpy/X (python X; os linux; arch )", + "language": "python", + "out.host": "api.datadoghq.com", + "runtime-id": "", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "requests.request", + "parent": null, + "resource": "POST /api/v1/distribution_points", + "service": "requests", + "type": "http" + } +] diff --git a/tests/integration/expected/spans/python38/sync-metrics/kinesis.json b/tests/integration/expected/spans/python38/sync-metrics/kinesis.json new file mode 100644 index 00000000..24eb6dc7 --- /dev/null +++ b/tests/integration/expected/spans/python38/sync-metrics/kinesis.json @@ -0,0 +1,141 @@ +[ + { + "error": 0, + "label": "aws.kinesis EXAMPLE", + "meta": { + "_dd.origin": "lambda", + "_dd.p.dm": "-0", + "_dd.p.tid": "", + "_dd.peer.service.source": "peer.service", + "_inferred_span.synchronicity": "async", + "_inferred_span.tag_source": "self", + "dd_resource_key": "arn:aws:kinesis:EXAMPLE", + "event_id": "shardId-000000000000:49545115243490985018280067714973144582180062593244200961", + "event_name": "aws:kinesis:record", + "event_source_arn": "arn:aws:kinesis:EXAMPLE", + "event_version": "1.0", + "language": "python", + "operation_name": "aws.kinesis", + "partition_key": "partitionKey-03", + "peer.service": "integration-tests-python", + "resource_names": "EXAMPLE", + "runtime-id": "", + "shardid": "shardId-000000000000", + "span.kind": "server", + "streamname": "EXAMPLE" + }, + "metrics": { + "_dd._inferred_span": 1.0, + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "aws.kinesis", + "parent": null, + "resource": "EXAMPLE", + "service": "EXAMPLE", + "type": "web" + }, + { + "error": 0, + "label": "aws.lambda ", + "meta": { + "_dd.origin": "lambda", + "cold_start": "false", + "datadog_lambda": "", + "dd_trace": "", + "function_arn": "arn:aws:lambda:eu-west-1::function:", + "function_trigger.event_source": "kinesis", + "function_trigger.event_source_arn": "arn:aws:kinesis:EXAMPLE", + "function_version": "$LATEST", + "functionname": "", + "request_id": "", + "resource_names": "", + "span.kind": "server", + "span.name": "aws.lambda" + }, + "metrics": { + "_dd.top_level": 1 + }, + "name": "aws.lambda", + "parent": "aws.kinesis EXAMPLE", + "resource": "", + "service": "integration-tests-python", + "type": "serverless" + }, + { + "error": 0, + "label": "requests.request GET / https://datadoghq.com/", + "meta": { + "_dd.origin": "lambda", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.url": "https://datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1 + }, + "name": "requests.request", + "parent": "aws.lambda ", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request GET / https://www.datadoghq.com/", + "meta": { + "_dd.origin": "lambda", + "_dd.p.tid": "", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.url": "https://www.datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "www.datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1 + }, + "name": "requests.request", + "parent": "requests.request GET / https://datadoghq.com/", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request POST /api/v1/distribution_points https://api.datadoghq.com/api/v1/distribution_points", + "meta": { + "_dd.origin": "lambda", + "_dd.p.dm": "-0", + "_dd.p.tid": "", + "component": "requests", + "http.method": "POST", + "http.status_code": "202", + "http.url": "https://api.datadoghq.com/api/v1/distribution_points", + "http.useragent": "datadogpy/X (python X; os linux; arch )", + "language": "python", + "out.host": "api.datadoghq.com", + "runtime-id": "", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "requests.request", + "parent": null, + "resource": "POST /api/v1/distribution_points", + "service": "requests", + "type": "http" + } +] diff --git a/tests/integration/expected/spans/python38/sync-metrics/s3.json b/tests/integration/expected/spans/python38/sync-metrics/s3.json new file mode 100644 index 00000000..b9462190 --- /dev/null +++ b/tests/integration/expected/spans/python38/sync-metrics/s3.json @@ -0,0 +1,152 @@ +[ + { + "error": 0, + "label": "aws.lambda ", + "meta": { + "_dd.origin": "lambda", + "cold_start": "false", + "datadog_lambda": "", + "dd_trace": "", + "function_arn": "arn:aws:lambda:eu-west-1::function:", + "function_trigger.event_source": "s3", + "function_trigger.event_source_arn": "arn:aws:s3:::example-bucket", + "function_version": "$LATEST", + "functionname": "", + "request_id": "", + "resource_names": "", + "span.kind": "server", + "span.name": "aws.lambda" + }, + "metrics": { + "_dd.top_level": 1 + }, + "name": "aws.lambda", + "parent": "aws.s3 example-bucket", + "resource": "", + "service": "integration-tests-python", + "type": "serverless" + }, + { + "error": 0, + "label": "aws.s3 example-bucket", + "meta": { + "_dd.origin": "lambda", + "_dd.p.dm": "-0", + "_dd.p.tid": "", + "_dd.peer.service.source": "peer.service", + "_inferred_span.synchronicity": "async", + "_inferred_span.tag_source": "self", + "bucket_arn": "arn:aws:s3:::example-bucket", + "bucketname": "example-bucket", + "dd_resource_key": "arn:aws:s3:::example-bucket", + "event_name": "ObjectCreated:Put", + "language": "python", + "object_etag": "0123456789abcdef0123456789abcdef", + "object_key": "test/key", + "object_size": "1024", + "operation_name": "aws.s3", + "peer.service": "integration-tests-python", + "resource_names": "example-bucket", + "runtime-id": "", + "span.kind": "server" + }, + "metrics": { + "_dd._inferred_span": 1.0, + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "aws.s3", + "parent": null, + "resource": "example-bucket", + "service": "example-bucket", + "span_links": [ + { + "attributes": { + "link.kind": "span-pointer", + "ptr.dir": "u", + "ptr.hash": "1dc3e5d00dae48c1f07d95371a747788", + "ptr.kind": "aws.s3.object" + }, + "span_id": "0000000000000000", + "trace_id": "00000000000000000000000000000000" + } + ], + "type": "web" + }, + { + "error": 0, + "label": "requests.request GET / https://datadoghq.com/", + "meta": { + "_dd.origin": "lambda", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.url": "https://datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1 + }, + "name": "requests.request", + "parent": "aws.lambda ", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request GET / https://www.datadoghq.com/", + "meta": { + "_dd.origin": "lambda", + "_dd.p.tid": "", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.url": "https://www.datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "www.datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1 + }, + "name": "requests.request", + "parent": "requests.request GET / https://datadoghq.com/", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request POST /api/v1/distribution_points https://api.datadoghq.com/api/v1/distribution_points", + "meta": { + "_dd.origin": "lambda", + "_dd.p.dm": "-0", + "_dd.p.tid": "", + "component": "requests", + "http.method": "POST", + "http.status_code": "202", + "http.url": "https://api.datadoghq.com/api/v1/distribution_points", + "http.useragent": "datadogpy/X (python X; os linux; arch )", + "language": "python", + "out.host": "api.datadoghq.com", + "runtime-id": "", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "requests.request", + "parent": null, + "resource": "POST /api/v1/distribution_points", + "service": "requests", + "type": "http" + } +] diff --git a/tests/integration/expected/spans/python38/sync-metrics/sns.json b/tests/integration/expected/spans/python38/sync-metrics/sns.json new file mode 100644 index 00000000..a67fb4ac --- /dev/null +++ b/tests/integration/expected/spans/python38/sync-metrics/sns.json @@ -0,0 +1,139 @@ +[ + { + "error": 0, + "label": "aws.lambda ", + "meta": { + "_dd.origin": "lambda", + "cold_start": "false", + "datadog_lambda": "", + "dd_trace": "", + "function_arn": "arn:aws:lambda:eu-west-1::function:", + "function_trigger.event_source": "sns", + "function_trigger.event_source_arn": "arn:aws:sns:us-east-2:123456789012:sns-lambda", + "function_version": "$LATEST", + "functionname": "", + "request_id": "", + "resource_names": "", + "span.kind": "server", + "span.name": "aws.lambda" + }, + "metrics": { + "_dd.top_level": 1 + }, + "name": "aws.lambda", + "parent": "aws.sns sns-lambda", + "resource": "", + "service": "integration-tests-python", + "type": "serverless" + }, + { + "error": 0, + "label": "aws.sns sns-lambda", + "meta": { + "_dd.origin": "lambda", + "_dd.p.dm": "-0", + "_dd.p.tid": "", + "_dd.peer.service.source": "peer.service", + "_inferred_span.synchronicity": "async", + "_inferred_span.tag_source": "self", + "dd_resource_key": "arn:aws:sns:us-east-2:123456789012:sns-lambda", + "language": "python", + "message_id": "95df01b4-ee98-5cb9-9903-4c221d41eb5e", + "operation_name": "aws.sns", + "peer.service": "integration-tests-python", + "resource_names": "sns-lambda", + "runtime-id": "", + "span.kind": "server", + "subject": "TestInvoke", + "topic_arn": "arn:aws:sns:us-east-2:123456789012:sns-lambda", + "topicname": "sns-lambda", + "type": "Notification" + }, + "metrics": { + "_dd._inferred_span": 1.0, + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "aws.sns", + "parent": null, + "resource": "sns-lambda", + "service": "sns-lambda", + "type": "web" + }, + { + "error": 0, + "label": "requests.request GET / https://datadoghq.com/", + "meta": { + "_dd.origin": "lambda", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.url": "https://datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1 + }, + "name": "requests.request", + "parent": "aws.lambda ", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request GET / https://www.datadoghq.com/", + "meta": { + "_dd.origin": "lambda", + "_dd.p.tid": "", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.url": "https://www.datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "www.datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1 + }, + "name": "requests.request", + "parent": "requests.request GET / https://datadoghq.com/", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request POST /api/v1/distribution_points https://api.datadoghq.com/api/v1/distribution_points", + "meta": { + "_dd.origin": "lambda", + "_dd.p.dm": "-0", + "_dd.p.tid": "", + "component": "requests", + "http.method": "POST", + "http.status_code": "202", + "http.url": "https://api.datadoghq.com/api/v1/distribution_points", + "http.useragent": "datadogpy/X (python X; os linux; arch )", + "language": "python", + "out.host": "api.datadoghq.com", + "runtime-id": "", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "requests.request", + "parent": null, + "resource": "POST /api/v1/distribution_points", + "service": "requests", + "type": "http" + } +] diff --git a/tests/integration/expected/spans/python38/sync-metrics/sqs.json b/tests/integration/expected/spans/python38/sync-metrics/sqs.json new file mode 100644 index 00000000..8aeb5c34 --- /dev/null +++ b/tests/integration/expected/spans/python38/sync-metrics/sqs.json @@ -0,0 +1,138 @@ +[ + { + "error": 0, + "label": "aws.lambda ", + "meta": { + "_dd.origin": "lambda", + "cold_start": "false", + "datadog_lambda": "", + "dd_trace": "", + "function_arn": "arn:aws:lambda:eu-west-1::function:", + "function_trigger.event_source": "sqs", + "function_trigger.event_source_arn": "arn:aws:sqs:us-east-2:123456789012:my-queue", + "function_version": "$LATEST", + "functionname": "", + "request_id": "", + "resource_names": "", + "span.kind": "server", + "span.name": "aws.lambda" + }, + "metrics": { + "_dd.top_level": 1 + }, + "name": "aws.lambda", + "parent": "aws.sqs my-queue", + "resource": "", + "service": "integration-tests-python", + "type": "serverless" + }, + { + "error": 0, + "label": "aws.sqs my-queue", + "meta": { + "_dd.origin": "lambda", + "_dd.p.dm": "-0", + "_dd.p.tid": "", + "_dd.peer.service.source": "peer.service", + "_inferred_span.synchronicity": "async", + "_inferred_span.tag_source": "self", + "dd_resource_key": "arn:aws:sqs:us-east-2:123456789012:my-queue", + "event_source_arn": "arn:aws:sqs:us-east-2:123456789012:my-queue", + "language": "python", + "operation_name": "aws.sqs", + "peer.service": "integration-tests-python", + "queuename": "my-queue", + "receipt_handle": "AQEBwJnKyrHigUMZj6rYigCgxlaS3SLy0a...", + "resource_names": "my-queue", + "runtime-id": "", + "sender_id": "AIDAIENQZJOLO23YVJ4VO", + "span.kind": "server" + }, + "metrics": { + "_dd._inferred_span": 1.0, + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "aws.sqs", + "parent": null, + "resource": "my-queue", + "service": "my-queue", + "type": "web" + }, + { + "error": 0, + "label": "requests.request GET / https://datadoghq.com/", + "meta": { + "_dd.origin": "lambda", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.url": "https://datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1 + }, + "name": "requests.request", + "parent": "aws.lambda ", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request GET / https://www.datadoghq.com/", + "meta": { + "_dd.origin": "lambda", + "_dd.p.tid": "", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.url": "https://www.datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "www.datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1 + }, + "name": "requests.request", + "parent": "requests.request GET / https://datadoghq.com/", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request POST /api/v1/distribution_points https://api.datadoghq.com/api/v1/distribution_points", + "meta": { + "_dd.origin": "lambda", + "_dd.p.dm": "-0", + "_dd.p.tid": "", + "component": "requests", + "http.method": "POST", + "http.status_code": "202", + "http.url": "https://api.datadoghq.com/api/v1/distribution_points", + "http.useragent": "datadogpy/X (python X; os linux; arch )", + "language": "python", + "out.host": "api.datadoghq.com", + "runtime-id": "", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "requests.request", + "parent": null, + "resource": "POST /api/v1/distribution_points", + "service": "requests", + "type": "http" + } +] diff --git a/tests/integration/expected/spans/python38/sync-metrics/websocket.json b/tests/integration/expected/spans/python38/sync-metrics/websocket.json new file mode 100644 index 00000000..3fdef7d5 --- /dev/null +++ b/tests/integration/expected/spans/python38/sync-metrics/websocket.json @@ -0,0 +1,146 @@ +[ + { + "error": 0, + "label": "aws.apigateway.websocket $default https://p62c47itsb.execute-api.eu-west-1.amazonaws.com$default", + "meta": { + "_dd.origin": "lambda", + "_dd.p.dm": "-0", + "_dd.p.tid": "", + "_dd.peer.service.source": "peer.service", + "_inferred_span.synchronicity": "sync", + "_inferred_span.tag_source": "self", + "apiid": "p62c47itsb", + "apiname": "p62c47itsb", + "connection_id": "Fc5SzcoYGjQCJlg=", + "dd_resource_key": "arn:aws:apigateway:eu-west-1::/restapis/p62c47itsb/stages/dev", + "endpoint": "$default", + "event_type": "MESSAGE", + "http.status_code": "200", + "http.url": "https://p62c47itsb.execute-api.eu-west-1.amazonaws.com$default", + "language": "python", + "message_direction": "IN", + "operation_name": "aws.apigateway.websocket", + "peer.service": "integration-tests-python", + "request_id": "", + "resource_names": "$default", + "runtime-id": "", + "span.kind": "server", + "stage": "dev" + }, + "metrics": { + "_dd._inferred_span": 1.0, + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "aws.apigateway.websocket", + "parent": null, + "resource": "$default", + "service": "p62c47itsb.execute-api.eu-west-1.amazonaws.com", + "type": "web" + }, + { + "error": 0, + "label": "aws.lambda https://p62c47itsb.execute-api.eu-west-1.amazonaws.com", + "meta": { + "_dd.origin": "lambda", + "cold_start": "false", + "datadog_lambda": "", + "dd_trace": "", + "function_arn": "arn:aws:lambda:eu-west-1::function:", + "function_trigger.event_source": "api-gateway", + "function_trigger.event_source_arn": "arn:aws:apigateway:eu-west-1::/restapis/p62c47itsb/stages/dev", + "function_version": "$LATEST", + "functionname": "", + "http.status_code": "200", + "http.url": "https://p62c47itsb.execute-api.eu-west-1.amazonaws.com", + "request_id": "", + "resource_names": "", + "span.kind": "server", + "span.name": "aws.lambda" + }, + "metrics": { + "_dd.top_level": 1 + }, + "name": "aws.lambda", + "parent": "aws.apigateway.websocket $default https://p62c47itsb.execute-api.eu-west-1.amazonaws.com$default", + "resource": "", + "service": "integration-tests-python", + "type": "serverless" + }, + { + "error": 0, + "label": "requests.request GET / https://datadoghq.com/", + "meta": { + "_dd.origin": "lambda", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.url": "https://datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1 + }, + "name": "requests.request", + "parent": "aws.lambda https://p62c47itsb.execute-api.eu-west-1.amazonaws.com", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request GET / https://www.datadoghq.com/", + "meta": { + "_dd.origin": "lambda", + "_dd.p.tid": "", + "component": "requests", + "http.method": "GET", + "http.status_code": "200", + "http.url": "https://www.datadoghq.com/", + "http.useragent": "python-requests/X", + "out.host": "www.datadoghq.com", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1 + }, + "name": "requests.request", + "parent": "requests.request GET / https://datadoghq.com/", + "resource": "GET /", + "service": "requests", + "type": "http" + }, + { + "error": 0, + "label": "requests.request POST /api/v1/distribution_points https://api.datadoghq.com/api/v1/distribution_points", + "meta": { + "_dd.origin": "lambda", + "_dd.p.dm": "-0", + "_dd.p.tid": "", + "component": "requests", + "http.method": "POST", + "http.status_code": "202", + "http.url": "https://api.datadoghq.com/api/v1/distribution_points", + "http.useragent": "datadogpy/X (python X; os linux; arch )", + "language": "python", + "out.host": "api.datadoghq.com", + "runtime-id": "", + "span.kind": "client" + }, + "metrics": { + "_dd.measured": 1, + "_dd.top_level": 1, + "_sampling_priority_v1": 1, + "process_id": "" + }, + "name": "requests.request", + "parent": null, + "resource": "POST /api/v1/distribution_points", + "service": "requests", + "type": "http" + } +] diff --git a/tests/integration/functions/baseline.py b/tests/integration/functions/baseline.py new file mode 100644 index 00000000..3590cb18 --- /dev/null +++ b/tests/integration/functions/baseline.py @@ -0,0 +1,38 @@ +import requests + +from datadog_lambda.metric import lambda_metric +from datadog_lambda.wrapper import datadog_lambda_wrapper + + +@datadog_lambda_wrapper +def handle(event, context): + # Parse request ID and record IDs out of the event to include in the response + request_id = event.get("requestContext", {}).get("requestId") + event_records = event.get("Records", []) + + record_ids = [] + for record in event_records: + # SQS + if record.get("messageId"): + record_ids.append(record["messageId"]) + # SNS + if record.get("Sns", {}).get("MessageId"): + record_ids.append(record["Sns"]["MessageId"]) + + # Generate custom metrics + lambda_metric("hello.dog", 1, tags=["team:serverless", "role:hello"]) + lambda_metric( + "tests.integration.count", 21, tags=["test:integration", "role:hello"] + ) + + # Make HTTP calls to test ddtrace instrumentation + requests.get("https://datadoghq.com") + + return { + "statusCode": 200, + "body": { + "message": "hello, dog!", + "request_id": request_id, + "event_record_ids": record_ids, + }, + } diff --git a/tests/integration/harness/__init__.py b/tests/integration/harness/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/integration/harness/aws.py b/tests/integration/harness/aws.py new file mode 100644 index 00000000..27724d47 --- /dev/null +++ b/tests/integration/harness/aws.py @@ -0,0 +1,378 @@ +"""Deploy the test stack, invoke functions, and read their logs.""" + +from __future__ import annotations + +import functools +import json +import os +import shutil +import subprocess +import sys +import time +import zipfile +from dataclasses import dataclass +from typing import Any, Callable, Dict, List, Optional + +import boto3 +from botocore.config import Config +from botocore.exceptions import ClientError + +from . import requirements as requirements_mod +from . import settings as settings_mod +from .intake import IntakeRequest, parse_requests +from .logs import InvocationLogs, split_invocations + +BUILD_DIR = settings_mod.INTEGRATION_DIR / ".build" +_BOTO_CONFIG = Config(retries={"max_attempts": 10, "mode": "adaptive"}) + + +@functools.lru_cache(maxsize=None) +def _client(service: str, region: str): + """One client per service and region; boto3 clients are thread-safe.""" + return boto3.client(service, region_name=region, config=_BOTO_CONFIG) + + +# -------------------------------------------------------------------------- +# Stack lifecycle +# -------------------------------------------------------------------------- + + +def stage_artifacts(s: settings_mod.Settings) -> None: + """Put the layer zip and the requirements layer where template.yaml expects them.""" + if not s.layer_zip.exists(): + raise RuntimeError( + "Layer %s not found. Build it first: PYTHON_VERSION=%s ARCH=%s ./scripts/build_layers.sh" + % (s.layer_zip, s.python_version, s.arch) + ) + if BUILD_DIR.exists(): + shutil.rmtree(BUILD_DIR) + BUILD_DIR.mkdir(parents=True) + shutil.copy(s.layer_zip, BUILD_DIR / "datadog_layer.zip") + + # pip would evaluate markers against CI's Python, not the target runtime. + requirements = BUILD_DIR / "requirements.txt" + source = (settings_mod.INTEGRATION_DIR / "requirements.txt").read_text() + resolved = requirements_mod.resolve(source.splitlines(), s.python_version, s.arch) + requirements.write_text("\n".join(resolved) + "\n") + print("Requirements layer for %s: %s" % (s.runtime, ", ".join(resolved))) + + # Built here (not by sam package) so the extension keeps its executable bit. + mock_intake = settings_mod.INTEGRATION_DIR / "mock_intake" / "mock-intake" + with zipfile.ZipFile(BUILD_DIR / "mock_intake_layer.zip", "w") as zf: + info = zipfile.ZipInfo("extensions/mock-intake") + info.external_attr = 0o100755 << 16 + info.compress_type = zipfile.ZIP_DEFLATED + zf.writestr(info, mock_intake.read_bytes()) + + platform = "manylinux2014_" + ("x86_64" if s.arch == "amd64" else "aarch64") + subprocess.run( + [ + sys.executable, + "-m", + "pip", + "install", + "--quiet", + "--no-deps", + "--only-binary=:all:", + "--platform", + platform, + "--implementation", + "cp", + "--python-version", + s.python_version, + "-r", + str(requirements), + "-t", + str(BUILD_DIR / "requirements_layer" / "python"), + ], + check=True, + ) + + +def extension_layer_arn(s: settings_mod.Settings) -> Optional[str]: + if not s.extension_enabled: + return None + return "%s:%s" % (s.extension_layer_base_arn, s.extension_layer_version) + + +# CloudFormation's TemplateBody limit; larger templates go through S3. +_MAX_TEMPLATE_BODY = 51200 + + +def package(s: settings_mod.Settings) -> dict: + """Upload code and layers to S3 and return the packaged SAM template.""" + from samtranslator.yaml_helper import yaml_parse + + packaged = BUILD_DIR / "packaged.yaml" + subprocess.run( + [ + "sam", + "package", + "--template-file", + str(settings_mod.INTEGRATION_DIR / "template.yaml"), + "--s3-bucket", + settings_mod.DEPLOYMENT_BUCKET, + "--s3-prefix", + s.stack_name, + "--region", + s.region, + "--output-template-file", + str(packaged), + ], + cwd=str(settings_mod.INTEGRATION_DIR), + env=dict(os.environ, SAM_CLI_TELEMETRY="0"), + check=True, + ) + return yaml_parse(packaged.read_text()) + + +def translate(sam_template: dict, region: str) -> dict: + """Expand the SAM transform locally into plain CloudFormation. + + The CI deployer role may not use the Serverless transform (that needs + cloudformation:CreateChangeSet on the transform), so the stack is created + from the expanded template instead. No parameter values are passed: Refs + stay in the template and CloudFormation resolves them, so secrets are never + written into it. + """ + from samtranslator.parser.parser import Parser + from samtranslator.translator.translator import Translator + + translator = Translator( + managed_policy_map={}, + sam_parser=Parser(), + boto_session=boto3.Session(region_name=region), + ) + return translator.translate( + sam_template, parameter_values={}, get_managed_policy_map=lambda: {} + ) + + +def _print_stack_failures(cfn, stack_name: str) -> None: + try: + events = cfn.describe_stack_events(StackName=stack_name)["StackEvents"] + except ClientError: + return + for e in reversed(events): + if e["ResourceStatus"].endswith("_FAILED"): + print( + " %s %s: %s" + % ( + e["LogicalResourceId"], + e["ResourceStatus"], + e.get("ResourceStatusReason", ""), + ) + ) + + +def deploy(s: settings_mod.Settings, mock_intake_api_key: str) -> None: + stage_artifacts(s) + parameters = { + "RunId": s.run_id, + "Runtime": s.runtime, + "RuntimeKey": s.runtime_key, + "Architecture": s.lambda_arch, + "LambdaRoleArn": settings_mod.LAMBDA_ROLE_ARN, + "DdApiKey": s.dd_api_key, + "DdApiKeySecretArn": s.dd_api_key_secret_arn, + "MockIntakeApiKey": mock_intake_api_key, + "ExtensionLayerArn": extension_layer_arn(s) or "", + } + template = translate(package(s), s.region) + body = json.dumps(template) + (BUILD_DIR / "cloudformation.json").write_text(json.dumps(template, indent=2)) + + cfn = _client("cloudformation", s.region) + kwargs = { + "StackName": s.stack_name, + "Parameters": [ + {"ParameterKey": k, "ParameterValue": v} for k, v in parameters.items() + ], + # Keep failed resources around long enough to report why they failed; + # the caller deletes the stack afterwards. + "OnFailure": "DO_NOTHING", + } + if len(body.encode("utf-8")) <= _MAX_TEMPLATE_BODY: + kwargs["TemplateBody"] = body + else: + key = "%s/cloudformation.json" % s.stack_name + _client("s3", s.region).put_object( + Bucket=settings_mod.DEPLOYMENT_BUCKET, Key=key, Body=body.encode("utf-8") + ) + kwargs["TemplateURL"] = "https://%s.s3.%s.amazonaws.com/%s" % ( + settings_mod.DEPLOYMENT_BUCKET, + s.region, + key, + ) + + print("Creating stack %s" % s.stack_name, flush=True) + cfn.create_stack(**kwargs) + try: + cfn.get_waiter("stack_create_complete").wait( + StackName=s.stack_name, WaiterConfig={"Delay": 10, "MaxAttempts": 90} + ) + except Exception: + print("Stack %s failed to create:" % s.stack_name) + _print_stack_failures(cfn, s.stack_name) + raise RuntimeError("creating stack %s failed" % s.stack_name) + print("Stack %s created" % s.stack_name, flush=True) + + +def stack_outputs(s: settings_mod.Settings) -> Dict[str, str]: + cfn = _client("cloudformation", s.region) + stack = cfn.describe_stacks(StackName=s.stack_name)["Stacks"][0] + return {o["OutputKey"]: o["OutputValue"] for o in stack.get("Outputs", [])} + + +def delete(s: settings_mod.Settings) -> None: + cfn = _client("cloudformation", s.region) + print("Deleting stack %s" % s.stack_name) + cfn.delete_stack(StackName=s.stack_name) + cfn.get_waiter("stack_delete_complete").wait( + StackName=s.stack_name, WaiterConfig={"Delay": 10, "MaxAttempts": 90} + ) + # Remove the packaged artifacts sam uploaded for this stack. + boto3.resource("s3", region_name=s.region).Bucket( + settings_mod.DEPLOYMENT_BUCKET + ).objects.filter(Prefix=s.stack_name + "/").delete() + + +# -------------------------------------------------------------------------- +# Invocations and logs +# -------------------------------------------------------------------------- + + +@dataclass +class Invocation: + function_name: str + request_id: str + response: Any + function_error: Optional[str] + logs: Optional[InvocationLogs] = None + + +def invoke(region: str, function_name: str, event: Any) -> Invocation: + resp = _client("lambda", region).invoke( + FunctionName=function_name, + Payload=json.dumps(event).encode("utf-8"), + ) + payload = resp["Payload"].read() + try: + response = json.loads(payload) if payload else None + except ValueError: + response = payload.decode("utf-8", "replace") + return Invocation( + function_name=function_name, + # For Invoke, the API request ID is the invocation's request ID. + request_id=resp["ResponseMetadata"]["RequestId"], + response=response, + function_error=resp.get("FunctionError"), + ) + + +def force_cold_start(region: str, function_name: str) -> None: + """Make the next invocation start a new execution environment, by changing + an environment variable (Lambda recycles environments on config changes).""" + client = _client("lambda", region) + config = client.get_function_configuration(FunctionName=function_name) + variables = dict(config.get("Environment", {}).get("Variables", {})) + variables["INTEGRATION_TEST_SANDBOX_ID"] = "%d" % time.time_ns() + client.update_function_configuration( + FunctionName=function_name, Environment={"Variables": variables} + ) + client.get_waiter("function_updated_v2").wait(FunctionName=function_name) + + +def _read_log_group(logs_client, log_group: str) -> Dict[str, List[str]]: + """Return {log_stream_name: [messages in ingestion order]}.""" + streams: Dict[str, List[str]] = {} + paginator = logs_client.get_paginator("describe_log_streams") + try: + pages = list(paginator.paginate(logGroupName=log_group)) + except logs_client.exceptions.ResourceNotFoundException: + return streams + for page in pages: + for stream in page["logStreams"]: + name = stream["logStreamName"] + messages: List[str] = [] + token = None + while True: + kwargs = { + "logGroupName": log_group, + "logStreamName": name, + "startFromHead": True, + } + if token: + kwargs["nextToken"] = token + resp = logs_client.get_log_events(**kwargs) + messages.extend(e["message"] for e in resp["events"]) + if resp.get("nextForwardToken") in (None, token): + break + token = resp["nextForwardToken"] + streams[name] = messages + return streams + + +def read_log_lines(region: str, function_name: str) -> List[str]: + """Every log line of a function, stream by stream.""" + streams = _read_log_group(_client("logs", region), "/aws/lambda/" + function_name) + return [line for lines in streams.values() for line in lines] + + +def _poll( + fetch: Callable[[], Any], done: Callable[[Any], bool], timeout_s: float, what: str +) -> Any: + deadline = time.monotonic() + timeout_s + delay = 3.0 + while True: + result = fetch() + if done(result): + return result + if time.monotonic() > deadline: + raise TimeoutError("Timed out after %ss waiting for %s" % (timeout_s, what)) + time.sleep(delay) + delay = min(delay * 1.5, 15.0) + + +def wait_for_logs( + region: str, function_name: str, request_ids: List[str], timeout_s: float = 180 +) -> Dict[str, InvocationLogs]: + """Wait until every request ID has a REPORT line in CloudWatch, then parse.""" + logs_client = _client("logs", region) + log_group = "/aws/lambda/" + function_name + + def fetch() -> Dict[str, InvocationLogs]: + parsed: Dict[str, InvocationLogs] = {} + for lines in _read_log_group(logs_client, log_group).values(): + parsed.update(split_invocations(lines)) + return parsed + + def done(parsed: Dict[str, InvocationLogs]) -> bool: + return all(rid in parsed and parsed[rid].complete for rid in request_ids) + + return _poll( + fetch, + done, + timeout_s, + "logs of %d invocations of %s" % (len(request_ids), function_name), + ) + + +def wait_for_intake( + region: str, + function_name: str, + done: Callable[[List[IntakeRequest]], bool], + timeout_s: float = 180, +) -> List[IntakeRequest]: + """Poll a function's logs until the requests its mock intake extension + recorded satisfy `done(requests)`.""" + logs_client = _client("logs", region) + log_group = "/aws/lambda/" + function_name + + def fetch() -> List[IntakeRequest]: + lines: List[str] = [] + for stream_lines in _read_log_group(logs_client, log_group).values(): + lines.extend(stream_lines) + return parse_requests(lines) + + return _poll(fetch, done, timeout_s, "mock intake requests") diff --git a/tests/integration/harness/intake.py b/tests/integration/harness/intake.py new file mode 100644 index 00000000..1849b76c --- /dev/null +++ b/tests/integration/harness/intake.py @@ -0,0 +1,104 @@ +"""Reassemble requests recorded by the mock intake extension (mock_intake/mock-intake). + +Pure Python apart from the optional zstandard dependency, so it is unit tested +offline. Decoding payload formats (protobuf traces, series, sketches) is left +to the tests that need it. +""" + +from __future__ import annotations + +import base64 +import gzip +import json +import zlib +from dataclasses import dataclass +from typing import Dict, List + +MARKER = "MOCK_INTAKE_REQUEST " + + +@dataclass +class IntakeRequest: + id: str + method: str + path: str + query: str + headers: Dict[str, str] + raw_body: bytes + + @property + def normalized_path(self) -> str: + # Function URLs end in "/", so "/api/v0.2/traces" arrives as "//api/...". + return "/" + self.path.lstrip("/") + + @property + def body(self) -> bytes: + """The body with any Content-Encoding removed.""" + return decompress(self.raw_body, self.headers.get("content-encoding", "")) + + def json(self): + return json.loads(self.body) + + +def _zstd_decompress(data: bytes) -> bytes: + try: + from compression import zstd # Python 3.14+ + + return zstd.decompress(data) + except ImportError: + pass + import zstandard + + return zstandard.ZstdDecompressor().decompressobj().decompress(data) + + +def decompress(data: bytes, encoding: str) -> bytes: + encoding = (encoding or "").strip().lower() + if encoding in ("", "identity"): + return data + if encoding == "gzip": + return gzip.decompress(data) + if encoding == "deflate": + try: + return zlib.decompress(data) + except zlib.error: + return zlib.decompress(data, -zlib.MAX_WBITS) + if encoding == "zstd": + return _zstd_decompress(data) + raise ValueError("unsupported Content-Encoding %r" % encoding) + + +def parse_requests(lines: List[str]) -> List[IntakeRequest]: + """Build requests from mock intake log lines. Ignores unrelated lines and + drops requests whose chunks are not all present yet.""" + parts: Dict[str, Dict] = {} + order: List[str] = [] + for line in lines: + index = line.find(MARKER) + if index < 0: + continue + record = json.loads(line[index + len(MARKER) :]) + entry = parts.get(record["id"]) + if entry is None: + entry = parts[record["id"]] = {"record": record, "chunks": {}} + order.append(record["id"]) + entry["chunks"][record["chunk"]] = record["body_b64"] + + requests = [] + for request_id in order: + entry = parts[request_id] + record = entry["record"] + if len(entry["chunks"]) != record["chunks"]: + continue + body_b64 = "".join(entry["chunks"][i] for i in range(record["chunks"])) + requests.append( + IntakeRequest( + id=request_id, + method=record.get("method") or "", + path=record.get("path") or "", + query=record.get("query") or "", + headers=record.get("headers") or {}, + raw_body=base64.b64decode(body_b64), + ) + ) + return requests diff --git a/tests/integration/harness/logs.py b/tests/integration/harness/logs.py new file mode 100644 index 00000000..89bf7bc7 --- /dev/null +++ b/tests/integration/harness/logs.py @@ -0,0 +1,292 @@ +"""Parse Lambda CloudWatch log lines into typed objects. + +Pure Python, no AWS dependencies, so it is unit tested offline in +tests/test_integration_harness.py. + +With DD_INTEGRATION_TEST=true and no extension, an invocation's logs contain: + * one JSON line per trace payload: {"traces": [[span, ...], ...]} + * one JSON line per metric when DD_FLUSH_TO_LOG=true: + {"m": name, "v": value, "e": epoch, "t": [tags]} + * one line per outgoing `requests` call (datadog_lambda/patch.py): + HTTP Headers: [<"k:v">, ...] Data: + * the Lambda runtime's START / END / REPORT lines +""" + +from __future__ import annotations + +import json +import re +from dataclasses import dataclass, field +from typing import Any, Dict, List, Optional + +_START_RE = re.compile(r"^START RequestId: (?P[0-9a-fA-F-]+)") +_END_RE = re.compile(r"^END RequestId: (?P[0-9a-fA-F-]+)") +_REPORT_RE = re.compile(r"^REPORT RequestId: (?P[0-9a-fA-F-]+)") +_REPORT_FIELD_RE = re.compile(r"(?P[A-Za-z ]+): (?P[0-9.]+) (?:ms|MB)") +# Lines written by the Lambda platform, not by the library or the function. +_PLATFORM_LINE_RES = [ + re.compile(p) + for p in ( + r"^INIT_START ", + r"^INIT_REPORT ", + r"^EXTENSION\s", + r"^TELEMETRY\s", + r"init complete at epoch", # preview runtimes + r"main started at epoch", # preview runtimes + r"\[tls-profile\]", # preview runtimes + ) +] +_HTTP_RE = re.compile( + r"^HTTP (?P[A-Z]+) (?P\S+) Headers: (?P\[.*?\]) Data: (?P.*)$" +) + + +def parse_id(value: Any) -> int: + """Normalize a trace/span ID from the log writer (hex string) to an int.""" + if isinstance(value, int): + return value + return int(str(value), 16) + + +@dataclass +class Span: + raw: Dict[str, Any] + + @property + def name(self) -> str: + return self.raw["name"] + + @property + def service(self) -> str: + return self.raw.get("service") + + @property + def resource(self) -> str: + return self.raw.get("resource") + + @property + def type(self) -> Optional[str]: + return self.raw.get("type") + + @property + def error(self) -> int: + return self.raw.get("error", 0) + + @property + def meta(self) -> Dict[str, str]: + return self.raw.get("meta", {}) + + @property + def metrics(self) -> Dict[str, float]: + return self.raw.get("metrics", {}) + + @property + def trace_id(self) -> int: + return parse_id(self.raw["trace_id"]) + + @property + def span_id(self) -> int: + return parse_id(self.raw["span_id"]) + + @property + def parent_id(self) -> int: + return parse_id(self.raw.get("parent_id", 0)) + + def __repr__(self) -> str: + return "Span(name=%r, service=%r, resource=%r)" % ( + self.name, + self.service, + self.resource, + ) + + +@dataclass +class Metric: + name: str + value: float + tags: List[str] + timestamp: Optional[float] = None + # The whole logged object, so snapshots also see fields not modeled here. + raw: Dict[str, Any] = field(default_factory=dict) + + def tag(self, key: str) -> Optional[str]: + prefix = key + ":" + for t in self.tags: + if t.startswith(prefix): + return t[len(prefix) :] + return None + + +@dataclass +class HttpRequest: + method: str + url: str + headers: Dict[str, str] + data: Any + + +@dataclass +class Report: + duration_ms: Optional[float] = None + billed_duration_ms: Optional[float] = None + memory_size_mb: Optional[float] = None + max_memory_used_mb: Optional[float] = None + init_duration_ms: Optional[float] = None + + +@dataclass +class InvocationLogs: + request_id: str + lines: List[str] = field(default_factory=list) + # Lines logged during INIT, before this invocation's START line. Only set + # for the first invocation in an execution environment. + init_lines: List[str] = field(default_factory=list) + report: Optional[Report] = None + spans: List[Span] = field(default_factory=list) + metrics: List[Metric] = field(default_factory=list) + http_requests: List[HttpRequest] = field(default_factory=list) + # Lines that are none of the above, nor the runtime's START/END/REPORT + # (warnings, prints, unparseable output...), in order. + other_lines: List[str] = field(default_factory=list) + + @property + def complete(self) -> bool: + return self.report is not None + + def spans_named(self, name: str) -> List[Span]: + return [s for s in self.spans if s.name == name] + + def metrics_named(self, name: str) -> List[Metric]: + return [m for m in self.metrics if m.name == name] + + def unexpected_lines(self) -> List[str]: + """Everything the parser did not recognize, minus Lambda platform lines: + warnings, prints, tracebacks, and any other unexpected output.""" + return [ + line + for line in self.other_lines + if not any(r.search(line) for r in _PLATFORM_LINE_RES) + ] + + +def parse_report(line: str) -> Report: + fields = { + m.group("key").strip(): float(m.group("value")) + for m in _REPORT_FIELD_RE.finditer(line) + } + return Report( + duration_ms=fields.get("Duration"), + billed_duration_ms=fields.get("Billed Duration"), + memory_size_mb=fields.get("Memory Size"), + max_memory_used_mb=fields.get("Max Memory Used"), + init_duration_ms=fields.get("Init Duration"), + ) + + +def parse_http_request(line: str) -> Optional[HttpRequest]: + match = _HTTP_RE.match(line) + if not match: + return None + headers = {} + for item in json.loads(match.group("headers")): + key, _, value = item.partition(":") + headers[key] = value + try: + data = json.loads(match.group("data")) + except ValueError: + data = match.group("data") + return HttpRequest( + method=match.group("method"), + url=match.group("url"), + headers=headers, + data=data, + ) + + +def _parse_json(line: str) -> Optional[Any]: + if not line.startswith("{"): + return None + try: + return json.loads(line) + except ValueError: + return None + + +def _absorb(inv: InvocationLogs, line: str) -> None: + obj = _parse_json(line) + if isinstance(obj, dict): + if "traces" in obj: + for trace in obj["traces"]: + inv.spans.extend(Span(raw) for raw in trace) + return + if "m" in obj and "v" in obj: + inv.metrics.append( + Metric( + name=obj["m"], + value=obj["v"], + tags=obj.get("t", []), + timestamp=obj.get("e"), + raw=obj, + ) + ) + return + request = parse_http_request(line) + if request: + inv.http_requests.append(request) + return + inv.other_lines.append(line) + + +def split_invocations(stream_lines: List[str]) -> Dict[str, InvocationLogs]: + """Group the lines of ONE log stream (one execution environment) by request ID. + + Lines before the first START (the INIT phase) are attached to the first + invocation as `init_lines`; lines between invocations go to the next one's + `init_lines`, and lines after the last REPORT to the last invocation. + """ + invocations: Dict[str, InvocationLogs] = {} + pending_init: List[str] = [] + current: Optional[InvocationLogs] = None + last: Optional[InvocationLogs] = None + + for raw in stream_lines: + line = raw.rstrip("\n") + if not line: + continue + start = _START_RE.match(line) + if start: + current = invocations.setdefault( + start.group("id"), InvocationLogs(start.group("id")) + ) + current.init_lines.extend(pending_init) + pending_init = [] + continue + report = _REPORT_RE.match(line) + if report: + inv = invocations.setdefault( + report.group("id"), InvocationLogs(report.group("id")) + ) + inv.report = parse_report(line) + current = None + last = inv + continue + if _END_RE.match(line): + continue + if current is None: + # INIT phase (or output between invocations, attributed to the next one) + pending_init.append(line) + continue + current.lines.append(line) + _absorb(current, line) + + # Output after the stream's last REPORT (e.g. at shutdown) belongs to the + # last invocation; nothing else could have produced it. + if pending_init and last is not None: + last.lines.extend(pending_init) + for line in pending_init: + _absorb(last, line) + + for inv in invocations.values(): + for line in inv.init_lines: + _absorb(inv, line) + return invocations diff --git a/tests/integration/harness/requirements.py b/tests/integration/harness/requirements.py new file mode 100644 index 00000000..30688983 --- /dev/null +++ b/tests/integration/harness/requirements.py @@ -0,0 +1,41 @@ +"""Resolve requirements.txt environment markers for the *target* Lambda runtime. + +pip evaluates markers such as `python_version < "3.10"` against the Python +running pip, even with --python-version, so building a 3.8 layer from CI's +3.12 picks the 3.10+ pins. We evaluate the markers ourselves instead. +""" + +from __future__ import annotations + +from typing import Iterable, List + +from packaging.requirements import Requirement + + +def marker_environment(python_version: str, arch: str) -> dict: + return { + "python_version": python_version, + "python_full_version": python_version + ".0", + "implementation_name": "cpython", + "platform_python_implementation": "CPython", + "os_name": "posix", + "sys_platform": "linux", + "platform_system": "Linux", + "platform_machine": "x86_64" if arch == "amd64" else "aarch64", + } + + +def resolve(lines: Iterable[str], python_version: str, arch: str) -> List[str]: + """Return the requirements that apply to the target, with markers removed.""" + env = marker_environment(python_version, arch) + resolved = [] + for raw in lines: + line = raw.split("#", 1)[0].strip() + if not line: + continue + req = Requirement(line) + if req.marker is not None and not req.marker.evaluate(env): + continue + req.marker = None + resolved.append(str(req)) + return resolved diff --git a/tests/integration/harness/settings.py b/tests/integration/harness/settings.py new file mode 100644 index 00000000..b2cd416c --- /dev/null +++ b/tests/integration/harness/settings.py @@ -0,0 +1,134 @@ +"""Run settings, read from the environment.""" + +from __future__ import annotations + +import os +import secrets +from dataclasses import dataclass, field +from pathlib import Path +from typing import List, Optional + +INTEGRATION_DIR = Path(__file__).resolve().parent.parent +REPO_DIR = INTEGRATION_DIR.parent.parent + +INPUT_EVENTS_DIR = INTEGRATION_DIR / "input_events" +# Sorted, so the first invocation of each function (the cold start) is always +# the same event. +EVENT_NAMES: List[str] = sorted(p.stem for p in INPUT_EVENTS_DIR.glob("*.json")) +# Baseline function key -> name of the stack output holding its function name. +# Keys match the function directories under expected/. +BASELINE_FUNCTIONS = { + "async-metrics": "AsyncMetricsFunctionName", + "sync-metrics": "SyncMetricsFunctionName", +} + +# Names must start with "integration-tests" for the sandbox IAM policies, and +# every function must use this role. +SERVICE = "integration-tests-python" +LAMBDA_ROLE_ARN = ( + "arn:aws:iam::425362996713:role/serverless-integration-test-lambda-role" +) +DEPLOYMENT_BUCKET = "integration-tests-serververless-deployment-bucket" +DEFAULT_REGION = "eu-west-1" +DATADOG_EXTENSION_ACCOUNT = "464622532012" +# Datadog Extension layer version used when DD_EXTENSION_LAYER_VERSION is unset. +# The one place the pin lives: CI, the run script, and the docs all defer to it. +DEFAULT_EXTENSION_LAYER_VERSION = "105" + + +def _required(name: str) -> str: + value = os.environ.get(name) + if not value: + raise RuntimeError("%s must be set to run the integration tests" % name) + return value + + +@dataclass(frozen=True) +class Settings: + python_version: str # "3.13" + arch: str # "amd64" | "arm64" + region: str + run_id: str + # repr=False: pytest prints fixture values in failure tracebacks. + dd_api_key: str = field(repr=False) + # Secrets Manager ARN the deployed functions read the key from, instead of + # dd_api_key. Empty when the plaintext key is used. + dd_api_key_secret_arn: str + # A layer version number, or "none" to + # deploy without the extension function. + extension_layer_version: str + # Reuse an already-deployed stack instead of deploying (and keep it afterwards). + # Function names are read from the stack outputs, so run_id is unused then. + existing_stack: Optional[str] + keep_stack: bool + + @property + def runtime(self) -> str: + return "python" + self.python_version + + @property + def runtime_key(self) -> str: + # python3.13 -> python313, used in function names (matches the old suite) + return "python" + self.python_version.replace(".", "") + + @property + def lambda_arch(self) -> str: + return "x86_64" if self.arch == "amd64" else "arm64" + + @property + def stack_name(self) -> str: + return self.existing_stack or "%s-%s" % (SERVICE, self.run_id) + + @property + def layer_zip(self) -> Path: + return ( + REPO_DIR + / ".layers" + / ("datadog_lambda_py-%s-%s.zip" % (self.arch, self.python_version)) + ) + + @property + def extension_enabled(self) -> bool: + return self.extension_layer_version != "none" + + @property + def extension_layer_base_arn(self) -> str: + """The Datadog Extension layer ARN without the version suffix.""" + name = "Datadog-Extension" + ("-ARM" if self.arch == "arm64" else "") + return "arn:aws:lambda:%s:%s:layer:%s" % ( + self.region, + DATADOG_EXTENSION_ACCOUNT, + name, + ) + + +def load() -> Settings: + extension_layer_version = ( + os.environ.get("DD_EXTENSION_LAYER_VERSION") or DEFAULT_EXTENSION_LAYER_VERSION + ).lower() + if extension_layer_version != "none" and not extension_layer_version.isdigit(): + raise RuntimeError( + "DD_EXTENSION_LAYER_VERSION must be a layer version number or 'none', got %r" + % extension_layer_version + ) + arch = _required("ARCH") + if arch not in ("amd64", "arm64"): + raise RuntimeError("ARCH must be amd64 or arm64, got %r" % arch) + existing_stack = os.environ.get("INTEGRATION_STACK_NAME") or None + dd_api_key = os.environ.get("DD_API_KEY", "") + dd_api_key_secret_arn = os.environ.get("DD_API_KEY_SECRET_ARN", "") + if not dd_api_key and not dd_api_key_secret_arn: + raise RuntimeError( + "DD_API_KEY or DD_API_KEY_SECRET_ARN must be set to run the integration tests" + ) + return Settings( + python_version=_required("PYTHON_VERSION"), + arch=arch, + region=os.environ.get("INTEGRATION_REGION") or DEFAULT_REGION, + run_id=os.environ.get("INTEGRATION_RUN_ID") or secrets.token_hex(4), + dd_api_key=dd_api_key, + dd_api_key_secret_arn=dd_api_key_secret_arn, + extension_layer_version=extension_layer_version, + existing_stack=existing_stack, + keep_stack=bool(existing_stack) or os.environ.get("KEEP_STACK") == "true", + ) diff --git a/tests/integration/harness/snapshots.py b/tests/integration/harness/snapshots.py new file mode 100644 index 00000000..b7004a88 --- /dev/null +++ b/tests/integration/harness/snapshots.py @@ -0,0 +1,528 @@ +"""Structured snapshots of spans, outgoing requests, and metrics. + +Each invocation's output is normalized (only values that legitimately change +between runs are replaced with placeholders), then compared with a checked-in +JSON file. Unlike the old line-sorted text snapshots, span parent links are +kept (as labels), and every tag and header is compared. + +Layout (see LEVELS): + spans: expected/spans///.json + requests: expected/requests///.json for events + that differ from the function's default, and + expected/requests//.json for the function default + metrics: expected/metrics//.json +where variant is the most specific of "-", "", +"default" that exists. Event files win over function files. `UPDATE_EXPECTED=true` +writes "-" files for the current run; +`python -m harness.snapshots dedupe` (from tests/integration) folds them into +the fewest files that resolve every case to the same content. + +Pure Python, no AWS dependencies; unit tested in tests/test_integration_harness.py. +""" + +from __future__ import annotations + +import difflib +import json +import re +import shutil +import sys +from collections import Counter +from dataclasses import dataclass +from pathlib import Path +from typing import Any, Dict, Iterable, List, Optional, Tuple + +from . import settings + +EXPECTED_DIR = Path(__file__).resolve().parent.parent / "expected" +# Which file levels a category uses: +# "event" //.json, one per event +# "function" /.json, shared by every event +# Event files win over function files, and a runtime's file wins over "default". +LEVELS = { + "spans": ("event",), + "requests": ("event", "function"), + "metrics": ("function",), +} +CATEGORIES = tuple(LEVELS) +ARCHES = ("amd64", "arm64") + +_MIN_LITERAL_LEN = 8 +_VERSION_RE = re.compile(r"\d+(?:\.\d+)+(?:\.?(?:dev|rc|a|b)\d+)?") +_ARCH_RE = re.compile(r"\b(?:x86_64|aarch64)\b") +_TRACEPARENT_RE = re.compile(r"^00-[0-9a-f]{32}-[0-9a-f]{16}-([0-9a-f]{2})$") + + +@dataclass(frozen=True) +class Context: + """Run-specific literals to replace, so snapshots are stable across runs.""" + + function_name: str + request_id: str + account_id: str + runtime: str # python3.13 + runtime_key: str # python313 + + def substitutions(self) -> List[Tuple[str, str]]: + # Longest first: the function name contains the runtime key. + return [ + (self.function_name, ""), + (self.function_name.lower(), ""), + (self.request_id, ""), + (self.account_id, ""), + (self.runtime, ""), + (self.runtime_key, ""), + ] + + +def _sub_literals(value: Any, ctx: Context) -> Any: + if isinstance(value, str): + for literal, placeholder in ctx.substitutions(): + # Short literals would match inside unrelated text. + if len(literal) >= _MIN_LITERAL_LEN: + value = value.replace(literal, placeholder) + return value + if isinstance(value, list): + return [_sub_literals(v, ctx) for v in value] + if isinstance(value, dict): + return {k: _sub_literals(v, ctx) for k, v in value.items()} + return value + + +# User agents of the clients the handler and library use, whose versions change +# with dependency bumps. Other user agents (such as a browser's in an input +# event) are compared exactly. +_CLIENT_USER_AGENT_PREFIXES = ("python-requests/", "datadogpy/") + + +def _versions(value: str) -> str: + if not value.startswith(_CLIENT_USER_AGENT_PREFIXES): + return value + return _ARCH_RE.sub("", _VERSION_RE.sub("X", value)) + + +# -------------------------------------------------------------------------- +# Spans +# -------------------------------------------------------------------------- + +# Values that change on every run. Keys not listed are compared exactly. +_SPAN_META_RULES = { + "runtime-id": lambda v: "", + "_dd.p.tid": lambda v: "" if re.fullmatch(r"[0-9a-f]{16}", v) else v, + "datadog_lambda": lambda v: "", + "dd_trace": lambda v: "", + "http.useragent": _versions, +} +_SPAN_METRIC_RULES = { + "process_id": lambda v: "", +} + + +def span_label(raw: Dict[str, Any]) -> str: + meta = raw.get("meta", {}) + label = "%s %s" % (raw.get("name"), raw.get("resource")) + if meta.get("http.url"): + label += " " + meta["http.url"] + return label + + +# Per-span fields that change on every run; links between spans are checked by +# ID in test_baseline.py and recorded here as parent labels. +_SPAN_DROPPED_FIELDS = ("trace_id", "span_id", "parent_id", "start", "duration") + + +def _link_id(value: Any) -> Any: + # Span pointer links carry zero IDs; anything else is run-specific. + try: + return value if int(str(value), 16) == 0 else "" + except ValueError: + return value + + +def _normalize_span_link(link: Dict[str, Any]) -> Dict[str, Any]: + link = dict(link) + for key in ("trace_id", "span_id", "trace_id_high"): + if key in link: + link[key] = _link_id(link[key]) + return link + + +def normalize_spans(raw_spans: Iterable[Dict[str, Any]], ctx: Context) -> List[Dict]: + """Every span field except IDs and timings; each span records its parent's label.""" + raw_spans = list(raw_spans) + by_id = {str(s.get("span_id")): s for s in raw_spans} + out = [] + for raw in raw_spans: + parent = by_id.get(str(raw.get("parent_id"))) + span = {k: v for k, v in raw.items() if k not in _SPAN_DROPPED_FIELDS} + span["meta"] = { + k: _SPAN_META_RULES[k](v) if k in _SPAN_META_RULES else v + for k, v in raw.get("meta", {}).items() + } + span["metrics"] = { + k: _SPAN_METRIC_RULES[k](v) if k in _SPAN_METRIC_RULES else v + for k, v in raw.get("metrics", {}).items() + } + if "span_links" in raw: + span["span_links"] = [ + _normalize_span_link(link) for link in raw["span_links"] + ] + span["label"] = span_label(raw) + span["parent"] = span_label(parent) if parent else None + out.append(_sub_literals(span, ctx)) + return sorted(out, key=lambda s: (s["label"], s["parent"] or "")) + + +# -------------------------------------------------------------------------- +# Outgoing HTTP requests (logged by DD_INTEGRATION_TEST) +# -------------------------------------------------------------------------- + + +def _traceparent(v: str) -> str: + m = _TRACEPARENT_RE.match(v) + return "00---%s" % m.group(1) if m else v + + +def _tracestate(v: str) -> str: + v = re.sub(r"\bp:[0-9a-f]{16}\b", "p:", v) + v = re.sub(r"\bt\.tid:[0-9a-f]{16}\b", "t.tid:", v) + # OpenTelemetry random value (W3C trace context level 2), set by ddtrace on + # Python 3.10+. Random per trace; the threshold ("th") is stable, so it stays. + return re.sub(r"\bot=rv:[0-9a-f]{14}\b", "ot=rv:", v) + + +def _digits(placeholder: str): + return lambda v: placeholder if re.fullmatch(r"\d+", v) else v + + +_HEADER_RULES = { + "traceparent": _traceparent, + "tracestate": _tracestate, + "x-datadog-trace-id": _digits(""), + "x-datadog-parent-id": _digits(""), + "x-datadog-tags": lambda v: re.sub( + r"_dd\.p\.tid=[0-9a-f]{16}", "_dd.p.tid=", v + ), + "content-length": _digits(""), + "dd-api-key": lambda v: "", + "user-agent": _versions, +} + + +def _metric_tag(tag: str) -> str: + key, _, value = tag.partition(":") + if key == "datadog_lambda": + return "datadog_lambda:" + if key == "dd_lambda_layer": + return "dd_lambda_layer:" + _VERSION_RE.sub("", value) + # Warm or cold depends on the invocation's order, not on the code; the + # baseline tests assert the actual value against the Lambda's init phase. + if key == "cold_start": + return "cold_start:" + return tag + + +def _normalize_request_data(data: Any) -> Any: + if isinstance(data, dict) and isinstance(data.get("series"), list): + series = [] + for s in data["series"]: + s = dict(s) + s["points"] = [["", p[1]] for p in s.get("points", [])] + s["tags"] = sorted(_metric_tag(t) for t in s.get("tags") or []) + series.append(s) + data = dict(data, series=sorted(series, key=lambda s: s.get("metric", ""))) + return data + + +def normalize_requests(requests: Iterable[Any], ctx: Context) -> List[Dict]: + out = [] + for r in requests: + headers = {} + for key, value in r.headers.items(): + rule = _HEADER_RULES.get(key.lower()) + headers[key] = rule(value) if rule else value + out.append( + _sub_literals( + { + "method": r.method, + "url": r.url, + "headers": headers, + "data": _normalize_request_data(r.data), + }, + ctx, + ) + ) + return sorted(out, key=lambda r: (r["method"], r["url"])) + + +# -------------------------------------------------------------------------- +# Metrics (written to logs: enhanced metrics, and custom ones with DD_FLUSH_TO_LOG) +# -------------------------------------------------------------------------- + + +def normalize_metrics(metrics: Iterable[Any], ctx: Context) -> List[Dict]: + """Every logged metric field except the timestamp ("e").""" + out = [] + for m in metrics: + raw = dict(m.raw) if m.raw else {"m": m.name, "v": m.value, "t": m.tags} + raw.pop("e", None) + raw["t"] = sorted(_metric_tag(t) for t in raw.get("t") or []) + out.append(_sub_literals(raw, ctx)) + return sorted(out, key=lambda m: (m.get("m", ""), m["t"])) + + +# -------------------------------------------------------------------------- +# Files +# -------------------------------------------------------------------------- + + +# Runtimes whose snapshots are identical to another runtime's. They keep no files +# of their own and fall back to the parent's. dedupe checks the equality and fails +# if it stops holding, so a divergence is never silently dropped. +SHARED_RUNTIMES = {"python39": "python38"} + + +def variants(runtime_key: str, arch: str) -> List[str]: + """Lookup order, most specific first: the runtime, then any runtime it shares + files with, then "default".""" + order: List[str] = [] + rk: Optional[str] = runtime_key + while rk is not None: + order += ["%s-%s" % (rk, arch), rk] + rk = SHARED_RUNTIMES.get(rk) + return order + ["default"] + + +def _path( + root: Path, category: str, variant: str, function: str, event: Optional[str] +) -> Path: + """//.json, or /.json when the + category is stored per function (event is None).""" + if event is None: + return root / category / variant / (function + ".json") + return root / category / variant / function / (event + ".json") + + +# What dedupe folds: every baseline function and every input event. +FUNCTIONS = tuple(settings.BASELINE_FUNCTIONS) +EVENTS = tuple(settings.EVENT_NAMES) + + +def _candidates( + category: str, + runtime_key: str, + arch: str, + function: str, + event: Optional[str], + root: Path, +) -> List[Path]: + """Every file that may hold this case's snapshot, most specific first.""" + paths: List[Path] = [] + if "event" in LEVELS[category] and event is not None: + paths += [ + _path(root, category, v, function, event) + for v in variants(runtime_key, arch) + ] + if "function" in LEVELS[category]: + paths += [ + _path(root, category, v, function, None) + for v in variants(runtime_key, arch) + ] + return paths + + +def resolve( + category: str, + runtime_key: str, + arch: str, + function: str, + event: Optional[str], + root: Path = EXPECTED_DIR, +) -> Optional[Path]: + for path in _candidates(category, runtime_key, arch, function, event, root): + if path.exists(): + return path + return None + + +def dumps(value: Any) -> str: + return json.dumps(value, indent=2, sort_keys=True) + "\n" + + +def write_current( + category: str, + runtime_key: str, + arch: str, + function: str, + event: Optional[str], + value: Any, + root: Path = EXPECTED_DIR, +) -> Path: + path = _path(root, category, "%s-%s" % (runtime_key, arch), function, event) + path.parent.mkdir(parents=True, exist_ok=True) + path.write_text(dumps(value)) + return path + + +def diff(expected_text: str, actual: Any, expected_name: str) -> str: + return "".join( + difflib.unified_diff( + expected_text.splitlines(True), + dumps(actual).splitlines(True), + fromfile=expected_name, + tofile="actual", + n=4, + ) + ) + + +def _mode(values): + return Counter(values).most_common(1)[0][0] + + +def _plan( + category: str, + effective: Dict[Tuple[str, Optional[str]], Dict[Tuple[str, str], str]], + runtime_keys: List[str], +) -> Dict[Tuple[str, str, Optional[str]], str]: + """Files to write for one category, as {(variant, function, event): content}. + + effective maps (function, event) to {(runtime_key, arch): content}, where + event is None for function-level categories. Every case must resolve to its + content afterwards, so each file written is checked against the order in + _candidates: a file is only written where the fallback would be wrong. + """ + levels = LEVELS[category] + plan: Dict[Tuple[str, str, Optional[str]], str] = {} + + def variant_for(rk: str, arch: str, arches: List[str]) -> str: + return rk if len(arches) == len(ARCHES) else "%s-%s" % (rk, arch) + + for fn in sorted({f for f, _ in effective}): + events = sorted({e for f, e in effective if f == fn}, key=lambda e: e or "") + func_value: Dict[Tuple[str, str], str] = {} + default = None + if "function" in levels: + combos = {c for ev in events for c in effective[(fn, ev)]} + for c in combos: + func_value[c] = _mode( + [ + effective[(fn, ev)][c] + for ev in events + if c in effective[(fn, ev)] + ] + ) + default = _mode(func_value.values()) + plan[("default", fn, None)] = default + for rk in runtime_keys: + present = [(rk, a) for a in ARCHES if (rk, a) in func_value] + values = {func_value[c] for c in present} + if not present or values == {default}: + continue + if len(present) == len(ARCHES) and len(values) == 1: + plan[(rk, fn, None)] = values.pop() + continue + for rk_, a in present: + if func_value[(rk_, a)] != default: + plan[("%s-%s" % (rk_, a), fn, None)] = func_value[(rk_, a)] + + if "event" in levels: + for ev in events: + per = effective[(fn, ev)] + if not per: + continue + mode = _mode(per.values()) + if "function" in levels: + # Only needed when this event disagrees with the function default. + x_ev = mode if mode != default else None + else: + x_ev = mode + if x_ev is not None: + plan[("default", fn, ev)] = x_ev + fallback = { + c: (x_ev if x_ev is not None else func_value[c]) for c in per + } + wrong = {c: v for c, v in per.items() if v != fallback[c]} + for rk in runtime_keys: + bad = [(rk, a) for a in ARCHES if (rk, a) in wrong] + if not bad: + continue + present = [(rk, a) for a in ARCHES if (rk, a) in per] + contents = {wrong[c] for c in bad} + if len(contents) == 1 and len(bad) == len(present): + plan[(rk, fn, ev)] = contents.pop() + else: + for rk_, a in bad: + plan[("%s-%s" % (rk_, a), fn, ev)] = wrong[(rk_, a)] + return plan + + +def dedupe( + runtime_keys: List[str], + root: Path = EXPECTED_DIR, + functions: Iterable[str] = FUNCTIONS, + events: Iterable[str] = EVENTS, +) -> None: + """Fold per-run files into 'default' plus the fewest overrides that keep every + case resolving to what it does today. + + Function-level categories get one "default" file per function, with a + runtime file where a runtime differs. Event-level categories get a default + per event, with runtime files where a runtime differs. Categories with both + levels (requests) add a function default and only the event files that + disagree with it. Fresh "-" files from UPDATE_EXPECTED + take part like any other file. + """ + functions = list(functions) + events = list(events) + # Shared runtimes are planned through their parent, so only the parents are + # planned. A shared runtime must resolve to its parent's content everywhere. + planned = [rk for rk in runtime_keys if rk not in SHARED_RUNTIMES] + for category in CATEGORIES: + cat_dir = root / category + if not cat_dir.exists(): + continue + event_list = events if "event" in LEVELS[category] else [None] + effective: Dict[Tuple[str, Optional[str]], Dict[Tuple[str, str], str]] = {} + for fn in functions: + for ev in event_list: + for child, parent in SHARED_RUNTIMES.items(): + if child not in runtime_keys: + continue + for arch in ARCHES: + c = resolve(category, child, arch, fn, ev, root) + p = resolve(category, parent, arch, fn, ev, root) + if (c.read_text() if c else None) != ( + p.read_text() if p else None + ): + raise ValueError( + "%s %s/%s/%s differs from %s; remove %s from SHARED_RUNTIMES" + % (category, child, fn, ev, parent, child) + ) + per = {} + for rk in planned: + for arch in ARCHES: + path = resolve(category, rk, arch, fn, ev, root) + if path: + per[(rk, arch)] = path.read_text() + if per: + effective[(fn, ev)] = per + plan = _plan(category, effective, planned) + shutil.rmtree(cat_dir) + for (variant, fn, ev), content in plan.items(): + path = _path(root, category, variant, fn, ev) + path.parent.mkdir(parents=True, exist_ok=True) + path.write_text(content) + + +def _supported_runtime_keys() -> List[str]: + text = (EXPECTED_DIR.parent.parent.parent / "python_versions.yaml").read_text() + versions = re.findall(r'^\s*- version:\s*"?(\d+\.\d+)"?', text, re.M) + return ["python" + v.replace(".", "") for v in versions] + + +if __name__ == "__main__": + if sys.argv[1:] != ["dedupe"]: + sys.exit("usage: python -m harness.snapshots dedupe") + dedupe(_supported_runtime_keys()) + print("Deduplicated snapshots in %s" % EXPECTED_DIR) diff --git a/tests/integration/mock_intake/mock-intake b/tests/integration/mock_intake/mock-intake new file mode 100755 index 00000000..e4bcbf5c --- /dev/null +++ b/tests/integration/mock_intake/mock-intake @@ -0,0 +1,122 @@ +#!/usr/bin/env python3 +"""Mock Datadog intake, run as a Lambda extension next to the Datadog Extension. + +It serves HTTP on 127.0.0.1 inside the execution environment, accepts every +request, and writes each one to stdout, which Lambda sends to the function's +CloudWatch log group. The harness reads them back (harness/intake.py). + +Nothing leaves the execution environment, so no public endpoint or extra IAM +permissions are needed. Standard library only; runs on every supported Python. + +Packaged by the harness as extensions/mock-intake in a layer (the file name +must match the name it registers with). +""" + +import base64 +import json +import os +import sys +import threading +import time +import urllib.request +import uuid +from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer + +NAME = "mock-intake" +MARKER = "MOCK_INTAKE_REQUEST" +CHUNK_SIZE = 150000 # base64 characters per log line (CloudWatch limit: 256 KB) +DEFAULT_PORT = 18080 +_print_lock = threading.Lock() + + +def record(method, path, headers, body, out=None): + """Write one request to stdout as MARKER lines, chunked.""" + out = out or sys.stdout + path, _, query = path.partition("?") + body_b64 = base64.b64encode(body).decode("ascii") + chunks = [body_b64[i : i + CHUNK_SIZE] for i in range(0, len(body_b64), CHUNK_SIZE)] + chunks = chunks or [""] + recorded_headers = { + k.lower(): v + for k, v in headers.items() + if k.lower() not in ("dd-api-key", "x-dd-api-key", "authorization") + } + request_id = str(uuid.uuid4()) + with _print_lock: + for index, chunk in enumerate(chunks): + line = { + "id": request_id, + "method": method, + "path": path, + "query": query, + "headers": recorded_headers, + "chunk": index, + "chunks": len(chunks), + "body_b64": chunk, + } + out.write(MARKER + " " + json.dumps(line) + "\n") + out.flush() + + +class Handler(BaseHTTPRequestHandler): + protocol_version = "HTTP/1.1" + + def _handle(self): + length = int(self.headers.get("Content-Length") or 0) + body = self.rfile.read(length) if length else b"" + if self.path.split("?", 1)[0].rstrip("/").endswith("/api/v1/validate"): + # The extension validates its API key at startup. + self._respond(200, b'{"valid": true}') + return + record(self.command, self.path, dict(self.headers.items()), body) + self._respond(202, b"{}") + + def _respond(self, status, payload): + self.send_response(status) + self.send_header("Content-Type", "application/json") + self.send_header("Content-Length", str(len(payload))) + self.end_headers() + self.wfile.write(payload) + + do_GET = do_POST = do_PUT = _handle + + def log_message(self, format, *args): # keep stdout for recorded requests only + pass + + +def serve(port): + server = ThreadingHTTPServer(("127.0.0.1", port), Handler) + thread = threading.Thread(target=server.serve_forever, daemon=True) + thread.start() + return server + + +def _extensions_api(path, data=None, headers=None): + url = "http://%s/2020-01-01/extension/%s" % (os.environ["AWS_LAMBDA_RUNTIME_API"], path) + req = urllib.request.Request(url, data=data, headers=headers or {}) + return urllib.request.urlopen(req) + + +def main(): + # Listen before registering, so the server is up before any invocation. + serve(int(os.environ.get("MOCK_INTAKE_PORT", DEFAULT_PORT))) + resp = _extensions_api( + "register", + data=json.dumps({"events": ["INVOKE", "SHUTDOWN"]}).encode(), + headers={"Lambda-Extension-Name": NAME, "Content-Type": "application/json"}, + ) + extension_id = resp.headers["Lambda-Extension-Identifier"] + while True: + event = json.loads( + _extensions_api( + "event/next", headers={"Lambda-Extension-Identifier": extension_id} + ).read() + ) + if event.get("eventType") == "SHUTDOWN": + # Give a final Datadog Extension flush a moment to arrive. + time.sleep(0.5) + return + + +if __name__ == "__main__": + main() diff --git a/tests/integration/pytest.ini b/tests/integration/pytest.ini new file mode 100644 index 00000000..3251a41d --- /dev/null +++ b/tests/integration/pytest.ini @@ -0,0 +1,8 @@ +# Integration tests deploy real AWS resources. Run them from this directory: +# cd tests/integration && pytest +# This file makes tests/integration the rootdir, so the unit test conftest in +# tests/ (which imports datadog_lambda) is not loaded. +[pytest] +addopts = -v --tb=short -p no:cacheprovider +markers = + extension: uses the Datadog Extension layer (DD_EXTENSION_LAYER_VERSION=none deselects) diff --git a/tests/integration/requirements-test.txt b/tests/integration/requirements-test.txt new file mode 100644 index 00000000..5396b408 --- /dev/null +++ b/tests/integration/requirements-test.txt @@ -0,0 +1,6 @@ +# Test-runner dependencies (not deployed). The deployed requirements layer is requirements.txt. +aws-sam-cli>=1.174 +boto3>=1.35 +pytest>=8.3 +zstandard>=0.23 +packaging>=23 diff --git a/tests/integration/template.yaml b/tests/integration/template.yaml new file mode 100644 index 00000000..a735fde0 --- /dev/null +++ b/tests/integration/template.yaml @@ -0,0 +1,183 @@ +AWSTemplateFormatVersion: "2010-09-09" +Transform: AWS::Serverless-2016-10-31 +Description: datadog-lambda-python integration tests (deployed by tests/integration/harness/aws.py) + +# The harness stages build artifacts under .build/ before deploying: +# .build/datadog_layer.zip the layer built by scripts/build_layers.sh +# .build/requirements_layer/ tests/integration/requirements.txt, pip installed into python/ +# .build/mock_intake_layer.zip mock_intake/mock-intake as extensions/mock-intake + +Parameters: + RunId: + Type: String + Runtime: + Type: String # e.g. python3.13 + RuntimeKey: + Type: String # e.g. python313, used in function names + Architecture: + Type: String + AllowedValues: [x86_64, arm64] + LambdaRoleArn: + Type: String + DdApiKey: + Type: String + NoEcho: true + Default: "" + DdApiKeySecretArn: + Type: String + Default: "" + MockIntakeApiKey: + Type: String + NoEcho: true + Description: Random per-run fake key for the extension function, so the real key is never sent to the mock intake. + ExtensionLayerArn: + Type: String + Default: "" + +Conditions: + HasExtension: !Not [!Equals [!Ref ExtensionLayerArn, ""]] + +Globals: + Function: + Runtime: !Ref Runtime + Architectures: [!Ref Architecture] + Timeout: 15 + MemorySize: 1024 + Tracing: PassThrough + CodeUri: functions/ + +Resources: + DatadogLayer: + Type: AWS::Serverless::LayerVersion + Properties: + LayerName: !Sub integration-tests-python-${RunId}-datadog + ContentUri: .build/datadog_layer.zip + CompatibleRuntimes: [!Ref Runtime] + + RequirementsLayer: + Type: AWS::Serverless::LayerVersion + Properties: + LayerName: !Sub integration-tests-python-${RunId}-requirements + ContentUri: .build/requirements_layer/ + CompatibleRuntimes: [!Ref Runtime] + + # --------------------------------------------------------------------------- + # Baseline: library only, no extension. Traces and metrics go to CloudWatch. + # --------------------------------------------------------------------------- + + # Metrics flushed to logs + AsyncMetricsFunction: + Type: AWS::Serverless::Function + Properties: + Role: !Ref LambdaRoleArn + FunctionName: !Sub integration-tests-python-${RunId}-async-metrics_${RuntimeKey} + Handler: baseline.handle + Layers: [!Ref DatadogLayer, !Ref RequirementsLayer] + Environment: + Variables: + DD_INTEGRATION_TEST: "true" + DD_TRACE_ENABLED: "true" + DD_TRACE_MANAGED_SERVICES: "true" + DD_COLD_START_TRACING: "false" + DD_SERVICE: integration-tests-python + DD_API_KEY: !Ref DdApiKey + DD_API_KEY_SECRET_ARN: !Ref DdApiKeySecretArn + DD_FLUSH_TO_LOG: "true" + + AsyncMetricsLogGroup: + Type: AWS::Logs::LogGroup + Properties: + LogGroupName: !Sub /aws/lambda/integration-tests-python-${RunId}-async-metrics_${RuntimeKey} + RetentionInDays: 7 + + # Metrics sent to the Datadog API + SyncMetricsFunction: + Type: AWS::Serverless::Function + Properties: + Role: !Ref LambdaRoleArn + FunctionName: !Sub integration-tests-python-${RunId}-sync-metrics_${RuntimeKey} + Handler: baseline.handle + Layers: [!Ref DatadogLayer, !Ref RequirementsLayer] + Environment: + Variables: + DD_INTEGRATION_TEST: "true" + DD_TRACE_ENABLED: "true" + DD_TRACE_MANAGED_SERVICES: "true" + DD_COLD_START_TRACING: "false" + DD_SERVICE: integration-tests-python + DD_API_KEY: !Ref DdApiKey + DD_API_KEY_SECRET_ARN: !Ref DdApiKeySecretArn + + SyncMetricsLogGroup: + Type: AWS::Logs::LogGroup + Properties: + LogGroupName: !Sub /aws/lambda/integration-tests-python-${RunId}-sync-metrics_${RuntimeKey} + RetentionInDays: 7 + + # --------------------------------------------------------------------------- + # Mock intake: a Lambda extension (mock_intake/mock-intake) serving HTTP on + # 127.0.0.1 next to the Datadog Extension, recording requests to the logs. + # --------------------------------------------------------------------------- + + MockIntakeLayer: + Type: AWS::Serverless::LayerVersion + Condition: HasExtension + Properties: + LayerName: !Sub integration-tests-python-${RunId}-mock-intake + ContentUri: .build/mock_intake_layer.zip + CompatibleRuntimes: [!Ref Runtime] + + # --------------------------------------------------------------------------- + # Extension: library + Datadog Extension, all intake traffic to the mock. + # --------------------------------------------------------------------------- + + ExtensionFunction: + Type: AWS::Serverless::Function + Condition: HasExtension + Properties: + Role: !Ref LambdaRoleArn + FunctionName: !Sub integration-tests-python-${RunId}-extension_${RuntimeKey} + Handler: baseline.handle + Layers: + - !Ref DatadogLayer + - !Ref RequirementsLayer + - !Ref ExtensionLayerArn + - !Ref MockIntakeLayer + Environment: + Variables: + DD_TRACE_ENABLED: "true" + DD_TRACE_MANAGED_SERVICES: "true" + DD_COLD_START_TRACING: "false" + DD_SERVICE: integration-tests-python + # Never the real key: everything goes to the mock intake. + DD_API_KEY: !Ref MockIntakeApiKey + # Same base env as the extension's own fake-intake tests + # (datadog-lambda-extension bottlecap/tests/HARNESS.md): + DD_SITE: datadoghq.com + DD_DD_URL: http://127.0.0.1:18080 + DD_URL: http://127.0.0.1:18080 + DD_APM_DD_URL: http://127.0.0.1:18080 + DD_LOGS_CONFIG_LOGS_DD_URL: http://127.0.0.1:18080 + # The mock speaks HTTP/1.1; the default client uses h2 prior knowledge. + DD_HTTP_PROTOCOL: http1 + # Anything still sent over https (trace stats follow DD_SITE) goes to a + # closed port and fails at once instead of reaching a real intake. + DD_PROXY_HTTPS: http://127.0.0.1:1 + DD_LOG_LEVEL: debug + DD_SERVERLESS_FLUSH_STRATEGY: end + + ExtensionLogGroup: + Type: AWS::Logs::LogGroup + Condition: HasExtension + Properties: + LogGroupName: !Sub /aws/lambda/integration-tests-python-${RunId}-extension_${RuntimeKey} + RetentionInDays: 7 + +Outputs: + AsyncMetricsFunctionName: + Value: !Ref AsyncMetricsFunction + SyncMetricsFunctionName: + Value: !Ref SyncMetricsFunction + ExtensionFunctionName: + Condition: HasExtension + Value: !Ref ExtensionFunction diff --git a/tests/integration/test_baseline.py b/tests/integration/test_baseline.py new file mode 100644 index 00000000..5d78b52f --- /dev/null +++ b/tests/integration/test_baseline.py @@ -0,0 +1,205 @@ +"""Baseline: the library on its own (no extension), invoked once per trigger type. + +Field values (every span tag, request header, and metric tag) are covered by +the structured snapshots in test_snapshots.py. The tests here check what a +snapshot cannot, because it drops IDs and run-specific values, plus a few +invariants that must hold however the snapshots are regenerated. +""" + +from __future__ import annotations + +import re + +import pytest + +from .harness.settings import EVENT_NAMES + +# The handler calls https://datadoghq.com, which redirects to www. +FIRST_URL = "https://datadoghq.com/" +REDIRECT_URL = "https://www.datadoghq.com/" +# Where sync custom metrics are sent (datadogpy), traced as its own root span. +METRICS_FLUSH_PATH = "/api/v1/distribution_points" + + +def _function_span(inv): + spans = inv.logs.spans_named("aws.lambda") + assert len(spans) == 1, "expected one aws.lambda span, got %r" % inv.logs.spans + return spans[0] + + +def _request_span(inv, url): + spans = [ + s + for s in inv.logs.spans_named("requests.request") + if s.meta.get("http.url") == url + ] + assert len(spans) == 1, "expected one requests.request span for %s" % url + return spans[0] + + +def _describe_span_id(inv, span_id): + for s in inv.logs.spans: + if s.span_id == span_id: + return "%s (%s)" % (s.name, s.meta.get("http.url") or s.resource) + return "no span in this invocation" + + +# What the handler returns for each input event: the API Gateway request ID, and +# the SQS / SNS message IDs, as they appear in input_events/.json. Written +# out rather than read back from the events, so a handler that mis-parses an +# event cannot also compute the expectation. +EXPECTED_RETURN_IDS = { + "api-gateway-get": ("77375676-xmpl-4b79-853a-f982474efe18", []), + "appsync": (None, []), + "dynamodb": (None, []), + "eventbridge-custom": (None, []), + "http-api": ("FaHnXjKCGjQEJ7A=", []), + "kinesis": (None, []), + "s3": (None, []), + "sns": (None, ["95df01b4-ee98-5cb9-9903-4c221d41eb5e"]), + "sqs": ( + None, + [ + "059f36b4-87a3-44ab-83d2-661975830a7d", + "2e1424d4-f796-459a-8184-9c92662be6da", + ], + ), + "websocket": ("Fc5S3EvdGjQFtsQ=", []), +} + + +def test_expected_return_ids_cover_every_event(): + assert sorted(EXPECTED_RETURN_IDS) == EVENT_NAMES + + +def test_return_value(case): + _, event_name, inv = case + request_id, record_ids = EXPECTED_RETURN_IDS[event_name] + + assert inv.function_error is None, inv.response + assert inv.response == { + "statusCode": 200, + "body": { + "message": "hello, dog!", + "request_id": request_id, + "event_record_ids": record_ids, + }, + } + + +# Log lines a change legitimately adds, as regexes matched with re.search. +# Lambda platform lines are already filtered out by _PLATFORM_LINE_RES in +# harness/logs.py; add library or handler output here, not to a snapshot file. +ALLOWED_LOG_LINES = [re.compile(p) for p in ()] + + +def test_no_unexpected_log_lines(case): + """Nothing unexpected in the logs: no warnings, prints, or tracebacks, beyond + the Lambda platform lines the harness already ignores and ALLOWED_LOG_LINES.""" + _, _, inv = case + unexpected = [ + line + for line in inv.logs.unexpected_lines() + if not any(r.search(line) for r in ALLOWED_LOG_LINES) + ] + assert unexpected == [] + + +def test_cold_start_tags(case): + """The cold_start tags are normalized out of the snapshots, so they are + checked here against the invocation order and what Lambda reports. + + Lambda leaves Init Duration out of REPORT for proactively initialized + environments, so its absence does not mean a warm start. Its presence (or + init-phase log lines) does mean a fresh environment, which Lambda may also + use for a later invocation.""" + _, event_name, inv = case + new_environment = inv.logs.report.init_duration_ms is not None or bool( + inv.logs.init_lines + ) + cold = event_name == EVENT_NAMES[0] or new_environment + assert _function_span(inv).meta.get("cold_start") == str(cold).lower() + (enhanced,) = inv.logs.metrics_named("aws.lambda.enhanced.invocations") + assert enhanced.tag("cold_start") == str(cold).lower() + + +def test_dynamodb_stream_metric_only_for_dynamodb_event(case): + # Only the DynamoDB event emits this metric; it is left out of the + # per-function metrics snapshot, so its value and tags are checked here. + _, event_name, inv = case + found = inv.logs.metrics_named("datadog.serverless.dynamodb.stream.type") + if event_name != "dynamodb": + assert found == [] + return + assert len(found) == 1, found + (metric,) = found + assert metric.value == 1 + # The layer tag is the one every metric carries, which the metrics + # snapshot already pins down. + (enhanced,) = inv.logs.metrics_named("aws.lambda.enhanced.invocations") + layer = enhanced.tag("dd_lambda_layer") + assert layer is not None + assert metric.tags == [ + "streamtype:NEW_AND_OLD_IMAGES", + "dd_lambda_layer:" + layer, + ] + + +def test_single_trace(case): + _, _, inv = case + # Without the extension, custom metrics are POSTed to the Datadog API after + # the function and inferred spans have finished (sync-metrics), so ddtrace + # traces that call as its own root span. It is not part of the invocation's + # trace, so leave it out. The snapshots record it as a root span. + spans = [ + s + for s in inv.logs.spans + if not s.meta.get("http.url", "").endswith(METRICS_FLUSH_PATH) + ] + trace_ids = {s.trace_id for s in spans} + assert len(trace_ids) == 1, "spans span %d traces: %r" % ( + len(trace_ids), + spans, + ) + + +def test_span_links_by_id(case): + """Parent links by actual span ID (snapshots only record parent labels).""" + _, _, inv = case + function_span = _function_span(inv) + inferred = [s for s in inv.logs.spans if s.metrics.get("_dd._inferred_span") == 1] + + if inferred: + assert len(inferred) == 1, inferred + assert function_span.parent_id == inferred[0].span_id + first = _request_span(inv, FIRST_URL) + redirect = _request_span(inv, REDIRECT_URL) + assert first.parent_id == function_span.span_id + # requests follows the redirect inside the first send(), so the redirected + # request's span is a child of the first request's span. + assert redirect.parent_id == first.span_id + + +@pytest.mark.parametrize("url", [FIRST_URL, REDIRECT_URL]) +def test_trace_context_propagated(case, url): + """Each outgoing request carries the context of its own requests.request span. + + ddtrace's Session.send wrapper is outermost, so the logged headers are the + ones it injected (for the redirect hop too).""" + _, _, inv = case + span = _request_span(inv, url) + requests = [r for r in inv.logs.http_requests if r.url == url] + assert len(requests) == 1, "expected one logged request to %s" % url + headers = requests[0].headers + + version, trace_id_hex, parent_id_hex, flags = headers["traceparent"].split("-") + assert version == "00" + assert int(trace_id_hex[-16:], 16) == span.trace_id + parent_id = int(parent_id_hex, 16) + assert parent_id == span.span_id, "traceparent parent is %s, not %s" % ( + _describe_span_id(inv, parent_id), + _describe_span_id(inv, span.span_id), + ) + # Sampled, as the trace is kept. + assert flags == "01" + assert "p:%s" % parent_id_hex in headers["tracestate"] diff --git a/tests/integration/test_extension_intake.py b/tests/integration/test_extension_intake.py new file mode 100644 index 00000000..6d8daab8 --- /dev/null +++ b/tests/integration/test_extension_intake.py @@ -0,0 +1,76 @@ +"""Smoke test for the mock intake: the extension sends traces and metrics to it. + +Decoding payloads (protobuf traces, series, sketches) is left to the feature +tests that need it. Here we check that the right endpoints were hit and that +the payloads come from this run's function. +""" + +from __future__ import annotations + +import pytest + +from .conftest import load_event +from .harness import aws + +pytestmark = pytest.mark.extension + +TRACE_PATH_FRAGMENT = "/api/v0.2/traces" +METRIC_PATH_FRAGMENTS = ( + "/api/v2/series", + "/api/v1/series", + "/api/beta/sketches", + "/api/v1/distribution_points", +) + + +def _hit(requests, fragments): + return [r for r in requests if any(f in r.normalized_path for f in fragments)] + + +@pytest.fixture(scope="module") +def intake_requests(run_settings, stack, extension_function): + inv = aws.invoke( + run_settings.region, extension_function, load_event("api-gateway-get") + ) + assert inv.function_error is None, inv.response + aws.wait_for_logs(run_settings.region, extension_function, [inv.request_id]) + + def done(requests): + return bool(_hit(requests, [TRACE_PATH_FRAGMENT])) and bool( + _hit(requests, METRIC_PATH_FRAGMENTS) + ) + + try: + return aws.wait_for_intake(run_settings.region, extension_function, done) + except TimeoutError: + # Show what did arrive, and what the extension logged about it. + seen = aws.wait_for_intake( + run_settings.region, extension_function, lambda r: True, timeout_s=0 + ) + problems = [ + line.rstrip() + for line in aws.read_log_lines(run_settings.region, extension_function) + if "DD_EXTENSION" in line and ("ERROR" in line or "WARN" in line) + ] + pytest.fail( + "mock intake never got traces and metrics; saw paths %r\n" + "extension warnings/errors (last 30):\n%s" + % (sorted({r.normalized_path for r in seen}), "\n".join(problems[-30:])) + ) + + +def test_traces_reach_mock_intake(intake_requests, extension_function): + traces = _hit(intake_requests, [TRACE_PATH_FRAGMENT]) + assert traces + # Protobuf keeps strings as raw bytes, so the function name shows up in the body. + assert any(extension_function.lower().encode() in r.body for r in traces) + assert any(b"aws.lambda" in r.body for r in traces) + + +def test_metrics_reach_mock_intake(intake_requests): + metrics = _hit(intake_requests, METRIC_PATH_FRAGMENTS) + assert metrics + assert any( + b"aws.lambda.enhanced.invocations" in r.body or b"hello.dog" in r.body + for r in metrics + ) diff --git a/tests/integration/test_snapshots.py b/tests/integration/test_snapshots.py new file mode 100644 index 00000000..4ce44d8a --- /dev/null +++ b/tests/integration/test_snapshots.py @@ -0,0 +1,84 @@ +"""Structured snapshots of every span field, outgoing request header, and metric +field for the baseline invocations (see harness/snapshots.py). Unexpected log +output is asserted in test_baseline.py instead. + +To create or update the expected files, see "Snapshots" in CONTRIBUTING.md. +""" + +from __future__ import annotations + +import os + +import pytest + +from .harness import settings as settings_mod +from .harness import snapshots + +UPDATE = os.environ.get("UPDATE_EXPECTED") == "true" +ACCOUNT_ID = settings_mod.LAMBDA_ROLE_ARN.split(":")[4] + +# Metrics that only some events emit. They are asserted in test_baseline.py and +# left out of the per-function metrics snapshot. +EVENT_SPECIFIC_METRICS = {"datadog.serverless.dynamodb.stream.type"} + + +@pytest.fixture +def snapshot_case(case, run_settings): + """The shared case, plus the run-specific values the normalizers replace.""" + fn, event_name, inv = case + ctx = snapshots.Context( + function_name=inv.function_name, + request_id=inv.request_id, + account_id=ACCOUNT_ID, + runtime=run_settings.runtime, + runtime_key=run_settings.runtime_key, + ) + return fn, event_name, inv, ctx + + +def _check(category, actual, fn, event_name, run_settings): + """event_name is None for function-level categories (metrics).""" + rk, arch = run_settings.runtime_key, run_settings.arch + label = fn if event_name is None else "%s/%s" % (fn, event_name) + if UPDATE: + path = snapshots.write_current(category, rk, arch, fn, event_name, actual) + print("wrote %s" % path) + return + path = snapshots.resolve(category, rk, arch, fn, event_name) + if path is None: + pytest.fail( + "No %s snapshot for %s on %s-%s. Generate one with UPDATE_EXPECTED=true " + "(see CONTRIBUTING.md)." % (category, label, rk, arch) + ) + expected = path.read_text() + if expected != snapshots.dumps(actual): + name = str(path.relative_to(snapshots.EXPECTED_DIR)) + pytest.fail( + "%s differ from %s:\n%s" + % (category, name, snapshots.diff(expected, actual, name)), + pytrace=False, + ) + + +def test_span_snapshot(snapshot_case, run_settings): + fn, event_name, inv, ctx = snapshot_case + raw = [s.raw for s in inv.logs.spans] + _check("spans", snapshots.normalize_spans(raw, ctx), fn, event_name, run_settings) + + +def test_request_snapshot(snapshot_case, run_settings): + fn, event_name, inv, ctx = snapshot_case + actual = snapshots.normalize_requests(inv.logs.http_requests, ctx) + _check("requests", actual, fn, event_name, run_settings) + + +def test_metric_snapshot(snapshot_case, run_settings): + """One snapshot per function: every event must produce the same metrics, + apart from the event-specific ones.""" + fn, _, inv, ctx = snapshot_case + actual = [ + m + for m in snapshots.normalize_metrics(inv.logs.metrics, ctx) + if m["m"] not in EVENT_SPECIFIC_METRICS + ] + _check("metrics", actual, fn, None, run_settings) diff --git a/tests/test_integration_harness.py b/tests/test_integration_harness.py new file mode 100644 index 00000000..d21aeac1 --- /dev/null +++ b/tests/test_integration_harness.py @@ -0,0 +1,561 @@ +"""Offline tests for the integration test harness parsers (no AWS needed).""" + +import base64 +import gzip +import json +import re +from pathlib import Path + +import pytest + +from tests.integration.harness.intake import MARKER, decompress, parse_requests +from tests.integration.harness.logs import parse_report, split_invocations + +SNAPSHOTS = Path(__file__).parent / "integration" / "snapshots" / "logs" + +RID_1 = "11111111-1111-1111-1111-111111111111" +RID_2 = "22222222-2222-2222-2222-222222222222" + + +def _span(name, trace_id, span_id, parent_id, **meta): + return { + "name": name, + "service": "svc", + "resource": name, + "trace_id": "%016X" % trace_id, + "span_id": "%016X" % span_id, + "parent_id": "%016X" % parent_id, + "meta": meta, + "metrics": {}, + "error": 0, + } + + +def _stream(): + trace = {"traces": [[_span("aws.lambda", 0xAB, 0x2, 0x1, cold_start="true")]]} + return [ + "INIT_START Runtime Version: python:3.13.v20\tRuntime Version ARN: arn:aws:lambda:...\n", + "init message\n", + "START RequestId: %s Version: $LATEST\n" % RID_1, + json.dumps( + {"m": "hello.dog", "v": 1, "e": 1700000000, "t": ["team:serverless"]} + ) + + "\n", + json.dumps(trace) + "\n", + 'HTTP GET https://datadoghq.com/ Headers: ["Accept:*/*","traceparent:00-0000000000000000000000000000ab-0000000000000002-01"] Data: {}\n', + "END RequestId: %s\n" % RID_1, + "REPORT RequestId: %s\tDuration: 12.34 ms\tBilled Duration: 13 ms\tMemory Size: 1024 MB\t" + "Max Memory Used: 80 MB\tInit Duration: 456.78 ms\t\n" % RID_1, + "START RequestId: %s Version: $LATEST\n" % RID_2, + "[ERROR]\t2024-01-01T00:00:00Z\t%s\tsomething broke\n" % RID_2, + "END RequestId: %s\n" % RID_2, + ] + + +def test_split_invocations_groups_by_request_id(): + invs = split_invocations(_stream()) + assert set(invs) == {RID_1, RID_2} + + first = invs[RID_1] + assert first.complete + assert first.init_lines[0].startswith("INIT_START") + assert [s.name for s in first.spans] == ["aws.lambda"] + assert first.spans[0].trace_id == 0xAB + assert first.spans[0].parent_id == 0x1 + assert first.spans[0].meta["cold_start"] == "true" + assert [(m.name, m.value, m.tag("team")) for m in first.metrics] == [ + ("hello.dog", 1, "serverless") + ] + assert first.http_requests[0].headers["traceparent"].startswith("00-") + assert first.http_requests[0].data == {} + assert first.report.init_duration_ms == 456.78 + # Only the INIT_START platform line is dropped; the function's own init output stays. + assert first.unexpected_lines() == ["init message"] + + second = invs[RID_2] + assert not second.complete # no REPORT yet + assert second.init_lines == [] + assert second.unexpected_lines() == [ + "[ERROR]\t2024-01-01T00:00:00Z\t%s\tsomething broke" % RID_2 + ] + # A REPORT without "Init Duration" (a warm invocation) has no init duration. + warm = parse_report( + "REPORT RequestId: %s\tDuration: 1.00 ms\tBilled Duration: 2 ms\t" % RID_1 + ) + assert warm.duration_ms == 1.0 and warm.init_duration_ms is None + + +def _snapshot_as_cloudwatch_lines(path): + """Turn a normalized, pretty-printed snapshot back into one-line-per-event + CloudWatch output, with synthetic request IDs.""" + out, buf, n = [], [], 0 + for line in path.read_text().splitlines(): + if buf: + buf.append(line) + if line == "}": + out.append(" ".join(buf)) + buf = [] + elif line == "{": + buf = [line] + elif line == "START": + n += 1 + out.append( + "START RequestId: %08d-0000-0000-0000-000000000000 Version: $LATEST" % n + ) + elif line.startswith("END "): + out.append("END RequestId: %08d-0000-0000-0000-000000000000" % n) + out.append( + "REPORT RequestId: %08d-0000-0000-0000-000000000000\tDuration: 1.00 ms" + % n + ) + else: + out.append(line) + # Normalized numbers ("e": XXXX) are not valid JSON; quote them. + return [re.sub(r'(": )XXXX(?=[ ,}\]])', r'\1"XXXX"', line) for line in out] + + +def test_parses_real_snapshot_output(): + lines = _snapshot_as_cloudwatch_lines(SNAPSHOTS / "async-metrics_python313.log") + invs = split_invocations(lines) + assert len(invs) == 10 + for inv in invs.values(): + assert len(inv.spans_named("aws.lambda")) == 1 + assert len(inv.spans_named("requests.request")) == 2 + assert inv.metrics_named("hello.dog") + # The old sed normalization truncates HTTP lines before "Data:", so they + # are not checked here; test_split_invocations_groups_by_request_id is. + + +def _intake_line(request_id, chunk, chunks, body_b64, **extra): + record = { + "id": request_id, + "method": "POST", + "path": "//api/v0.2/traces", + "query": "", + "headers": {"content-encoding": "gzip"}, + "chunk": chunk, + "chunks": chunks, + "body_b64": body_b64, + } + record.update(extra) + return "2024-01-01T00:00:00Z\trequest-id\tINFO\t" + MARKER + json.dumps(record) + + +def test_parse_intake_requests_reassembles_chunks(): + body = gzip.compress(b"payload-with-function-name") + b64 = base64.b64encode(body).decode() + half = len(b64) // 2 + lines = [ + "unrelated line", + _intake_line("a", 1, 2, b64[half:]), + _intake_line("a", 0, 2, b64[:half]), + _intake_line("b", 0, 2, b64[:half]), # incomplete, dropped + ] + requests = parse_requests(lines) + assert [r.id for r in requests] == ["a"] + assert requests[0].normalized_path == "/api/v0.2/traces" + assert requests[0].body == b"payload-with-function-name" + + # Identity and raw/zlib deflate bodies, for the other Content-Encodings. + import zlib + + assert decompress(b"x", "") == b"x" + assert decompress(zlib.compress(b"x"), "deflate") == b"x" + + +def test_requirements_markers_resolved_for_target_runtime(): + from tests.integration.harness.requirements import resolve + + source = (Path(__file__).parent / "integration" / "requirements.txt").read_text() + lines = source.splitlines() + assert "requests==2.32.4" in resolve(lines, "3.8", "amd64") + assert "requests==2.33.1" not in resolve(lines, "3.8", "amd64") + assert "requests==2.33.1" in resolve(lines, "3.13", "arm64") + assert all(";" not in r for r in resolve(lines, "3.13", "arm64")) + + +def test_settings_repr_hides_api_key(): + from tests.integration.harness.settings import Settings + + s = Settings( + python_version="3.13", + arch="amd64", + region="eu-west-1", + run_id="abcd", + dd_api_key="super-secret-key", + dd_api_key_secret_arn="", + extension_layer_version="105", + existing_stack=None, + keep_stack=False, + ) + assert "super-secret-key" not in repr(s) + + +def _load_mock_intake(): + import importlib.machinery + import importlib.util + + path = Path(__file__).parent / "integration" / "mock_intake" / "mock-intake" + loader = importlib.machinery.SourceFileLoader("mock_intake_extension", str(path)) + spec = importlib.util.spec_from_loader(loader.name, loader) + module = importlib.util.module_from_spec(spec) + loader.exec_module(module) + return module + + +def test_mock_intake_extension_records_requests(capsys): + import urllib.request + + mock_intake = _load_mock_intake() + server = mock_intake.serve(0) + try: + port = server.server_address[1] + body = gzip.compress(b"x" * 400000) # several log-line chunks + req = urllib.request.Request( + "http://127.0.0.1:%d/api/v0.2/traces?a=b" % port, + data=body, + headers={"Content-Encoding": "gzip", "DD-API-KEY": "secret"}, + ) + assert urllib.request.urlopen(req, timeout=5).status == 202 + validate = "http://127.0.0.1:%d/api/v1/validate" % port + assert json.loads(urllib.request.urlopen(validate, timeout=5).read()) == { + "valid": True + } + finally: + server.shutdown() + + out = capsys.readouterr().out + assert "secret" not in out + requests = parse_requests(out.splitlines()) + assert [(r.method, r.normalized_path, r.query) for r in requests] == [ + ("POST", "/api/v0.2/traces", "a=b") + ] + assert requests[0].body == b"x" * 400000 + + +def _ctx(): + from tests.integration.harness.snapshots import Context + + return Context( + function_name="integration-tests-python-ab12cd34-sync-metrics_python313", + request_id=RID_1, + account_id="123456789012", + runtime="python3.13", + runtime_key="python313", + ) + + +def test_normalize_spans_keeps_structure_and_hides_run_values(): + from tests.integration.harness.snapshots import normalize_spans + + fn = _ctx().function_name + root = _span("aws.apigateway", 1, 10, 0) + root["resource"] = "GET /" + lam = _span( + "aws.lambda", + 1, + 11, + 10, + request_id=RID_1, + function_arn="arn:aws:lambda:eu-west-1:123456789012:function:" + fn, + **{"runtime-id": "c0ffee", "datadog_lambda": "8.130.0", "cold_start": "true"} + ) + lam["resource"] = fn + lam["metrics"] = {"process_id": 42, "_dd.top_level": 1} + req = _span("requests.request", 1, 12, 11, **{"http.url": "https://x/"}) + req["meta"]["http.useragent"] = "python-requests/2.33.1" + + # Only the library's own clients have their versions normalized. A browser or + # curl user agent comes from the fixed input event, so it is compared exactly. + root["meta"]["http.useragent"] = "curl/7.64.1" + + spans = normalize_spans([req, lam, root], _ctx()) + by_name = {s["name"]: s for s in spans} + assert by_name["aws.apigateway"]["meta"]["http.useragent"] == "curl/7.64.1" + assert by_name["aws.apigateway"]["parent"] is None + assert by_name["aws.lambda"]["parent"] == "aws.apigateway GET /" + assert by_name["requests.request"]["parent"] == "aws.lambda " + meta = by_name["aws.lambda"]["meta"] + assert meta["request_id"] == "" + assert meta["function_arn"] == ( + "arn:aws:lambda:eu-west-1::function:" + ) + assert meta["runtime-id"] == "" + assert meta["datadog_lambda"] == "" + assert meta["cold_start"] == "true" # compared exactly + assert by_name["aws.lambda"]["metrics"] == { + "process_id": "", + "_dd.top_level": 1, + } + assert by_name["requests.request"]["meta"]["http.useragent"] == ( + "python-requests/X" + ) + assert ( + "span_id" not in by_name["aws.lambda"] and "start" not in by_name["aws.lambda"] + ) + + +def test_normalize_requests_checks_header_formats(): + from tests.integration.harness.logs import HttpRequest + from tests.integration.harness.snapshots import normalize_requests + + good = HttpRequest( + method="GET", + url="https://datadoghq.com/", + headers={ + "traceparent": "00-" + "a" * 32 + "-" + "b" * 16 + "-01", + "tracestate": "dd=p:" + "b" * 16 + ";s:1;t.dm:-0;t.tid:" + "c" * 16, + "User-Agent": "datadogpy/0.52.0 (python 3.13.1; os linux; arch x86_64)", + "DD-API-KEY": "secret", + "Content-Length": "123", + }, + data={ + "series": [ + { + "metric": "hello.dog", + "points": [[1700000000, [1]]], + "tags": ["dd_lambda_layer:datadog-python313_8.130.0.dev0"], + } + ] + }, + ) + bad = HttpRequest("GET", "https://x/", {"traceparent": "garbage"}, {}) + out = {r["url"]: r for r in normalize_requests([good, bad], _ctx())} + headers = out["https://datadoghq.com/"]["headers"] + assert headers["traceparent"] == "00---01" + assert headers["tracestate"] == "dd=p:;s:1;t.dm:-0;t.tid:" + # The OpenTelemetry random value differs for every trace. + with_rv = HttpRequest( + "GET", + "https://rv/", + { + "tracestate": "dd=p:%s;s:1;t.dm:-0;t.tid:%s,ot=rv:c3fce776e0eb44;th:0" + % ("b" * 16, "c" * 16) + }, + {}, + ) + rv_headers = normalize_requests([with_rv], _ctx())[0]["headers"] + assert ( + rv_headers["tracestate"] + == "dd=p:;s:1;t.dm:-0;t.tid:,ot=rv:;th:0" + ) + assert headers["User-Agent"] == "datadogpy/X (python X; os linux; arch )" + assert headers["DD-API-KEY"] == "" + assert headers["Content-Length"] == "" + series = out["https://datadoghq.com/"]["data"]["series"][0] + assert series["points"] == [["", [1]]] + assert series["tags"] == ["dd_lambda_layer:datadog-_"] + # A malformed header is kept as-is, so it shows up in the diff. + assert out["https://x/"]["headers"]["traceparent"] == "garbage" + + +def test_span_snapshot_keeps_unmodeled_fields_and_span_pointers(): + from tests.integration.harness.snapshots import normalize_spans + + raw = _span("aws.s3", 1, 10, 0) + raw["span_links"] = [ + { + "trace_id": "0" * 32, + "span_id": "0" * 16, + "attributes": {"ptr.kind": "aws.s3.object", "ptr.hash": "1dc3"}, + }, + {"trace_id": "a" * 32, "span_id": "b" * 16, "attributes": {}}, + ] + raw["span_events"] = [{"name": "exception"}] # a field the harness doesn't model + (span,) = normalize_spans([raw], _ctx()) + assert span["span_links"][0]["attributes"]["ptr.kind"] == "aws.s3.object" + assert span["span_links"][0]["span_id"] == "0" * 16 + assert span["span_links"][1]["span_id"] == "" + assert span["span_events"] == [{"name": "exception"}] + assert not {"trace_id", "span_id", "parent_id", "start", "duration"} & set(span) + + +def test_metric_snapshot_keeps_unmodeled_fields(): + from tests.integration.harness.logs import Metric + from tests.integration.harness.snapshots import normalize_metrics + + line = json.dumps( + { + "m": "aws.lambda.enhanced.invocations", + "v": 1, + "e": 1700000000, + "t": ["runtime:python3.13", "datadog_lambda:v8.130.0"], + "type": "distribution", + } + ) + invs = split_invocations(["START RequestId: %s Version: $LATEST" % RID_1, line]) + (metric,) = normalize_metrics(invs[RID_1].metrics, _ctx()) + assert metric == { + "m": "aws.lambda.enhanced.invocations", + "v": 1, + "t": ["datadog_lambda:", "runtime:"], + "type": "distribution", + } + + # cold_start is normalized: warm and cold invocations give the same snapshot. + warm = Metric("aws.lambda.enhanced.invocations", 1, ["cold_start:false"]) + cold = Metric("aws.lambda.enhanced.invocations", 1, ["cold_start:true"]) + assert normalize_metrics([warm], _ctx()) == normalize_metrics([cold], _ctx()) + + +def test_shared_runtime_folds_into_parent_and_refuses_divergence(tmp_path, monkeypatch): + from tests.integration.harness import snapshots as snap + + monkeypatch.setitem(snap.SHARED_RUNTIMES, "python39", "python38") + assert snap.variants("python39", "amd64") == [ + "python39-amd64", + "python39", + "python38-amd64", + "python38", + "default", + ] + assert snap.variants("python310", "amd64") == [ + "python310-amd64", + "python310", + "default", + ] + keys = ["python310", "python38", "python39"] + same = "same\n" + for arch in snap.ARCHES: + for rk, value in ( + ("python310", same), + ("python38", "old\n"), + ("python39", "old\n"), + ): + snap.write_current( + "spans", rk, arch, "fn", "ev", {}, root=tmp_path + ).write_text(value) + + snap.dedupe(keys, root=tmp_path, functions=["fn"], events=["ev"]) + files = sorted(str(p.relative_to(tmp_path)) for p in tmp_path.rglob("*.json")) + assert not any("python39" in f for f in files), files + assert ( + snap.resolve("spans", "python39", "amd64", "fn", "ev", tmp_path).read_text() + == "old\n" + ) + + # python39 diverges from python38: dedupe must refuse rather than drop its file. + snap.write_current( + "spans", "python39", "amd64", "fn", "ev", {}, root=tmp_path + ).write_text("new\n") + before = sorted(str(p.relative_to(tmp_path)) for p in tmp_path.rglob("*.json")) + with pytest.raises(ValueError, match="remove python39 from SHARED_RUNTIMES"): + snap.dedupe(keys, root=tmp_path, functions=["fn"], events=["ev"]) + assert ( + sorted(str(p.relative_to(tmp_path)) for p in tmp_path.rglob("*.json")) == before + ) + + +def test_split_attributes_init_and_trailing_output(): + from tests.integration.harness.logs import InvocationLogs + + stream = _stream() + [ + "REPORT RequestId: %s\tDuration: 1.00 ms\t" % RID_2, + "[WARNING]\t2026-12-01T00:00:00.123Z\t%s\tshutting down" % RID_2, + ] + invs = split_invocations(stream) + # INIT output is attributed to the first invocation. + assert "init message" in invs[RID_1].other_lines + assert any("something broke" in line for line in invs[RID_2].other_lines) + # Output after the stream's last REPORT goes to the last invocation. + assert any("shutting down" in line for line in invs[RID_2].other_lines) + # Recognized lines are not repeated as "other". + assert not any(line.startswith(("{", "HTTP ")) for line in invs[RID_1].other_lines) + + # Platform lines are dropped from the unexpected output; anything else is kept. + inv = InvocationLogs(RID_1) + inv.other_lines = [ + "INIT_START Runtime Version: python:3.13.v20", + "EXTENSION\tName: datadog-agent\tState: Ready", + "TELEMETRY\tSubscription: ok", + "[WARNING]\t2026-12-01T00:00:00.123Z\t%s\tobject at 0xdeadbeef1234 leaked" + % RID_1, + ] + assert inv.unexpected_lines() == [inv.other_lines[-1]] + + +def _dedupe_value(rk, arch, ev): + """A scenario with every kind of override: python38 differs everywhere, python314 + differs on amd64 only, and event "b" differs everywhere. Function-level + categories pass ev=None.""" + if ev == "b": + return "exception\n" + if rk == "python38": + return "old\n" + if (rk, arch) == ("python314", "amd64"): + return "zstd\n" + return "common\n" + + +@pytest.mark.parametrize( + "category, expected_files", + [ + ( + "spans", + [ + "spans/default/fn/a.json", + "spans/default/fn/b.json", + "spans/default/fn/c.json", + "spans/python38/fn/a.json", + "spans/python38/fn/c.json", + "spans/python314-amd64/fn/a.json", + "spans/python314-amd64/fn/c.json", + ], + ), + ( + "metrics", + [ + "metrics/default/fn.json", + "metrics/python38/fn.json", + "metrics/python314-amd64/fn.json", + ], + ), + ( + "requests", + [ + "requests/default/fn.json", + "requests/default/fn/b.json", + "requests/python38/fn.json", + "requests/python314-amd64/fn.json", + ], + ), + ], +) +def test_dedupe_keeps_every_case_and_writes_only_needed_files( + tmp_path, category, expected_files +): + """Each layout folds into the fewest files, and every case still resolves to + the content it had before dedupe.""" + from tests.integration.harness import snapshots as snap + + keys = ["python310", "python311", "python38", "python314"] + events = ["a", "b", "c"] + per_event = "event" in snap.LEVELS[category] + cases = [] + for rk in keys: + for arch in snap.ARCHES: + for ev in events if per_event else [None]: + value = _dedupe_value(rk, arch, ev) + snap.write_current( + category, rk, arch, "fn", ev, {}, root=tmp_path + ).write_text(value) + cases.append((rk, arch, ev, value)) + + snap.dedupe(keys, root=tmp_path, functions=["fn"], events=events) + files = sorted(str(p.relative_to(tmp_path)) for p in tmp_path.rglob("*.json")) + assert files == sorted(expected_files) + for rk, arch, ev, value in cases: + path = snap.resolve(category, rk, arch, "fn", ev, tmp_path) + assert path.read_text() == value, (rk, arch, ev) + + +def test_user_agent_versions_only_normalized_for_known_clients(): + from tests.integration.harness.snapshots import _versions + + assert _versions("python-requests/2.33.1") == "python-requests/X" + assert ( + _versions("datadogpy/0.52.1 (python 3.13.1; os linux; arch aarch64)") + == "datadogpy/X (python X; os linux; arch )" + ) + browser = "Mozilla/5.0 (Windows NT 10.0) Chrome/80.0.3987.132 Safari/537.36" + assert _versions(browser) == browser