From c58710d2a20f448e8234b508829c0851ceae563d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Neum=C3=BCller?= Date: Wed, 24 Aug 2022 18:22:46 +0200 Subject: [PATCH 1/2] [Instrumentation.AwsLambda] Rename Trace to TraceAsync where appropriate. --- .../Implementation/AWSLambdaWrapper.cs | 6 +++--- .../AWSLambdaWrapperTests.cs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/OpenTelemetry.Contrib.Instrumentation.AWSLambda/Implementation/AWSLambdaWrapper.cs b/src/OpenTelemetry.Contrib.Instrumentation.AWSLambda/Implementation/AWSLambdaWrapper.cs index 4ca66e3c7a..2ac8cb602c 100644 --- a/src/OpenTelemetry.Contrib.Instrumentation.AWSLambda/Implementation/AWSLambdaWrapper.cs +++ b/src/OpenTelemetry.Contrib.Instrumentation.AWSLambda/Implementation/AWSLambdaWrapper.cs @@ -103,7 +103,7 @@ public static void Trace( /// unless X-Ray propagation is disabled in the configuration for this wrapper. /// /// Task. - public static Task Trace( + public static Task TraceAsync( TracerProvider tracerProvider, Func lambdaHandler, TInput input, @@ -130,7 +130,7 @@ public static Task Trace( /// unless X-Ray propagation is disabled in the configuration for this wrapper. /// /// Task of result. - public static async Task Trace( + public static async Task TraceAsync( TracerProvider tracerProvider, Func> lambdaHandler, TInput input, @@ -178,7 +178,7 @@ public static void Trace( /// unless X-Ray propagation is disabled in the configuration. /// /// Task. - public static Task Trace( + public static Task TraceAsync( TracerProvider tracerProvider, Func lambdaHandler, ILambdaContext context, diff --git a/test/OpenTelemetry.Contrib.Instrumentation.AWSLambda.Tests/AWSLambdaWrapperTests.cs b/test/OpenTelemetry.Contrib.Instrumentation.AWSLambda.Tests/AWSLambdaWrapperTests.cs index 724806bac2..8e92e9ddf5 100644 --- a/test/OpenTelemetry.Contrib.Instrumentation.AWSLambda.Tests/AWSLambdaWrapperTests.cs +++ b/test/OpenTelemetry.Contrib.Instrumentation.AWSLambda.Tests/AWSLambdaWrapperTests.cs @@ -137,7 +137,7 @@ public async Task TraceAsyncWithInputAndReturn(bool setCustomParent) .Build()) { var parentContext = setCustomParent ? CreateParentContext() : default; - var result = await AWSLambdaWrapper.Trace(tracerProvider, this.sampleHandlers.SampleHandlerAsyncInputAndReturn, "TestStream", this.sampleLambdaContext, parentContext); + var result = await AWSLambdaWrapper.TraceAsync(tracerProvider, this.sampleHandlers.SampleHandlerAsyncInputAndReturn, "TestStream", this.sampleLambdaContext, parentContext); var resource = tracerProvider.GetResource(); this.AssertResourceAttributes(resource); } @@ -163,7 +163,7 @@ public async Task TraceAsyncWithInputAndNoReturn(bool setCustomParent) .Build()) { var parentContext = setCustomParent ? CreateParentContext() : default; - await AWSLambdaWrapper.Trace(tracerProvider, this.sampleHandlers.SampleHandlerAsyncInputAndNoReturn, "TestStream", this.sampleLambdaContext, parentContext); + await AWSLambdaWrapper.TraceAsync(tracerProvider, this.sampleHandlers.SampleHandlerAsyncInputAndNoReturn, "TestStream", this.sampleLambdaContext, parentContext); var resource = tracerProvider.GetResource(); this.AssertResourceAttributes(resource); } @@ -189,7 +189,7 @@ public async Task TraceAsyncWithNoInputAndNoReturn(bool setCustomParent) .Build()) { var parentContext = setCustomParent ? CreateParentContext() : default; - await AWSLambdaWrapper.Trace(tracerProvider, this.sampleHandlers.SampleHandlerAsyncNoInputAndNoReturn, this.sampleLambdaContext, parentContext); + await AWSLambdaWrapper.TraceAsync(tracerProvider, this.sampleHandlers.SampleHandlerAsyncNoInputAndNoReturn, this.sampleLambdaContext, parentContext); var resource = tracerProvider.GetResource(); this.AssertResourceAttributes(resource); } From 216ea997b9c1bfc6cefd1029363129bcc510921e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Neum=C3=BCller?= Date: Wed, 24 Aug 2022 18:24:50 +0200 Subject: [PATCH 2/2] Regroup overloads. --- .../Implementation/AWSLambdaWrapper.cs | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/OpenTelemetry.Contrib.Instrumentation.AWSLambda/Implementation/AWSLambdaWrapper.cs b/src/OpenTelemetry.Contrib.Instrumentation.AWSLambda/Implementation/AWSLambdaWrapper.cs index 2ac8cb602c..dd053fdd61 100644 --- a/src/OpenTelemetry.Contrib.Instrumentation.AWSLambda/Implementation/AWSLambdaWrapper.cs +++ b/src/OpenTelemetry.Contrib.Instrumentation.AWSLambda/Implementation/AWSLambdaWrapper.cs @@ -88,6 +88,28 @@ public static void Trace( TraceInternal(tracerProvider, action, input, context, parentContext); } + /// + /// Tracing wrapper for Lambda handler. + /// + /// TracerProvider passed in. + /// Lambda handler function passed in. + /// Instance of lambda context. + /// + /// The optional parent context is used for Activity object creation. + /// If no parent context provided, incoming request is used to extract one. + /// If parent is not extracted from incoming request then X-Ray propagation is used to extract one + /// unless X-Ray propagation is disabled in the configuration for this wrapper. + /// + public static void Trace( + TracerProvider tracerProvider, + Action lambdaHandler, + ILambdaContext context, + ActivityContext parentContext = default) + { + Action action = () => lambdaHandler(context); + TraceInternal(tracerProvider, action, null, context, parentContext); + } + /// /// Tracing wrapper for async Lambda handler. /// @@ -143,28 +165,6 @@ public static async Task TraceAsync( return result; } - /// - /// Tracing wrapper for Lambda handler. - /// - /// TracerProvider passed in. - /// Lambda handler function passed in. - /// Instance of lambda context. - /// - /// The optional parent context is used for Activity object creation. - /// If no parent context provided, incoming request is used to extract one. - /// If parent is not extracted from incoming request then X-Ray propagation is used to extract one - /// unless X-Ray propagation is disabled in the configuration for this wrapper. - /// - public static void Trace( - TracerProvider tracerProvider, - Action lambdaHandler, - ILambdaContext context, - ActivityContext parentContext = default) - { - Action action = () => lambdaHandler(context); - TraceInternal(tracerProvider, action, null, context, parentContext); - } - /// /// Tracing wrapper for async Lambda handler. ///