Skip to content

Commit

Permalink
- removed flag for ignoring x-ray propagation: x-ray is used as a fal…
Browse files Browse the repository at this point in the history
…lback when parent context is not provided (open-telemetry#403)
  • Loading branch information
rypdal committed Jun 8, 2022
1 parent 2e8d92f commit bbf6448
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 63 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ public class AWSLambdaWrapper
{
private static readonly ActivitySource AWSLambdaActivitySource = new(AWSLambdaUtils.ActivitySourceName);

/// <summary>
/// Gets or sets a value indicating whether AWS X-Ray propagation is ignored.
/// </summary>
internal static bool IgnoreAWSXRayPropagation { get; set; }

/// <summary>
/// Tracing wrapper for Lambda handler without Lambda context.
/// </summary>
Expand All @@ -45,8 +40,7 @@ public class AWSLambdaWrapper
/// <param name="input">Instance of input.</param>
/// <param name="parentContext">
/// The optional parent context <see cref="ActivityContext"/> 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 <see cref="AWSLambdaInstrumentationOptions.IgnoreAWSXRayPropagation"/> is not set to true.
/// If the parent context parametere is not provided then X-Ray propagation is used to extract the parent.
/// </param>
/// <param name="tags">The optional tags list to initialize the created Activity object with.</param>
/// <returns>Instance of output result.</returns>
Expand All @@ -69,8 +63,7 @@ public static TResult Trace<TInput, TResult>(
/// <param name="input">Instance of input.</param>
/// <param name="parentContext">
/// The optional parent context <see cref="ActivityContext"/> 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 <see cref="AWSLambdaInstrumentationOptions.IgnoreAWSXRayPropagation"/> is not set to true.
/// If the parent context parametere is not provided then X-Ray propagation is used to extract the parent.
/// </param>
/// <param name="tags">The optional tags list to initialize the created Activity object with.</param>
public static void Trace<TInput>(
Expand All @@ -92,8 +85,7 @@ public static void Trace<TInput>(
/// <param name="input">Instance of input.</param>
/// <param name="parentContext">
/// The optional parent context <see cref="ActivityContext"/> 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 <see cref="AWSLambdaInstrumentationOptions.IgnoreAWSXRayPropagation"/> is not set to true.
/// If the parent context parametere is not provided then X-Ray propagation is used to extract the parent.
/// </param>
/// <param name="tags">The optional tags list to initialize the created Activity object with.</param>
/// <returns>Task.</returns>
Expand All @@ -117,8 +109,7 @@ public static async Task Trace<TInput>(
/// <param name="input">Instance of input.</param>
/// <param name="parentContext">
/// The optional parent context <see cref="ActivityContext"/> 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 <see cref="AWSLambdaInstrumentationOptions.IgnoreAWSXRayPropagation"/> is not set to true.
/// If the parent context parametere is not provided then X-Ray propagation is used to extract the parent.
/// </param>
/// <param name="tags">The optional tags list to initialize the created Activity object with.</param>
/// <returns>Task of result.</returns>
Expand All @@ -129,7 +120,7 @@ public static async Task<TResult> Trace<TInput, TResult>(
ActivityContext parentContext = default,
IEnumerable<KeyValuePair<string, object>> tags = null)
{
return await Intercept(tracerProvider, () => lambdaHandler(input), default, default, tags);
return await Intercept(tracerProvider, () => lambdaHandler(input), default, parentContext, tags);
}

/// <summary>
Expand All @@ -143,8 +134,7 @@ public static async Task<TResult> Trace<TInput, TResult>(
/// <param name="context">Instance of lambda context.</param>
/// <param name="parentContext">
/// The optional parent context <see cref="ActivityContext"/> 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 <see cref="AWSLambdaInstrumentationOptions.IgnoreAWSXRayPropagation"/> is not set to true.
/// If the parent context parametere is not provided then X-Ray propagation is used to extract the parent.
/// </param>
/// <param name="tags">The optional tags list to initialize the created Activity object with.</param>
/// <returns>Instance of output result.</returns>
Expand All @@ -169,8 +159,7 @@ public static TResult Trace<TInput, TResult>(
/// <param name="context">Instance of lambda context.</param>
/// <param name="parentContext">
/// The optional parent context <see cref="ActivityContext"/> 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 <see cref="AWSLambdaInstrumentationOptions.IgnoreAWSXRayPropagation"/> is not set to true.
/// If the parent context parametere is not provided then X-Ray propagation is used to extract the parent.
/// </param>
/// <param name="tags">The optional tags list to initialize the created Activity object with.</param>
public static void Trace<TInput>(
Expand All @@ -194,8 +183,7 @@ public static void Trace<TInput>(
/// <param name="context">Instance of lambda context.</param>
/// <param name="parentContext">
/// The optional parent context <see cref="ActivityContext"/> 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 <see cref="AWSLambdaInstrumentationOptions.IgnoreAWSXRayPropagation"/> is not set to true.
/// If the parent context parametere is not provided then X-Ray propagation is used to extract the parent.
/// </param>
/// <param name="tags">The optional tags list to initialize the created Activity object with.</param>
/// <returns>Task.</returns>
Expand All @@ -221,8 +209,7 @@ public static async Task Trace<TInput>(
/// <param name="context">Instance of lambda context.</param>
/// <param name="parentContext">
/// The optional parent context <see cref="ActivityContext"/> 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 <see cref="AWSLambdaInstrumentationOptions.IgnoreAWSXRayPropagation"/> is not set to true.
/// If the parent context parametere is not provided then X-Ray propagation is used to extract the parent.
/// </param>
/// <param name="tags">The optional tags list to initialize the created Activity object with.</param>
/// <returns>Task of result.</returns>
Expand Down Expand Up @@ -338,7 +325,7 @@ private static Activity OnFunctionStart(
ActivityContext parentContext = default,
IEnumerable<KeyValuePair<string, object>> tags = null)
{
if (parentContext == default && !IgnoreAWSXRayPropagation)
if (parentContext == default)
{
parentContext = AWSLambdaUtils.GetParentContext();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,11 @@ public static class TracerProviderBuilderExtensions
/// Add AWS Lambda configurations.
/// </summary>
/// <param name="builder"><see cref="TracerProviderBuilder"/> being configured.</param>
/// <param name="configure"><see cref="AWSLambdaInstrumentationOptions"/>.</param>
/// <returns>The instance of <see cref="TracerProviderBuilder"/> to chain the calls.</returns>
public static TracerProviderBuilder AddAWSLambdaConfigurations(
this TracerProviderBuilder builder,
Action<AWSLambdaInstrumentationOptions> 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()
Expand Down

0 comments on commit bbf6448

Please sign in to comment.