Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Instrumentation.AwsLambda] Rename Trace to TraceAsync where appropriate #608

Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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