From bbf6448efff74e2cee243d93974e6327b9673bfd Mon Sep 17 00:00:00 2001 From: Oleksiy Dubinin Date: Wed, 8 Jun 2022 11:50:01 +0200 Subject: [PATCH] - removed flag for ignoring x-ray propagation: x-ray is used as a fallback when parent context is not provided (#403) --- .../AWSLambdaInstrumentationOptions.cs | 31 ----------------- .../Implementation/AWSLambdaWrapper.cs | 33 ++++++------------- .../TracerProviderBuilderExtensions.cs | 10 +----- 3 files changed, 11 insertions(+), 63 deletions(-) delete mode 100644 src/OpenTelemetry.Contrib.Instrumentation.AWSLambda/AWSLambdaInstrumentationOptions.cs diff --git a/src/OpenTelemetry.Contrib.Instrumentation.AWSLambda/AWSLambdaInstrumentationOptions.cs b/src/OpenTelemetry.Contrib.Instrumentation.AWSLambda/AWSLambdaInstrumentationOptions.cs deleted file mode 100644 index f2b61bc231..0000000000 --- a/src/OpenTelemetry.Contrib.Instrumentation.AWSLambda/AWSLambdaInstrumentationOptions.cs +++ /dev/null @@ -1,31 +0,0 @@ -// -// Copyright The OpenTelemetry Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -namespace OpenTelemetry.Contrib.Instrumentation.AWSLambda -{ - /// - /// Options for AWS lambda instrumentation. - /// - public class AWSLambdaInstrumentationOptions - { - /// - /// Gets or sets a value indicating whether AWS X-Ray propagation is ignored. - /// This option has to be used as a workaround until resolution of the issue - /// https://github.com/open-telemetry/opentelemetry-dotnet/issues/3290. - /// - public bool IgnoreAWSXRayPropagation { get; set; } - } -} diff --git a/src/OpenTelemetry.Contrib.Instrumentation.AWSLambda/Implementation/AWSLambdaWrapper.cs b/src/OpenTelemetry.Contrib.Instrumentation.AWSLambda/Implementation/AWSLambdaWrapper.cs index 6b5c584dde..acf370ea3d 100644 --- a/src/OpenTelemetry.Contrib.Instrumentation.AWSLambda/Implementation/AWSLambdaWrapper.cs +++ b/src/OpenTelemetry.Contrib.Instrumentation.AWSLambda/Implementation/AWSLambdaWrapper.cs @@ -30,11 +30,6 @@ public class AWSLambdaWrapper { private static readonly ActivitySource AWSLambdaActivitySource = new(AWSLambdaUtils.ActivitySourceName); - /// - /// Gets or sets a value indicating whether AWS X-Ray propagation is ignored. - /// - internal static bool IgnoreAWSXRayPropagation { get; set; } - /// /// Tracing wrapper for Lambda handler without Lambda context. /// @@ -45,8 +40,7 @@ public class AWSLambdaWrapper /// Instance of input. /// /// The optional parent context used for Activity object creation. - /// If the parent context parametere is not provided then X-Ray propagation is used to extract the parent - /// if configuration flag is not set to true. + /// If the parent context parametere is not provided then X-Ray propagation is used to extract the parent. /// /// The optional tags list to initialize the created Activity object with. /// Instance of output result. @@ -69,8 +63,7 @@ public static TResult Trace( /// Instance of input. /// /// The optional parent context used for Activity object creation. - /// If the parent context parametere is not provided then X-Ray propagation is used to extract the parent - /// if configuration flag is not set to true. + /// If the parent context parametere is not provided then X-Ray propagation is used to extract the parent. /// /// The optional tags list to initialize the created Activity object with. public static void Trace( @@ -92,8 +85,7 @@ public static void Trace( /// Instance of input. /// /// The optional parent context used for Activity object creation. - /// If the parent context parametere is not provided then X-Ray propagation is used to extract the parent - /// if configuration flag is not set to true. + /// If the parent context parametere is not provided then X-Ray propagation is used to extract the parent. /// /// The optional tags list to initialize the created Activity object with. /// Task. @@ -117,8 +109,7 @@ public static async Task Trace( /// Instance of input. /// /// The optional parent context used for Activity object creation. - /// If the parent context parametere is not provided then X-Ray propagation is used to extract the parent - /// if configuration flag is not set to true. + /// If the parent context parametere is not provided then X-Ray propagation is used to extract the parent. /// /// The optional tags list to initialize the created Activity object with. /// Task of result. @@ -129,7 +120,7 @@ public static async Task Trace( ActivityContext parentContext = default, IEnumerable> tags = null) { - return await Intercept(tracerProvider, () => lambdaHandler(input), default, default, tags); + return await Intercept(tracerProvider, () => lambdaHandler(input), default, parentContext, tags); } /// @@ -143,8 +134,7 @@ public static async Task Trace( /// Instance of lambda context. /// /// The optional parent context used for Activity object creation. - /// If the parent context parametere is not provided then X-Ray propagation is used to extract the parent - /// if configuration flag is not set to true. + /// If the parent context parametere is not provided then X-Ray propagation is used to extract the parent. /// /// The optional tags list to initialize the created Activity object with. /// Instance of output result. @@ -169,8 +159,7 @@ public static TResult Trace( /// Instance of lambda context. /// /// The optional parent context used for Activity object creation. - /// If the parent context parametere is not provided then X-Ray propagation is used to extract the parent - /// if configuration flag is not set to true. + /// If the parent context parametere is not provided then X-Ray propagation is used to extract the parent. /// /// The optional tags list to initialize the created Activity object with. public static void Trace( @@ -194,8 +183,7 @@ public static void Trace( /// Instance of lambda context. /// /// The optional parent context used for Activity object creation. - /// If the parent context parametere is not provided then X-Ray propagation is used to extract the parent - /// if configuration flag is not set to true. + /// If the parent context parametere is not provided then X-Ray propagation is used to extract the parent. /// /// The optional tags list to initialize the created Activity object with. /// Task. @@ -221,8 +209,7 @@ public static async Task Trace( /// Instance of lambda context. /// /// The optional parent context used for Activity object creation. - /// If the parent context parametere is not provided then X-Ray propagation is used to extract the parent - /// if configuration flag is not set to true. + /// If the parent context parametere is not provided then X-Ray propagation is used to extract the parent. /// /// The optional tags list to initialize the created Activity object with. /// Task of result. @@ -338,7 +325,7 @@ private static Activity OnFunctionStart( ActivityContext parentContext = default, IEnumerable> tags = null) { - if (parentContext == default && !IgnoreAWSXRayPropagation) + if (parentContext == default) { parentContext = AWSLambdaUtils.GetParentContext(); } diff --git a/src/OpenTelemetry.Contrib.Instrumentation.AWSLambda/TracerProviderBuilderExtensions.cs b/src/OpenTelemetry.Contrib.Instrumentation.AWSLambda/TracerProviderBuilderExtensions.cs index 40be76a6f1..8ff15fa489 100644 --- a/src/OpenTelemetry.Contrib.Instrumentation.AWSLambda/TracerProviderBuilderExtensions.cs +++ b/src/OpenTelemetry.Contrib.Instrumentation.AWSLambda/TracerProviderBuilderExtensions.cs @@ -31,19 +31,11 @@ public static class TracerProviderBuilderExtensions /// Add AWS Lambda configurations. /// /// being configured. - /// . /// The instance of to chain the calls. - public static TracerProviderBuilder AddAWSLambdaConfigurations( - this TracerProviderBuilder builder, - Action configure = null) + public static TracerProviderBuilder AddAWSLambdaConfigurations(this TracerProviderBuilder builder) { Guard.ThrowIfNull(builder); - var options = new AWSLambdaInstrumentationOptions(); - configure?.Invoke(options); - - AWSLambdaWrapper.IgnoreAWSXRayPropagation = options.IgnoreAWSXRayPropagation; - builder.AddSource(AWSLambdaUtils.ActivitySourceName); builder.SetResourceBuilder(ResourceBuilder .CreateEmpty()