Skip to content

Commit

Permalink
[Instrumentation.AwsLambda] Rename Trace to TraceAsync where appropri…
Browse files Browse the repository at this point in the history
…ate (#608)
  • Loading branch information
Oberon00 authored Sep 2, 2022
1 parent e7bc1b0 commit 071a1d9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
50 changes: 25 additions & 25 deletions src/OpenTelemetry.Instrumentation.AWSLambda/AWSLambdaWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,80 +98,80 @@ public static void Trace<TInput>(
}

/// <summary>
/// Tracing wrapper for async Lambda handler.
/// Tracing wrapper for Lambda handler.
/// </summary>
/// <typeparam name="TInput">Input.</typeparam>
/// <param name="tracerProvider">TracerProvider passed in.</param>
/// <param name="lambdaHandler">Lambda handler function passed in.</param>
/// <param name="input">Instance of input.</param>
/// <param name="context">Lambda context (optional, but strongly recommended).</param>
/// <param name="context">Instance of lambda context.</param>
/// <param name="parentContext">
/// The optional parent context <see cref="ActivityContext"/> 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.
/// </param>
/// <returns>Task.</returns>
public static Task Trace<TInput>(
public static void Trace(
TracerProvider tracerProvider,
Func<TInput, ILambdaContext, Task> lambdaHandler,
TInput input,
Action<ILambdaContext> lambdaHandler,
ILambdaContext context,
ActivityContext parentContext = default)
{
Func<Task> action = async () => await lambdaHandler(input, context);
return TraceInternalAsync(tracerProvider, action, input, context, parentContext);
Action action = () => lambdaHandler(context);
TraceInternal<object>(tracerProvider, action, null, context, parentContext);
}

/// <summary>
/// Tracing wrapper for async Lambda handler.
/// </summary>
/// <typeparam name="TInput">Input.</typeparam>
/// <typeparam name="TResult">Output result.</typeparam>
/// <param name="tracerProvider">TracerProvider passed in.</param>
/// <param name="lambdaHandler">Lambda handler function passed in.</param>
/// <param name="input">Instance of input.</param>
/// <param name="context">Instance of lambda context.</param>
/// <param name="context">Lambda context (optional, but strongly recommended).</param>
/// <param name="parentContext">
/// The optional parent context <see cref="ActivityContext"/> 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.
/// </param>
/// <returns>Task of result.</returns>
public static async Task<TResult> Trace<TInput, TResult>(
/// <returns>Task.</returns>
public static Task TraceAsync<TInput>(
TracerProvider tracerProvider,
Func<TInput, ILambdaContext, Task<TResult>> lambdaHandler,
Func<TInput, ILambdaContext, Task> lambdaHandler,
TInput input,
ILambdaContext context,
ActivityContext parentContext = default)
{
TResult result = default;
Func<Task> action = async () => result = await lambdaHandler(input, context);
await TraceInternalAsync(tracerProvider, action, input, context, parentContext);
return result;
Func<Task> action = async () => await lambdaHandler(input, context);
return TraceInternalAsync(tracerProvider, action, input, context, parentContext);
}

/// <summary>
/// Tracing wrapper for Lambda handler.
/// Tracing wrapper for async Lambda handler.
/// </summary>
/// <typeparam name="TInput">Input.</typeparam>
/// <typeparam name="TResult">Output result.</typeparam>
/// <param name="tracerProvider">TracerProvider passed in.</param>
/// <param name="lambdaHandler">Lambda handler function passed in.</param>
/// <param name="input">Instance of input.</param>
/// <param name="context">Instance of lambda context.</param>
/// <param name="parentContext">
/// The optional parent context <see cref="ActivityContext"/> 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.
/// </param>
public static void Trace(
/// <returns>Task of result.</returns>
public static async Task<TResult> TraceAsync<TInput, TResult>(
TracerProvider tracerProvider,
Action<ILambdaContext> lambdaHandler,
Func<TInput, ILambdaContext, Task<TResult>> lambdaHandler,
TInput input,
ILambdaContext context,
ActivityContext parentContext = default)
{
Action action = () => lambdaHandler(context);
TraceInternal<object>(tracerProvider, action, null, context, parentContext);
TResult result = default;
Func<Task> action = async () => result = await lambdaHandler(input, context);
await TraceInternalAsync(tracerProvider, action, input, context, parentContext);
return result;
}

/// <summary>
Expand All @@ -187,7 +187,7 @@ public static void Trace(
/// unless X-Ray propagation is disabled in the configuration.
/// </param>
/// <returns>Task.</returns>
public static Task Trace(
public static Task TraceAsync(
TracerProvider tracerProvider,
Func<ILambdaContext, Task> lambdaHandler,
ILambdaContext context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand Down

0 comments on commit 071a1d9

Please sign in to comment.