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 +4 -4
- data/lib/datadog/lambda.rb +25 -3
- data/lib/datadog/lambda/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88a466fc2c14e5abead82a19cf71b2f7b96005ce98570475ed894c8ab98504c9
|
4
|
+
data.tar.gz: 69d3a77bc438037552865f7c6649ee3130b32d4c179a2c73ac6a35abcd3b3981
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15677a13c06d71ecc401db19e5b36baca72c252ba078105bca108c1388d2ee4542c23588eade9447e7c2611d2f7a696318d41fc8f27d3ad28dbff6dccdbab356
|
7
|
+
data.tar.gz: f1735e753b714ff1d43d444bb0b623c93b3714e54f54509f7ddb31e36eee3f6748938f56455b6c73f824bf4f27f6e03fbb675655131a3d066f9f9c3eea0f5289
|
data/lib/datadog/lambda.rb
CHANGED
@@ -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
|
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.
|
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-
|
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/
|
116
|
+
homepage: https://github.com/DataDog/datadog-lambda-layer-rb
|
117
117
|
licenses:
|
118
118
|
- Apache-2.0
|
119
119
|
metadata:
|