yake 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/README.md +4 -2
- data/lib/yake/datadog/v1.rb +61 -0
- data/lib/yake/datadog/v2.rb +61 -0
- data/lib/yake/datadog.rb +1 -59
- data/lib/yake/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 27610c07a200a3f10913adf3a8ce42a892383de03663587f885770b903b48c03
|
4
|
+
data.tar.gz: 062e3bcfab24054137e70643435c39bfe9e61e37b6882a9fc720b0fb57ded05f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c9dbfc3ff7244e92d1a963054ef23007fe31cfabce8a00423d0d4d926fa130017b84e1737d8ba527cb274afce62a06cc59f129c97906bdabfd7c683b99ded112
|
7
|
+
data.tar.gz: 4d6e4458f0e305468499bef5e069dda1b6912969083c0d18469ffcd7e906c2f29536a670ddaf1bcd63e8734a56b72ec041abaa69898ab6963393128eee6254b7
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# λake
|
2
2
|
|
3
|
-
![gem](https://img.shields.io/gem/v/yake?color=crimson&logo=rubygems&logoColor=eee&style=flat-square)
|
3
|
+
[![gem](https://img.shields.io/gem/v/yake?color=crimson&logo=rubygems&logoColor=eee&style=flat-square)](https://rubygems.org/gems/yake)
|
4
4
|
[![rspec](https://img.shields.io/github/workflow/status/amancevice/yake/RSpec?logo=github&style=flat-square)](https://github.com/amancevice/yake/actions)
|
5
5
|
[![coverage](https://img.shields.io/codeclimate/coverage/amancevice/yake?logo=code-climate&style=flat-square)](https://codeclimate.com/github/amancevice/yake/test_coverage)
|
6
6
|
[![maintainability](https://img.shields.io/codeclimate/maintainability/amancevice/yake?logo=code-climate&style=flat-square)](https://codeclimate.com/github/amancevice/yake/maintainability)
|
@@ -331,6 +331,8 @@ UTC.now
|
|
331
331
|
|
332
332
|
As of `~> 0.4`, `yake` comes with a helper for writing Lambdas that integrate with Datadog's `datadog-ruby` gem.
|
333
333
|
|
334
|
+
As of `~> 0.8`, `yake` uses the v2 Datadog Lambda gem.
|
335
|
+
|
334
336
|
Creating a Lambda handler that wraps the Datadog tooling is easy:
|
335
337
|
|
336
338
|
```ruby
|
@@ -338,7 +340,7 @@ require 'aws-sdk-someservice'
|
|
338
340
|
require 'yake/datadog'
|
339
341
|
|
340
342
|
# Configure Datadog to use AWS tracing
|
341
|
-
Datadog::Lambda.configure_apm { |
|
343
|
+
Datadog::Lambda.configure_apm { |c| c.tracing.instrument :aws }
|
342
344
|
|
343
345
|
datadog :handler do |event|
|
344
346
|
# …
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'logger'
|
3
|
+
|
4
|
+
require 'datadog/lambda'
|
5
|
+
require 'yake'
|
6
|
+
|
7
|
+
module Yake
|
8
|
+
module Datadog
|
9
|
+
class Formatter < ::Logger::Formatter
|
10
|
+
Format = "[%s] %s %s %s %s\n"
|
11
|
+
|
12
|
+
def call(severity, time, progname, msg)
|
13
|
+
Format % [
|
14
|
+
severity,
|
15
|
+
time.utc.strftime('%Y-%m-%dT%H:%M:%S.%LZ'),
|
16
|
+
progname.nil? ? '-' : progname.split.last,
|
17
|
+
::Datadog.tracer.active_correlation,
|
18
|
+
msg2str(msg).strip,
|
19
|
+
]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class MockContext < Struct.new(
|
24
|
+
:clock_diff,
|
25
|
+
:deadline_ms,
|
26
|
+
:aws_request_id,
|
27
|
+
:invoked_function_arn,
|
28
|
+
:log_group_name,
|
29
|
+
:log_stream_name,
|
30
|
+
:function_name,
|
31
|
+
:memory_limit_in_mb,
|
32
|
+
:function_version)
|
33
|
+
|
34
|
+
def invoked_function_arn
|
35
|
+
@invoked_function_arn ||= begin
|
36
|
+
region = ENV['AWS_REGION'] || ENV['AWS_DEFAULT_REGION'] || 'us-east-1'
|
37
|
+
"arn:aws:lambda:#{region}:123456789012:function-name"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
module DSL
|
43
|
+
include Yake::DSL
|
44
|
+
|
45
|
+
##
|
46
|
+
# Datadog handler wrapper
|
47
|
+
def datadog(name, &block)
|
48
|
+
define_method(name) do |event:nil, context:nil|
|
49
|
+
context ||= MockContext.new
|
50
|
+
::Datadog::Lambda.wrap(event, context) do
|
51
|
+
Yake.wrap(event, context, &block)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
logger.formatter = Datadog::Formatter.new
|
59
|
+
end
|
60
|
+
|
61
|
+
extend Yake::Datadog::DSL
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'logger'
|
3
|
+
|
4
|
+
require 'datadog/lambda'
|
5
|
+
require 'yake'
|
6
|
+
|
7
|
+
module Yake
|
8
|
+
module Datadog
|
9
|
+
class Formatter < ::Logger::Formatter
|
10
|
+
Format = "[%s] %s %s %s %s\n"
|
11
|
+
|
12
|
+
def call(severity, time, progname, msg)
|
13
|
+
Format % [
|
14
|
+
severity,
|
15
|
+
time.utc.strftime('%Y-%m-%dT%H:%M:%S.%LZ'),
|
16
|
+
progname.nil? ? '-' : progname.split.last,
|
17
|
+
::Datadog::Tracing.log_correlation,
|
18
|
+
msg2str(msg).strip,
|
19
|
+
]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class MockContext < Struct.new(
|
24
|
+
:clock_diff,
|
25
|
+
:deadline_ms,
|
26
|
+
:aws_request_id,
|
27
|
+
:invoked_function_arn,
|
28
|
+
:log_group_name,
|
29
|
+
:log_stream_name,
|
30
|
+
:function_name,
|
31
|
+
:memory_limit_in_mb,
|
32
|
+
:function_version)
|
33
|
+
|
34
|
+
def invoked_function_arn
|
35
|
+
@invoked_function_arn ||= begin
|
36
|
+
region = ENV['AWS_REGION'] || ENV['AWS_DEFAULT_REGION'] || 'us-east-1'
|
37
|
+
"arn:aws:lambda:#{region}:123456789012:function-name"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
module DSL
|
43
|
+
include Yake::DSL
|
44
|
+
|
45
|
+
##
|
46
|
+
# Datadog handler wrapper
|
47
|
+
def datadog(name, &block)
|
48
|
+
define_method(name) do |event:nil, context:nil|
|
49
|
+
context ||= MockContext.new
|
50
|
+
::Datadog::Lambda.wrap(event, context) do
|
51
|
+
Yake.wrap(event, context, &block)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
logger.formatter = Datadog::Formatter.new
|
59
|
+
end
|
60
|
+
|
61
|
+
extend Yake::Datadog::DSL
|
data/lib/yake/datadog.rb
CHANGED
@@ -1,61 +1,3 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
require 'logger'
|
3
|
-
|
4
2
|
require 'datadog/lambda'
|
5
|
-
|
6
|
-
|
7
|
-
module Yake
|
8
|
-
module Datadog
|
9
|
-
class Formatter < ::Logger::Formatter
|
10
|
-
Format = "[%s] %s %s %s %s\n"
|
11
|
-
|
12
|
-
def call(severity, time, progname, msg)
|
13
|
-
Format % [
|
14
|
-
severity,
|
15
|
-
time.utc.strftime('%Y-%m-%dT%H:%M:%S.%LZ'),
|
16
|
-
progname.nil? ? '-' : progname.split.last,
|
17
|
-
::Datadog.tracer.active_correlation,
|
18
|
-
msg2str(msg).strip,
|
19
|
-
]
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
class MockContext < Struct.new(
|
24
|
-
:clock_diff,
|
25
|
-
:deadline_ms,
|
26
|
-
:aws_request_id,
|
27
|
-
:invoked_function_arn,
|
28
|
-
:log_group_name,
|
29
|
-
:log_stream_name,
|
30
|
-
:function_name,
|
31
|
-
:memory_limit_in_mb,
|
32
|
-
:function_version)
|
33
|
-
|
34
|
-
def invoked_function_arn
|
35
|
-
@invoked_function_arn ||= begin
|
36
|
-
region = ENV['AWS_REGION'] || ENV['AWS_DEFAULT_REGION'] || 'us-east-1'
|
37
|
-
"arn:aws:lambda:#{region}:123456789012:function-name"
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
module DSL
|
43
|
-
include Yake::DSL
|
44
|
-
|
45
|
-
##
|
46
|
-
# Datadog handler wrapper
|
47
|
-
def datadog(name, &block)
|
48
|
-
define_method(name) do |event:nil, context:nil|
|
49
|
-
context ||= MockContext.new
|
50
|
-
::Datadog::Lambda.wrap(event, context) do
|
51
|
-
Yake.wrap(event, context, &block)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
logger.formatter = Datadog::Formatter.new
|
59
|
-
end
|
60
|
-
|
61
|
-
extend Yake::Datadog::DSL
|
3
|
+
require_relative "datadog/v#{Datadog::Lambda::VERSION::MAJOR}"
|
data/lib/yake/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yake
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Mancevice
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-11-24 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -22,6 +22,8 @@ files:
|
|
22
22
|
- lib/yake.rb
|
23
23
|
- lib/yake/api.rb
|
24
24
|
- lib/yake/datadog.rb
|
25
|
+
- lib/yake/datadog/v1.rb
|
26
|
+
- lib/yake/datadog/v2.rb
|
25
27
|
- lib/yake/dsl.rb
|
26
28
|
- lib/yake/errors.rb
|
27
29
|
- lib/yake/logger.rb
|