datadog-json_logger 0.3.0 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9df47f5fde7ef4639bbba0854c2d9fa90db7f580d489bfc04051c79c191c7d8f
4
- data.tar.gz: 8f88db7cf3f19787fabb34d4fa95d787689223e8e933a9e38f3f448b2501322b
3
+ metadata.gz: c4761325e6c6e8b1ef89a84eb3996f1efeff464d1905c1b02b60e753f74db6a9
4
+ data.tar.gz: fb35271ac279af034ba6954470a56c385a2485605cf327b747dc9d02db1ebde9
5
5
  SHA512:
6
- metadata.gz: 24e9e6f6a59711c62bcc386be834a0b2e98bdc70e53084c7da73a6b04a26f25b091afae4a61b8049b6e24b5bc94901997b3383b8fa1d485033f09919140b5ac9
7
- data.tar.gz: 8ad6344f4e503a946f6653a30840b9dca8afc70e161b5369a582dbcd2105b276f3545c66d396fb60ac6d25725745a6322c607336931a542f34915a3234652889
6
+ metadata.gz: 60a1f036af46a40eddf436678882c8feab759cdef7e09a70914dfbc87bb64c935c7602d38b1ddf6d71b01a429637379e4f05d1d0d6bc19ad1a5700c44434575f
7
+ data.tar.gz: 870db4cf8af593d9f1a60e74a23d0255bb26e2ade670790871a89c8edce48149279dbba24870bc32f7bb9024a1c6b6b00196f791e5021b775fd937f87956ca2c
data/.rubocop.yml CHANGED
@@ -1,3 +1,7 @@
1
+ plugins:
2
+ - rubocop-rake
3
+ - rubocop-rspec
4
+
1
5
  AllCops:
2
6
  Exclude:
3
7
  - 'sig/**/*'
@@ -5,7 +9,7 @@ AllCops:
5
9
  - 'lib/datadog/tracing/contrib/bunny/patcher.rb'
6
10
  - 'vendor/**/*'
7
11
  NewCops: enable
8
- TargetRubyVersion: 3.0
12
+ TargetRubyVersion: 3.4
9
13
 
10
14
  Style/StringLiterals:
11
15
  Enabled: true
@@ -33,4 +37,22 @@ Metrics/BlockLength:
33
37
  - 'spec/**/*'
34
38
 
35
39
  Metrics/ParameterLists:
36
- Max: 6
40
+ Max: 6
41
+
42
+ RSpec/MultipleMemoizedHelpers:
43
+ Max: 10
44
+
45
+ RSpec/MultipleExpectations:
46
+ Max: 5
47
+
48
+ RSpec/NestedGroups:
49
+ Max: 4
50
+
51
+ RSpec/ExampleLength:
52
+ Max: 15
53
+
54
+ RSpec/MessageChain:
55
+ Enabled: false
56
+
57
+ RSpec/VerifiedDoubles:
58
+ Enabled: false
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.4.1
1
+ 3.4.7
data/.tool-versions ADDED
@@ -0,0 +1 @@
1
+ ruby 3.4.7
data/README.md CHANGED
@@ -21,7 +21,7 @@
21
21
  ## Requirements
22
22
 
23
23
  - Ruby 3.0+
24
- - [ddtrace](https://github.com/DataDog/dd-trace-rb) properly configured in your application
24
+ - [datadog](https://github.com/DataDog/dd-trace-rb) properly configured in your application
25
25
 
26
26
  ## Installation
27
27
 
@@ -62,12 +62,12 @@ logger.info('Hello World')
62
62
  Datadog::JSONLogger.configure do |config|
63
63
  # Function to extract current user from environment
64
64
  config.current_user = ->(env) { { email: env['current_user']&.email } }
65
-
65
+
66
66
  # Custom environment keys
67
67
  config.controller_key = "sinatra.controller_name"
68
68
  config.resource_key = "sinatra.resource_name"
69
69
  config.action_key = "sinatra.action_name"
70
-
70
+
71
71
  # Custom context for all logs
72
72
  config.custom_context = -> { { environment: ENV['RACK_ENV'] } }
73
73
  end
@@ -81,7 +81,7 @@ In your `config/initializers/datadog.rb`:
81
81
  require 'datadog/json_logger'
82
82
 
83
83
  Datadog::JSONLogger.configure do |config|
84
- config.current_user = ->(env) { { email: env['warden']&.user&.email } }
84
+ config.current_user = ->(env) { { email: env['warden']&.user&.email } }
85
85
  config.controller_key = "action_controller.instance"
86
86
  config.action_key = "action_dispatch.request.path_parameters[:action]"
87
87
  config.resource_key = "action_dispatch.request.path_parameters[:controller]"
@@ -103,14 +103,14 @@ class MyApp < Sinatra::Base
103
103
  Datadog::JSONLogger.configure do |config|
104
104
  config.current_user = ->(env) { { email: env['warden']&.user&.email } }
105
105
  end
106
-
106
+
107
107
  # Set up logger
108
108
  set :logger, Datadog::JSONLogger.new
109
-
109
+
110
110
  # Add Rack middleware
111
111
  use Datadog::RackMiddleware, settings.logger
112
112
  end
113
-
113
+
114
114
  # Your routes here
115
115
  end
116
116
  ```
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Datadog
4
4
  module Loggers
5
- VERSION = "0.3.0"
5
+ VERSION = "0.3.3"
6
6
  end
7
7
  end
@@ -12,7 +12,7 @@ module Rack
12
12
  end
13
13
  end
14
14
 
15
- module Datadog
15
+ module Datadog # rubocop:disable Style/OneClassPerFile
16
16
  class RackMiddleware
17
17
  attr_reader :app, :logger
18
18
 
@@ -45,7 +45,7 @@ module Datadog
45
45
  def safely_process_request(env)
46
46
  app.call(env)
47
47
  rescue StandardError => e
48
- [500, { "Content-Type": "application/json" }, [e.class.name, e.message].join(": ")]
48
+ [500, { "Content-Type": "application/json" }, ["#{e.class.name}: #{e.message}"]]
49
49
  end
50
50
 
51
51
  def log_request(request, env, status, headers, start_time, end_time)
@@ -18,11 +18,23 @@ module Datadog
18
18
  return
19
19
  end
20
20
 
21
+ # A producer on a newer datadog gem may serialize digest fields this
22
+ # consumer's TraceDigest does not know yet; drop them instead of raising.
23
+ serializes_trace_digest = serializes_trace_digest.slice(*supported_trace_digest_keys)
24
+
21
25
  trace_digest = Datadog::Tracing::TraceDigest.new(**serializes_trace_digest)
22
26
  return unless trace_digest
23
27
 
24
28
  Datadog::Tracing.continue_trace!(trace_digest)
25
29
  end
30
+
31
+ # @return [Array<Symbol>]
32
+ def supported_trace_digest_keys
33
+ @supported_trace_digest_keys ||=
34
+ Datadog::Tracing::TraceDigest.instance_method(:initialize).parameters.filter_map do |type, name|
35
+ name if %i[key keyreq].include?(type)
36
+ end
37
+ end
26
38
  end
27
39
  end
28
40
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: datadog-json_logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eth3rnit3
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2025-03-26 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: datadog
@@ -36,13 +35,12 @@ files:
36
35
  - ".rubocop.yml"
37
36
  - ".ruby-version"
38
37
  - ".rubycritic.yml"
38
+ - ".tool-versions"
39
39
  - CHANGELOG.md
40
40
  - CODE_OF_CONDUCT.md
41
- - Dockerfile.nexus
42
41
  - LICENSE.txt
43
42
  - README.md
44
43
  - Rakefile
45
- - Steepfile
46
44
  - datadog-json_logger.gemspec
47
45
  - lib/datadog/configuration.rb
48
46
  - lib/datadog/json_logger.rb
@@ -54,7 +52,6 @@ files:
54
52
  - lib/datadog/tracing/contrib/bunny/integration.rb
55
53
  - lib/datadog/tracing/contrib/bunny/patcher.rb
56
54
  - lib/datadog/tracing/contrib/bunny/utils.rb
57
- - nexus_release.sh
58
55
  - sig/.keep
59
56
  homepage: https://github.com/buyco/datadog-json-logger
60
57
  licenses:
@@ -65,7 +62,6 @@ metadata:
65
62
  source_code_uri: https://github.com/buyco/datadog-json-logger
66
63
  changelog_uri: https://github.com/buyco/datadog-json-logger/blob/main/CHANGELOG.md
67
64
  rubygems_mfa_required: 'true'
68
- post_install_message:
69
65
  rdoc_options: []
70
66
  require_paths:
71
67
  - lib
@@ -80,8 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
80
76
  - !ruby/object:Gem::Version
81
77
  version: '0'
82
78
  requirements: []
83
- rubygems_version: 3.4.10
84
- signing_key:
79
+ rubygems_version: 3.6.9
85
80
  specification_version: 4
86
81
  summary: Connect your ruby application to Datadog logging and tracing.
87
82
  test_files: []
data/Dockerfile.nexus DELETED
@@ -1,12 +0,0 @@
1
- FROM ruby:3.0.1-alpine
2
-
3
- RUN apk add --no-cache build-base git
4
-
5
- COPY . /gem
6
- WORKDIR /gem
7
-
8
- RUN chmod +x nexus_release.sh
9
-
10
- RUN gem install nexus
11
-
12
- CMD ["/bin/sh", "/gem/nexus_release.sh"]
data/Steepfile DELETED
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # D = Steep::Diagnostic
4
- #
5
- target :lib do
6
- signature "sig"
7
-
8
- check "lib" # Directory name
9
- # ignore "lib/templates/*.rb"
10
-
11
- # library "pathname" # Standard libraries
12
- # library "strong_json" # Gems
13
- library "logger"
14
- library "uri"
15
- library "json"
16
-
17
- # configure_code_diagnostics(D::Ruby.default) # `default` diagnostics setting (applies by default)
18
- # configure_code_diagnostics(D::Ruby.strict) # `strict` diagnostics setting
19
- # configure_code_diagnostics(D::Ruby.lenient) # `lenient` diagnostics setting
20
- # configure_code_diagnostics(D::Ruby.silent) # `silent` diagnostics setting
21
- # configure_code_diagnostics do |hash| # You can setup everything yourself
22
- # hash[D::Ruby::NoMethod] = :information
23
- # end
24
- end
25
-
26
- # target :test do
27
- # signature "sig", "sig-private"
28
- #
29
- # check "test"
30
- #
31
- # # library "pathname" # Standard libraries
32
- # end
data/nexus_release.sh DELETED
@@ -1,10 +0,0 @@
1
- #! /bin/sh
2
-
3
- gem_file=$(ls -1 | grep '\.gem$' | head -n 1)
4
-
5
- if [ -z "$gem_file" ]; then
6
- echo "Error : no .gem file was found"
7
- exit 1
8
- fi
9
-
10
- gem nexus --url $NEXUS_DEPLOY_URL --credential $NEXUS_CREDENTIALS $gem_file