Skip to content

Conversation

@AzharH
Copy link

@AzharH AzharH commented Nov 7, 2025

Implement AWS Lambda detector
Discussion issue

Changes

Exposed the AWSLambdaResourceDetector.Detect over the ResourceBuilder to allow enriching logs/traces/metrics with AWS Lambda specific attributes

Merge requirement checklist

  • CONTRIBUTING guidelines followed (license requirements, nullable enabled, static analysis, etc.)
  • Unit tests added/updated
  • Appropriate CHANGELOG.md files updated for non-trivial changes
  • Changes in public API reviewed (if applicable)

@AzharH AzharH requested a review from a team as a code owner November 7, 2025 01:24
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Nov 7, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

@github-actions github-actions bot added the comp:instrumentation.awslambda Things related to OpenTelemetry.Instrumentation.AWSLambda label Nov 7, 2025
@AzharH AzharH force-pushed the feature/implement-aws-lambda-detector branch from d2715a0 to 9954d3c Compare November 7, 2025 01:53
Signed-off-by: AzharH <azhar.hosenbocus@outlook.com>
@AzharH AzharH force-pushed the feature/implement-aws-lambda-detector branch from 9954d3c to a00874c Compare November 7, 2025 02:03
# Conflicts:
#	src/OpenTelemetry.Instrumentation.AWSLambda/CHANGELOG.md
@azhar-hosenbocus-cko
Copy link

hey @martincostello
any chance I can get a review on the PR please? 🤞

@Kielek
Copy link
Member

Kielek commented Nov 21, 2025

@normj, @lukeina2z, @Oberon00, @rypdal?

/// <param name="builder">The <see cref="ResourceBuilder"/> being configured.</param>
/// <param name="configure">Optional callback action for configuring <see cref="AWSLambdaInstrumentationOptions"/>.</param>
/// <returns>The instance of <see cref="ResourceBuilder"/> being configured.</returns>
public static ResourceBuilder AddAWSLambdaDetector(this ResourceBuilder builder, Action<AWSLambdaInstrumentationOptions>? configure = null)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if this is called when also adding the resource detector implicitly via the instrumentation (

builder.ConfigureResource(x => x.AddDetector(new AWSLambdaResourceDetector(awsSemanticConventions)));
)? Couldn't this easily lead to double-detection of resources? I think it may be easy to misuse this method, if they are going to be in the same package, maybe it's better to enhance the instrumentation method with a parameter/add an option inside AWSLambdaInstrumentationOptions to add only resource detection without instrumentation? That would make it hard to accidentally add it twice.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its a valid point.
However just enhancing TracerProviderBuilderExtensions.AddAWSLambdaConfigurations to add only resource detection will not work in that case because the extension is exposed on TracerProviderBuilder. Resource detectors should be allowed to be added for logs and metrics too (similar to the other resource detectors) and be exposed on ResourceBuilder instead.

I enhanced the XML docs to make it easier to understand how the 2 extensions are expected to be used, should make it clearer to avoid double resource detection.
Let me know what you think.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 1, 2025

This PR was marked stale due to lack of activity. It will be closed in 7 days.

@github-actions github-actions bot added the Stale label Dec 1, 2025
@AzharH
Copy link
Author

AzharH commented Dec 1, 2025

@normj, @lukeina2z , @Oberon00, @rypdal
The PR has been opened for a while, any chance we get this approved and merged soon?

/// <param name="builder">The <see cref="ResourceBuilder"/> being configured.</param>
/// <param name="configure">Optional callback action for configuring <see cref="AWSLambdaInstrumentationOptions"/>.</param>
/// <returns>The instance of <see cref="ResourceBuilder"/> being configured.</returns>
public static ResourceBuilder AddAWSLambdaDetector(this ResourceBuilder builder, Action<AWSLambdaInstrumentationOptions>? configure = null)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to accept AWSLambdaInstrumentationOptions here? The detector is not an instrumentation, and indeed it seems like all options except SemanticConventionVersion are ignored.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was mostly trying to keep it close to the other detectors extensions. but its a valid point - removed the AWSLambdaInstrumentationOptions to use the default semantic convention version

Would appreciate another review please

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Oberon00 🙏

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not accept (just) the semantic convention version as parameter?

@github-actions github-actions bot removed the Stale label Dec 2, 2025
Copy link
Member

@Oberon00 Oberon00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems OK to me and I definitely see the use case, but I can't really review conformance to usual OTel best practices, would appreciate it if someone else could also take a look at the API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp:instrumentation.awslambda Things related to OpenTelemetry.Instrumentation.AWSLambda

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants