def create_writer(self): self.output = DummyOutput() writer = LogWriter(out=self.output) for i in range(self.N_TRACES): writer.write( [Span(tracer=None, name="name", trace_id=i, span_id=j, parent_id=j - 1 or None) for j in range(7)] ) return writer
import os import requests from decorator import conditional_decorator from datadog_lambda.metric import lambda_metric from datadog_lambda.wrapper import datadog_lambda_wrapper from ddtrace import tracer from ddtrace.internal.writer import LogWriter tracer.writer = LogWriter() with_plugin = os.getenv("WITH_PLUGIN", False) @conditional_decorator(datadog_lambda_wrapper, with_plugin) def handle(event, context): lambda_metric("hello.dog", 1, tags=["team:serverless", "role:hello"]) lambda_metric("tests.integration.count", 21, tags=["test:integration", "role:hello"]) requests.get("https://ip-ranges.datadoghq.com/") requests.get("https://ip-ranges.datadoghq.eu/") return {"statusCode": 200, "body": {"message": "hello, dog!"}}