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

feat: add aws Lambda instrumentation #721

Merged
merged 65 commits into from
May 10, 2024

Conversation

xuan-cao-swi
Copy link
Contributor

@xuan-cao-swi xuan-cao-swi commented Nov 15, 2023

This instrumentation allow user to use the handler to extract parent context from header that produce distributed tracing.

Inspired by splunk ruby lambda layer and opentelemetry python lambda layer.
Ruby layer creation can be found in opentelemetry-lambda PR

Sample wrapper should be added in layer creation (with lambda instrumentation).

# wrapper.rb
require 'opentelemetry/sdk'
require 'opentelemetry/exporter/otlp'
require 'opentelemetry/instrumentation/all'

OpenTelemetry::SDK.configure do |c|
  c.service_name = '<YOUR_SERVICE_NAME>'
  c.use_all() # enables all instrumentation!
end

def otel_wrapper(event:, context:)
  otel_wrapper = OpenTelemetry::Instrumentation::AwsLambda::Handler.new()
  otel_wrapper.call_wrapped(event: event, context: context)
end

To test with aws lambda, you can try to follow the steps here

@kaylareopelle
Copy link
Contributor

@xuan-cao-swi - Are there any tests I should run using both your opentelemetry-lambda PR and this one?

@xuan-cao-swi
Copy link
Contributor Author

@xuan-cao-swi - Are there any tests I should run using both your opentelemetry-lambda PR and this one?

I will create a detailed step to test lambda-related instrumentation.

@xuan-cao-swi
Copy link
Contributor Author

@kaylareopelle I have created a gist for the steps; but let me know if it's uncleared or failed.

@kaylareopelle
Copy link
Contributor

@xuan-cao-swi, thank you for the gist. It's very helpful! I've done a bit of testing, but wasn't able to successfully get the lambda to appear in New Relic. That might be an issue on our end. I'll also try to run some tests with an open-source endpoint. I plan to resume testing when I return to work on January 2, 2024.

@xuan-cao-swi xuan-cao-swi requested a review from a team January 5, 2024 05:44
Copy link
Contributor

@kaylareopelle kaylareopelle left a comment

Choose a reason for hiding this comment

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

This is looking great! I have a few, small documentation changes.

instrumentation/aws_lambda/README.md Outdated Show resolved Hide resolved
instrumentation/aws_lambda/README.md Outdated Show resolved Hide resolved
instrumentation/aws_lambda/README.md Show resolved Hide resolved
instrumentation/aws_lambda/README.md Show resolved Hide resolved
xuan-cao-swi and others added 5 commits May 2, 2024 12:07
Co-authored-by: Kayla Reopelle (she/her) <[email protected]>
…ws_lambda/handler.rb

Co-authored-by: Kayla Reopelle (she/her) <[email protected]>
…ws_lambda/handler.rb

Co-authored-by: Kayla Reopelle (she/her) <[email protected]>
Co-authored-by: Kayla Reopelle (she/her) <[email protected]>
Co-authored-by: Kayla Reopelle (she/her) <[email protected]>
Copy link
Contributor

@kaylareopelle kaylareopelle left a comment

Choose a reason for hiding this comment

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

Xuan, Amazing job with this. Thank you for your hard work! 🚀

Copy link
Contributor

@cheempz cheempz left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @xuan-cao-swi (and @kaylareopelle + @arielvalentin for the continued guidance!). Really looking forward to when we can get the metrics component into upstream for the full Lambda tracing experience.

@kaylareopelle
Copy link
Contributor

@xuan-cao-swi While reviewing #887, I noticed you made a few changes to release-please-related files. Do those changes need to be made for the lambda gem as well, or are releases different for this gem?

@xuan-cao-swi
Copy link
Contributor Author

@xuan-cao-swi While reviewing #887, I noticed you made a few changes to release-please-related files. Do those changes need to be made for the lambda gem as well, or are releases different for this gem?

Yes, that would be great if can release together. I have updated the release files.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This file was deleted on main. Please remove it from this branch.

@kaylareopelle
Copy link
Contributor

It looks like we're getting close, @xuan-cao-swi! Is there anything else you were hoping to accomplish before we sync with main and merge this in?

@xuan-cao-swi
Copy link
Contributor Author

It looks like we're getting close, @xuan-cao-swi! Is there anything else you were hoping to accomplish before we sync with main and merge this in?

Hi @kaylareopelle , no, I think it should be ok. I will open new PR if anything come up (esp. when incorporating with lambda layer build on lambda repo)

@kaylareopelle kaylareopelle merged commit 7905d11 into open-telemetry:main May 10, 2024
52 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants