datadog-lambda 2.21.0 → 2.22.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6c867a4e0858e0ba773829993e4c60b2d84b26f8afe4e69a766ac75f6ef454c5
4
- data.tar.gz: feaa85e2d5d998b32602b74958792a656f692eab4950fdc7da0cccb7d12542bd
3
+ metadata.gz: 1ff16978e295234189602cab59d2c4f2adbff91edc9bcb9a52bbde91fb744369
4
+ data.tar.gz: 4e89c094a7c0fb2e6161f7179266831df23dd4f665ccaafcc9b1d233fcce0860
5
5
  SHA512:
6
- metadata.gz: cd5062d00ae5f88a8c5021f6c76c3b87fa9236d035508e04dbd33113cf51a5b7bec006060ab6dc12ea27da46feaf78ae3eb98d9bd4c907b5a972c7176ca40ee7
7
- data.tar.gz: 823cc2efc44cfefd3e0829ca038e966f6b999fd5c2648131a91a2b8b805dbd8ae5aeb5cdba1c14d3c8579aafffb719679b8e1bdd60306f37c80c3bc176f154d2
6
+ metadata.gz: 3738d873ac92162f632b6457ad1d188397eec4a3a59d9a523fcdf9b2f53eadd559f92f388f8d5d4a96da6cc38024124efb828b714c0cd44ed050a347eb246150
7
+ data.tar.gz: 37cfd0a36ae52012ebdc14cab31b1d22b20e968413ef136010fa21f0ee6be2b965257b2066d5d93ed7c3eabdf9989a2a40c84e5341f48aa1bb1ae0e0cffb29d9
@@ -17,6 +17,7 @@ module Datadog
17
17
  DD_TRACE_ID_HEADER = 'x-datadog-trace-id'
18
18
  DD_PARENT_ID_HEADER = 'x-datadog-parent-id'
19
19
  DD_SAMPLING_PRIORITY_HEADER = 'x-datadog-sampling-priority'
20
+ DD_ORIGIN = 'x-datadog-origin'
20
21
  DD_XRAY_SUBSEGMENT_NAME = 'datadog-metadata'
21
22
  DD_XRAY_SUBSEGMENT_KEY = 'trace'
22
23
  DD_XRAY_SUBSEGMENT_NAMESPACE = 'datadog'
@@ -42,8 +42,13 @@ module Datadog
42
42
  options[:service] = 'aws.lambda'
43
43
  options[:span_type] = 'serverless'
44
44
  Datadog::Trace.apply_datadog_trace_context(Datadog::Trace.trace_context)
45
+
46
+ trace_digest = Datadog::Utils.send_start_invocation_request(event: event)
47
+ # Only continue trace from a new one if it exist, or else,
48
+ # it will create a new trace, which is not ideal here.
49
+ options[:continue_from] = trace_digest if trace_digest
50
+
45
51
  @trace = Datadog::Tracing.trace('aws.lambda', **options)
46
- Datadog::Utils.send_start_invocation_request(event: event)
47
52
  end
48
53
  # rubocop:enable Metrics/AbcSize
49
54
 
@@ -8,6 +8,7 @@
8
8
  # Copyright 2023 Datadog, Inc.
9
9
  #
10
10
  require 'net/http'
11
+ require 'datadog/tracing/contrib/http/distributed/fetcher'
11
12
 
12
13
  module Datadog
13
14
  # Utils contains utility functions shared between modules
@@ -21,6 +22,11 @@ module Datadog
21
22
  START_INVOCATION_URI = URI(EXTENSION_BASE_URL + START_INVOCATION_PATH).freeze
22
23
  END_INVOCATION_URI = URI(EXTENSION_BASE_URL + END_INVOCATION_PATH).freeze
23
24
 
25
+ # Internal communications use Datadog tracing headers
26
+ PROPAGATOR = Tracing::Distributed::Datadog.new(
27
+ fetcher: Tracing::Contrib::HTTP::Distributed::Fetcher
28
+ )
29
+
24
30
  def self.extension_running?
25
31
  return @is_extension_running unless @is_extension_running.nil?
26
32
 
@@ -35,11 +41,10 @@ module Datadog
35
41
  return unless extension_running?
36
42
 
37
43
  response = Net::HTTP.post(START_INVOCATION_URI, event.to_json, request_headers)
44
+ # Add origin, since tracer expects it for extraction
45
+ response[Datadog::Trace::DD_ORIGIN] = 'lambda'
38
46
 
39
- trace_digest = Tracing::Propagation::HTTP.extract(response)
40
- # Only continue trace from a new one if it exist, or else,
41
- # it will create a new trace, which is not ideal here.
42
- Tracing.continue_trace!(trace_digest) if trace_digest
47
+ PROPAGATOR.extract(response)
43
48
  rescue StandardError => e
44
49
  Datadog::Utils.logger.debug "failed on start invocation request to extension: #{e}"
45
50
  end
@@ -51,8 +56,9 @@ module Datadog
51
56
  request.body = response.to_json
52
57
  request[Datadog::Core::Transport::Ext::HTTP::HEADER_DD_INTERNAL_UNTRACED_REQUEST] = 1
53
58
 
54
- trace = Datadog::Tracing.active_trace
55
- Tracing::Propagation::HTTP.inject!(trace, request)
59
+ trace_digest = Datadog::Tracing.active_trace&.to_digest
60
+
61
+ PROPAGATOR.inject!(trace_digest, request)
56
62
  Net::HTTP.start(END_INVOCATION_URI.host, END_INVOCATION_URI.port) do |http|
57
63
  http.request(request)
58
64
  end
@@ -12,7 +12,7 @@ module Datadog
12
12
  module Lambda
13
13
  module VERSION
14
14
  MAJOR = 2
15
- MINOR = 21
15
+ MINOR = 22
16
16
  PATCH = 0
17
17
  PRE = nil
18
18
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: datadog-lambda
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.21.0
4
+ version: 2.22.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Datadog, Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-10-16 00:00:00.000000000 Z
11
+ date: 2023-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-xray-sdk
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 1.15.0
47
+ version: 1.17.0
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 1.15.0
54
+ version: 1.17.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement