forked from aws/aws-xray-sdk-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lambda.rb
35 lines (29 loc) · 1.03 KB
/
lambda.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# AWS Lambda functions should require this file to configure the XRay.recorder
# for use within the function.
require_relative 'lambda/lambda_recorder'
require_relative 'lambda/facade_segment'
require_relative 'lambda/lambda_context'
require_relative 'lambda/lambda_streamer'
module XRay
@recorder = LambdaRecorder.new
# provide an instance of LambdaRecorder as the global XRay.recorder
def self.recorder
@recorder
end
end
# Set `XRAY_LAMBDA_PATCH_CONFIG` before requiring `aws-xray-sdk/lambda`
# to configure which libraries (if any) to instrument.
#
# By default, both `net_http` and `aws_sdk` will be instrumented
unless defined? XRAY_LAMBDA_PATCH_CONFIG
XRAY_LAMBDA_PATCH_CONFIG = %I[net_http aws_sdk]
end
# Configure the XRay.recorder with Lambda specific config.
#
# From here, a lambda may create subsegments manually, or via
# the instrumented libraries setup by XRAY_LAMBDA_PATCH_CONFIG
XRay.recorder.configure(
patch: XRAY_LAMBDA_PATCH_CONFIG,
context: XRay::LambdaContext.new,
streamer: XRay::LambdaStreamer.new
)