datadog-lambda 0.7.0 → 0.8.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: 300ec79cee959b800acfbb7db97f2495cd73357dbbf2982e3fa471912c21c4eb
4
- data.tar.gz: 8854a16bbafcaba922d387f6923fde1340ba788284c72ec6affc1afa373a1184
3
+ metadata.gz: 88a466fc2c14e5abead82a19cf71b2f7b96005ce98570475ed894c8ab98504c9
4
+ data.tar.gz: 69d3a77bc438037552865f7c6649ee3130b32d4c179a2c73ac6a35abcd3b3981
5
5
  SHA512:
6
- metadata.gz: 02aa89e21441a5d66ac6af0568e1fb9e441f04d392744ee0848b2b229a9e47305ac08120b8f18b0b68889c99c4e618ecad812667ff34244185e4ebd1fadb9f03
7
- data.tar.gz: fc9da6f32e2a9802bee2cfe29953ace582fbeda26a94fde8e6a1064ee80021e78783562d21d66b29c040fe6540c02808bcecc1594af73e1537c66f9f6009c0d4
6
+ metadata.gz: 15677a13c06d71ecc401db19e5b36baca72c252ba078105bca108c1388d2ee4542c23588eade9447e7c2611d2f7a696318d41fc8f27d3ad28dbff6dccdbab356
7
+ data.tar.gz: f1735e753b714ff1d43d444bb0b623c93b3714e54f54509f7ddb31e36eee3f6748938f56455b6c73f824bf4f27f6e03fbb675655131a3d066f9f9c3eea0f5289
@@ -7,6 +7,7 @@
7
7
  # This product includes software developed at Datadog (https://www.datadoghq.com/).
8
8
  # Copyright 2019 Datadog, Inc.
9
9
  #
10
+ # rubocop:disable Metrics/ModuleLength
10
11
 
11
12
  require 'datadog/lambda/trace/listener'
12
13
  require 'datadog/lambda/utils/logger'
@@ -93,22 +94,42 @@ module Datadog
93
94
  # Generate tags for enhanced metrics
94
95
  # @param context [Object] https://docs.aws.amazon.com/lambda/latest/dg/ruby-context.html
95
96
  # @return [hash] a hash of the enhanced metrics tags
97
+ # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
96
98
  def self.gen_enhanced_tags(context)
97
99
  arn_parts = context.invoked_function_arn.split(':')
98
- {
100
+ # Check if we have an alias or version
101
+ function_alias = arn_parts[7].nil? ? nil : arn_parts[7]
102
+
103
+ tags = {
99
104
  functionname: context.function_name,
100
105
  region: arn_parts[3],
101
106
  account_id: arn_parts[4],
102
107
  memorysize: context.memory_limit_in_mb,
103
108
  cold_start: @is_cold_start,
104
- runtime: "Ruby #{RUBY_VERSION}"
109
+ runtime: "Ruby #{RUBY_VERSION}",
110
+ resource: context.function_name
105
111
  }
112
+ # If we have an alias...
113
+ unless function_alias.nil?
114
+ # If the alis version is $Latest, drop the $ for ddog tag convention.
115
+ if function_alias.start_with?('$')
116
+ function_alias[0] = ''
117
+ # If the alias is not a version number add the executed version tag
118
+ elsif !/\A\d+\z/.match(function_alias)
119
+ tags[:executedversion] = context.function_version
120
+ end
121
+ # Append the alias to the resource tag
122
+ tags[:resource] = context.function_name + ':' + function_alias
123
+ end
124
+
125
+ tags
106
126
  rescue StandardError => e
107
127
  Datadog::Utils.logger.error 'Unable to parse Lambda context' \
108
128
  "#{context}: #{e}"
109
129
  {}
110
130
  end
111
131
 
132
+ # rubocop:enable Metrics/AbcSize, Metrics/MethodLength
112
133
  # Format and add tags to enhanced metrics
113
134
  # This method wraps the metric method, checking the DD_ENHANCED_METRICS
114
135
  # environment variable, adding 'aws.lambda.enhanced' to the metric name,
@@ -116,7 +137,7 @@ module Datadog
116
137
  # @param metric_name [String] basic name of the metric
117
138
  # @param context [Object] AWS Ruby Lambda Context
118
139
  # @return [boolean] false if the metric was not added for some reason,
119
- # true otherwise (for ease of testing)
140
+ # true otherwise (for ease of testing
120
141
 
121
142
  def self.record_enhanced(metric_name, context)
122
143
  return false unless do_enhanced_metrics?
@@ -153,3 +174,4 @@ module Datadog
153
174
  end
154
175
  end
155
176
  end
177
+ # rubocop:enable Metrics/ModuleLength
@@ -12,7 +12,7 @@ module Datadog
12
12
  module Lambda
13
13
  module VERSION
14
14
  MAJOR = 0
15
- MINOR = 7
15
+ MINOR = 8
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: 0.7.0
4
+ version: 0.8.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: 2020-04-02 00:00:00.000000000 Z
11
+ date: 2020-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-xray-sdk
@@ -113,7 +113,7 @@ files:
113
113
  - lib/datadog/lambda/trace/xray.rb
114
114
  - lib/datadog/lambda/utils/logger.rb
115
115
  - lib/datadog/lambda/version.rb
116
- homepage: https://github.com/DataDog/dd-lambda-rb
116
+ homepage: https://github.com/DataDog/datadog-lambda-layer-rb
117
117
  licenses:
118
118
  - Apache-2.0
119
119
  metadata: