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

[OpenTelemetry.Instrumentation.AWSLambda]: update README according to the recent code changes. #1234

Merged
merged 23 commits into from
Jun 15, 2023
Merged
Changes from 14 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
ffc089b
[OpenTelemetry.Instrumentation.AWSLambda]: bringing README.md up to date
rypdal Jun 13, 2023
85fbfe9
Merge branch 'main' into feature/actualize-aws-lambda-readme
rypdal Jun 14, 2023
93c6d88
[OpenTelemetry.Instrumentation.AWSLambda]: README update: fixed missp…
rypdal Jun 14, 2023
5e50a39
[OpenTelemetry.Instrumentation.AWSLambda]: README update: lines refor…
rypdal Jun 14, 2023
d119455
[OpenTelemetry.Instrumentation.AWSLambda]: README update: lines refor…
rypdal Jun 14, 2023
ba64135
Update src/OpenTelemetry.Instrumentation.AWSLambda/README.md
rypdal Jun 14, 2023
db21d55
Update src/OpenTelemetry.Instrumentation.AWSLambda/README.md
rypdal Jun 14, 2023
ba873e4
Update src/OpenTelemetry.Instrumentation.AWSLambda/README.md
rypdal Jun 14, 2023
2053e03
[OpenTelemetry.Instrumentation.AWSLambda]: README update: review sugg…
rypdal Jun 14, 2023
6ebe475
[OpenTelemetry.Instrumentation.AWSLambda]: README update: fixed the r…
rypdal Jun 14, 2023
d0619eb
[OpenTelemetry.Instrumentation.AWSLambda]: README update: fixed the r…
rypdal Jun 14, 2023
322c892
[OpenTelemetry.Instrumentation.AWSLambda]: README update: removed lin…
rypdal Jun 14, 2023
cc1ecb8
[OpenTelemetry.Instrumentation.AWSLambda]: README update: consistent …
rypdal Jun 14, 2023
6528d9d
[OpenTelemetry.Instrumentation.AWSLambda]: README update: removed red…
rypdal Jun 14, 2023
f211089
Update src/OpenTelemetry.Instrumentation.AWSLambda/README.md
rypdal Jun 15, 2023
9d233bd
Update src/OpenTelemetry.Instrumentation.AWSLambda/README.md
rypdal Jun 15, 2023
f1239d9
Update src/OpenTelemetry.Instrumentation.AWSLambda/README.md
rypdal Jun 15, 2023
59e5d22
Update src/OpenTelemetry.Instrumentation.AWSLambda/README.md
rypdal Jun 15, 2023
a7457a3
Update src/OpenTelemetry.Instrumentation.AWSLambda/README.md
rypdal Jun 15, 2023
9a088e2
[OpenTelemetry.Instrumentation.AWSLambda]: README update: some re-for…
rypdal Jun 15, 2023
091edcf
[OpenTelemetry.Instrumentation.AWSLambda]: README update: some clarif…
rypdal Jun 15, 2023
182cf10
[OpenTelemetry.Instrumentation.AWSLambda]: README update: tailing space
rypdal Jun 15, 2023
ca1fc7d
Merge branch 'main' into feature/actualize-aws-lambda-readme
Kielek Jun 15, 2023
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
39 changes: 34 additions & 5 deletions src/OpenTelemetry.Instrumentation.AWSLambda/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,45 @@ Add `AddAWSLambdaConfigurations()` to `TracerProvider`.
```csharp
TracerProvider tracerProvider = Sdk.CreateTracerProviderBuilder()
// add other instrumentations
.AddAWSLambdaConfigurations()
.AddAWSLambdaConfigurations(options => options.DisableAwsXRayContextExtraction = true)
Kielek marked this conversation as resolved.
Show resolved Hide resolved
.Build();
```

### AWSLambdaInstrumentationOptions

`AWSLambdaInstrumentationOptions` contains various properties to configure
AWS lambda instrumentation.
rypdal marked this conversation as resolved.
Show resolved Hide resolved

* [`DisableAwsXRayContextExtraction`](/src/OpenTelemetry.Instrumentation.AWSLambda/AWSLambdaInstrumentationOptions.cs)
* [`SetParentFromBatch`](/src/OpenTelemetry.Instrumentation.AWSLambda/AWSLambdaInstrumentationOptions.cs)

## Instrumentation

`AWSLambdaWrapper` class contains tracing methods covering different types of
rypdal marked this conversation as resolved.
Show resolved Hide resolved
function handler method signatures. `AWSLambdaWrapper.Trace()` and
`AWSLambdaWrapper.TraceAsync()` methods are used for wrapping synchronous
rypdal marked this conversation as resolved.
Show resolved Hide resolved
and asynchronous function handlers respectively. The `ActivityContext parentContext`
parameter is optional and used to pass a custom parent context. If the parent
is not passed explicitly then it's either extracted from the
input parameter or uses AWS X-Ray headers if AWS X-Ray context extraction is
enabled (see configuration property `DisableAwsXRayContextExtraction`).
The sequence of the parent extraction:
`explicit parent` -> `parent from input parameter` -> `AWS X-Ray headers` -> `default`
The parent extraction is supported for the input types listed in the table below.
Although the `SQSEvent` and `SNSEvent` consist of multiple
records (`SQSMessage` and `SNSRecord`) it's recommended to pass the full event.
rypdal marked this conversation as resolved.
Show resolved Hide resolved

| Package | Types |
rypdal marked this conversation as resolved.
Show resolved Hide resolved
|---------|-------|
| `Amazon.Lambda.APIGatewayEvents` | `APIGatewayProxyRequest, APIGatewayHttpApiV2ProxyRequest` |
| `Amazon.Lambda.SQSEvents` | `SQSEvent` |
| `Amazon.Lambda.SNSEvents` | `SNSEvent` |

### Lambda Function

1. Create a wrapper function with the same signature as the original Lambda function.
rypdal marked this conversation as resolved.
Show resolved Hide resolved
Call `AWSLambdaWrapper.Trace()` API and pass `TracerProvider`, original Lambda function
Call `AWSLambdaWrapper.Trace()` or `AWSLambdaWrapper.TraceAsync()` API and pass
`TracerProvider`, original Lambda function
and its inputs as parameters.
rypdal marked this conversation as resolved.
Show resolved Hide resolved

2. Set the wrapper function as the Lambda handler input.
Expand All @@ -48,14 +77,14 @@ public string OriginalFunctionHandler(JObject input, ILambdaContext context)

For using base classes from package [Amazon.Lambda.AspNetCoreServer](https://github.com/aws/aws-lambda-dotnet/tree/master/Libraries/src/Amazon.Lambda.AspNetCoreServer#amazonlambdaaspnetcoreserver),
override the `FunctionHandlerAsync` function in `LambdaEntryPoint.cs` file. Call
`AWSLambdaWrapper.Trace()` API and pass `TracerProvider`, original Lambda function
`AWSLambdaWrapper.TraceAsync()` API and pass `TracerProvider`, original Lambda function
and its inputs as parameters. Below is an example if using `APIGatewayProxyFunction`
as base class.

```csharp
public override async Task<APIGatewayProxyResponse> FunctionHandlerAsync(
APIGatewayProxyRequest request, ILambdaContext lambdaContext)
=> await AWSLambdaWrapper.Trace(tracerProvider, base.FunctionHandlerAsync,
=> await AWSLambdaWrapper.TraceAsync(tracerProvider, base.FunctionHandlerAsync,
request, lambdaContext);
```

Expand All @@ -75,7 +104,7 @@ public class Function
.AddHttpClientInstrumentation()
.AddAWSInstrumentation()
.AddOtlpExporter()
.AddAWSLambdaConfigurations()
.AddAWSLambdaConfigurations(options => options.DisableAwsXRayContextExtraction = true)
.Build();
}

Expand Down