event_tracer 0.4.0 → 0.4.1

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: 5f5987bb0a399ec5960ef763bfcd0dbfa5ccd6057706deb1a1916daa126208be
4
- data.tar.gz: 4ccd9d11711d43ff6bb9facc9bed872f2023d09f1c1669469eb1583bce46783b
3
+ metadata.gz: 335d4c810b2a3e378d826518f8e8c6c2a8a1310f029401381ac2f407437554ca
4
+ data.tar.gz: 95971a338ad15cb6f5f74bb78f10f59dfba0918c7578a3e1057f8d11e5dc7bbb
5
5
  SHA512:
6
- metadata.gz: 0d741c12baacd00c430f8d312d364161ba5959ccbcbfc79093ca520908b1d0c1537d9c50d918b3cb1df3610e5384f2fe36416342b9154fcec7e0d3d07b4d5d9f
7
- data.tar.gz: 5bfd26725b5048a49a94746015127385cf03ada9fa9cede00d8a329780d3524442d40e4157a75c66c820e4076baa1d531381e7fd92374dcf98d0880c419be935
6
+ metadata.gz: 473b42b4728e7233bdddaa4d85c681b33b41c71c26eb78ee9578c332f878e78234e6007b37c6c120e0adf13eaa8dd87e18f09d2069cfe7ca578e2ef8f1fc6079
7
+ data.tar.gz: 5a58acc598909419d8164a4cfb46c2c9695b12faee98bdf2ae937648dc964c4c70e04c78e8a2395ed133a245ca86d4ac7d471972a7e72510267d2bcb754b1e56
@@ -5,6 +5,9 @@ module EventTracer
5
5
  extend Dry::Configurable
6
6
 
7
7
  setting :app_name, default: 'app_name'
8
+
9
+ # TODO: switch to namespace in v1.0
8
10
  setting :dynamo_db_table_name, default: 'logs'
11
+ setting :dynamo_db_client
9
12
  end
10
13
  end
@@ -1,8 +1,13 @@
1
1
  module EventTracer
2
2
  module DynamoDB
3
3
  class Client
4
- def self.call
5
- Aws::DynamoDB::Client.new
4
+ class << self
5
+ extend Gem::Deprecate
6
+
7
+ def call
8
+ Aws::DynamoDB::Client.new
9
+ end
10
+ deprecate :call, 'EventTracer::Config.config.dynamo_db_client', 2021, 12
6
11
  end
7
12
  end
8
13
  end
@@ -20,14 +20,19 @@ module EventTracer
20
20
  # See https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/DynamoDB/Client.html#batch_write_item-instance_method
21
21
  MAX_DYNAMO_DB_ITEM_PER_REQUEST = 25
22
22
 
23
+ def initialize(client = nil)
24
+ @config = EventTracer::Config.config
25
+ @client = client || @config.dynamo_db_client || Client.call
26
+ end
27
+
23
28
  def perform(items)
24
29
  wrap(items).each_slice(MAX_DYNAMO_DB_ITEM_PER_REQUEST) do |batch|
25
30
  data = batch.map do |item|
26
31
  { put_request: { item: clean_empty_values(item) } }
27
32
  end
28
33
 
29
- Client.call.batch_write_item(
30
- request_items: { EventTracer::Config.config.dynamo_db_table_name => data }
34
+ client.batch_write_item(
35
+ request_items: { config.dynamo_db_table_name => data }
31
36
  )
32
37
 
33
38
  rescue Aws::DynamoDB::Errors::ServiceError => e
@@ -43,6 +48,8 @@ module EventTracer
43
48
 
44
49
  private
45
50
 
51
+ attr_reader :client, :config
52
+
46
53
  def wrap(items)
47
54
  # NOTE: This allows us to handle either buffered or unbuffered payloads
48
55
  if items.is_a?(Hash)
@@ -1,3 +1,3 @@
1
1
  module EventTracer
2
- VERSION = '0.4.0'.freeze
2
+ VERSION = '0.4.1'.freeze
3
3
  end
data/lib/event_tracer.rb CHANGED
@@ -3,7 +3,7 @@ require 'event_tracer/log_result'
3
3
 
4
4
  module EventTracer
5
5
 
6
- LOG_TYPES ||= %i(info warn error)
6
+ LOG_TYPES = %i(info warn error)
7
7
 
8
8
  @loggers = {}
9
9
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: event_tracer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - melvrickgoh
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-10-15 00:00:00.000000000 Z
11
+ date: 2021-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby