diff --git a/instrumentation/opentelemetry-instrumentation-aws-lambda/src/opentelemetry/instrumentation/aws_lambda/__init__.py b/instrumentation/opentelemetry-instrumentation-aws-lambda/src/opentelemetry/instrumentation/aws_lambda/__init__.py index 0334230b2d..7ea56b4880 100644 --- a/instrumentation/opentelemetry-instrumentation-aws-lambda/src/opentelemetry/instrumentation/aws_lambda/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-aws-lambda/src/opentelemetry/instrumentation/aws_lambda/__init__.py @@ -82,7 +82,7 @@ def custom_event_context_extractor(lambda_event): from opentelemetry.instrumentation.instrumentor import BaseInstrumentor from opentelemetry.instrumentation.utils import unwrap from opentelemetry.metrics import MeterProvider, get_meter_provider -from opentelemetry.propagate import get_global_textmap +from opentelemetry.propagate import extract, get_global_textmap from opentelemetry.semconv.resource import ResourceAttributes from opentelemetry.semconv.trace import SpanAttributes from opentelemetry.trace import ( @@ -94,7 +94,6 @@ def custom_event_context_extractor(lambda_event): ) from opentelemetry.trace.propagation import get_current_span from opentelemetry.trace.status import Status, StatusCode -from opentelemetry.propagate import extract logger = logging.getLogger(__name__) diff --git a/instrumentation/opentelemetry-instrumentation-aws-lambda/tests/mocks/lambda_function.py b/instrumentation/opentelemetry-instrumentation-aws-lambda/tests/mocks/lambda_function.py index fdf2a4c297..0a3c0edc3e 100644 --- a/instrumentation/opentelemetry-instrumentation-aws-lambda/tests/mocks/lambda_function.py +++ b/instrumentation/opentelemetry-instrumentation-aws-lambda/tests/mocks/lambda_function.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. + def handler(event, context): # The purpose of this function is to be used as the call_wrapped function # of _instrumented_lambda_handler_call. diff --git a/propagator/opentelemetry-propagator-aws-xray/tests/test_aws_xray_lambda_propagator.py b/propagator/opentelemetry-propagator-aws-xray/tests/test_aws_xray_lambda_propagator.py index bd66b4f230..336bb6d6cb 100644 --- a/propagator/opentelemetry-propagator-aws-xray/tests/test_aws_xray_lambda_propagator.py +++ b/propagator/opentelemetry-propagator-aws-xray/tests/test_aws_xray_lambda_propagator.py @@ -19,12 +19,12 @@ from requests.structures import CaseInsensitiveDict from opentelemetry.context import get_current +from opentelemetry.instrumentation.aws_lambda import _X_AMZN_TRACE_ID from opentelemetry.propagators.aws.aws_xray_propagator import ( TRACE_HEADER_KEY, AwsXrayLambdaPropagator, AwsXRayPropagator, ) -from opentelemetry.instrumentation.aws_lambda import _X_AMZN_TRACE_ID from opentelemetry.propagators.textmap import DefaultGetter from opentelemetry.sdk.trace import ReadableSpan from opentelemetry.trace import ( @@ -173,7 +173,7 @@ def test_add_link_from_environment_variable(self): "Parent=1234567890123456;" "Sampled=1" ), - } + }, ) def test_equivalent_extraction(self): @@ -189,18 +189,12 @@ def check_context(context) -> str: self.assertEqual( hex(span_context.trace_id), - "0x12345678123456789012345678901234" + "0x12345678123456789012345678901234", ) - self.assertEqual( - hex(span_context.span_id), - "0x1234567890123456" - ) + self.assertEqual(hex(span_context.span_id), "0x1234567890123456") - self.assertEqual( - hex(span_context.trace_flags), - "0x1" - ) + self.assertEqual(hex(span_context.trace_flags), "0x1") return context_key @@ -210,5 +204,5 @@ def check_context(context) -> str: {TRACE_HEADER_KEY: environ.get(_X_AMZN_TRACE_ID)} ) ), - check_context(AwsXrayLambdaPropagator().extract({})) + check_context(AwsXrayLambdaPropagator().extract({})), )