datadog-json_logger 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -0
- data/.rubycritic.yml +4 -0
- data/README.md +9 -0
- data/Steepfile +32 -0
- data/datadog-json_logger.gemspec +8 -7
- data/lib/datadog/json_logger.rb +10 -4
- data/lib/datadog/loggers/json_formatter.rb +25 -14
- data/lib/datadog/loggers/version.rb +1 -1
- data/lib/datadog/sinatra_middleware.rb +3 -3
- data/sig/datadog/json_logger.rbs +11 -3
- data/sig/datadog/loggers/json_formatter.rbs +29 -0
- data/sig/datadog/loggers/version.rbs +5 -0
- data/sig/datadog/sinatra_middleware.rbs +33 -0
- data/sig/datadog/tracing.rbs +90 -0
- data/sig/rack/request.rbs +362 -0
- metadata +12 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: beb6fb82518d662d8db07b415cc953e99fc67348208aa5f34a1b02111ce487a8
|
4
|
+
data.tar.gz: d555d69fe127aaedd4505b69e0d790cc03d43eb23a711895cc46fc35cd10d19c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6710e8f18de45387168fafc58bfb54d84731af279707a9c1788c60f569b846dd581d080d8f7e8ebb8e70e24f2d66ff88829ca5e9d1e51cfb2f7c6550ba36abc8
|
7
|
+
data.tar.gz: a707d9786bf1fb06ce3607b134fd6feb892d60287f94eb7e87888d76ffcb56872d8faa513f8c81cf43db18d9de65770f66814f5147884deb2efa56e29f7c04a0
|
data/.rubocop.yml
CHANGED
data/.rubycritic.yml
ADDED
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# Datadog::JSONLogger
|
2
2
|
|
3
3
|
[![Rubocop and Rspec](https://github.com/Eth3rnit3/datadog-json_logger/actions/workflows/main.yml/badge.svg?branch=main)](https://github.com/Eth3rnit3/datadog-json_logger/actions/workflows/main.yml)
|
4
|
+
[![Nexus upload](https://github.com/buyco/datadog-json-logger/actions/workflows/nexus.yml/badge.svg)](https://github.com/buyco/datadog-json-logger/actions/workflows/nexus.yml)
|
4
5
|
|
5
6
|
`Datadog::JSONLogger` is a Ruby gem designed to seamlessly integrate Ruby applications with Datadog's logging and tracing services. This gem allows your Ruby application to format its output as JSON, including necessary correlation IDs and other details for optimal Datadog functionality.
|
6
7
|
|
@@ -85,6 +86,14 @@ require 'datadog/sinatra_middleware'
|
|
85
86
|
use Datadog::SinatraMiddleware, logger
|
86
87
|
```
|
87
88
|
|
89
|
+
## Features
|
90
|
+
| Feature | Link | Compatibility |
|
91
|
+
|-------------------------|-------------------------------------------------|---------------|
|
92
|
+
| JSON correlated logging | [Ruby Collection](https://docs.datadoghq.com/logs/log_collection/ruby/?tab=lograge) | ✅ |
|
93
|
+
| Tracing | [Ruby Tracing application](https://docs.datadoghq.com/tracing/trace_collection/dd_libraries/ruby) | ✅ |
|
94
|
+
| Error Tracking | [Datadog error tracking](https://www.datadoghq.com/product/error-tracking) | ✅ |
|
95
|
+
|
96
|
+
|
88
97
|
## Development
|
89
98
|
|
90
99
|
After checking out the repo, run `bundle install` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/Steepfile
ADDED
@@ -0,0 +1,32 @@
|
|
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/datadog-json_logger.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.email = ["eth3rnit3@gmail.com"]
|
10
10
|
|
11
11
|
spec.summary = "Connect your ruby application to Datadog logging and tracing."
|
12
|
-
spec.description = "This gem provides easy integration for connecting a ruby application to Datadog's logging and tracing services."
|
12
|
+
spec.description = "This gem provides easy integration for connecting a ruby application to Datadog's logging and tracing services."
|
13
13
|
spec.homepage = "https://github.com/eth3rnit3/datadog-json_logger"
|
14
14
|
spec.license = "MIT"
|
15
15
|
spec.required_ruby_version = ">= 3.0"
|
@@ -22,17 +22,18 @@ Gem::Specification.new do |spec|
|
|
22
22
|
|
23
23
|
# Specify which files should be added to the gem when it is released.
|
24
24
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
25
|
-
spec.files =
|
26
|
-
|
27
|
-
(
|
28
|
-
|
25
|
+
spec.files =
|
26
|
+
Dir.chdir(__dir__) do
|
27
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
28
|
+
(File.expand_path(f) == __FILE__) ||
|
29
|
+
f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor Gemfile])
|
30
|
+
end
|
29
31
|
end
|
30
|
-
end
|
31
32
|
spec.bindir = "exe"
|
32
33
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
33
34
|
spec.require_paths = ["lib"]
|
34
35
|
|
35
|
-
spec.add_dependency
|
36
|
+
spec.add_dependency("ddtrace", ">= 1.16")
|
36
37
|
|
37
38
|
# For more information and examples about making a new gem, check out our
|
38
39
|
# guide at: https://bundler.io/guides/creating_gem.html
|
data/lib/datadog/json_logger.rb
CHANGED
@@ -1,17 +1,23 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "logger"
|
4
|
-
require_relative "loggers/version"
|
5
4
|
require_relative "loggers/json_formatter"
|
5
|
+
require_relative "loggers/version"
|
6
6
|
|
7
7
|
module Datadog
|
8
8
|
class Error < StandardError; end
|
9
9
|
|
10
10
|
class JSONLogger < Logger
|
11
|
-
def initialize(output =
|
12
|
-
|
13
|
-
super(output || $stdout)
|
11
|
+
def initialize(output = default_output)
|
12
|
+
super(output)
|
14
13
|
@default_formatter = ::Datadog::Loggers::JSONFormatter
|
15
14
|
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def default_output
|
19
|
+
$stdout.sync = true
|
20
|
+
$stdout
|
21
|
+
end
|
16
22
|
end
|
17
23
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "ddtrace"
|
4
|
-
require "logger"
|
5
4
|
require "json"
|
5
|
+
require "logger"
|
6
6
|
|
7
7
|
module Datadog
|
8
8
|
module Loggers
|
@@ -14,7 +14,7 @@ module Datadog
|
|
14
14
|
|
15
15
|
yield(log_hash) if block_given?
|
16
16
|
|
17
|
-
"#{log_hash
|
17
|
+
"#{::JSON.dump(log_hash)}\n"
|
18
18
|
end
|
19
19
|
|
20
20
|
def self.base_log_hash(severity, datetime, progname)
|
@@ -46,31 +46,42 @@ module Datadog
|
|
46
46
|
}
|
47
47
|
end
|
48
48
|
|
49
|
-
|
50
|
-
|
49
|
+
module HashFormatter
|
50
|
+
module_function
|
51
|
+
|
52
|
+
def format(log_hash, msg)
|
51
53
|
log_hash.merge!(msg)
|
52
54
|
end
|
53
55
|
end
|
54
56
|
|
55
|
-
|
56
|
-
|
57
|
+
module ExceptionFormatter
|
58
|
+
module_function
|
59
|
+
|
60
|
+
def format(log_hash, exception)
|
57
61
|
log_hash.merge!(
|
58
|
-
|
59
|
-
|
60
|
-
|
62
|
+
message: exception.inspect,
|
63
|
+
error: {
|
64
|
+
kind: exception.class,
|
65
|
+
message: exception.message,
|
66
|
+
stack: (exception.backtrace || []).join("\n")
|
67
|
+
}
|
61
68
|
)
|
62
69
|
end
|
63
70
|
end
|
64
71
|
|
65
|
-
|
66
|
-
|
72
|
+
module StringFormatter
|
73
|
+
module_function
|
74
|
+
|
75
|
+
def format(log_hash, msg)
|
67
76
|
log_hash[:message] = msg.dup.force_encoding("utf-8")
|
68
77
|
end
|
69
78
|
end
|
70
79
|
|
71
|
-
|
72
|
-
|
73
|
-
|
80
|
+
module DefaultFormatter
|
81
|
+
module_function
|
82
|
+
|
83
|
+
def format(log_hash, msg)
|
84
|
+
log_hash[:message] = msg.is_a?(String) ? msg : msg.inspect
|
74
85
|
end
|
75
86
|
end
|
76
87
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "uri"
|
4
3
|
require "json"
|
4
|
+
require "uri"
|
5
5
|
|
6
6
|
module Rack
|
7
7
|
class CommonLogger
|
@@ -40,7 +40,7 @@ module Datadog
|
|
40
40
|
def safely_process_request(env)
|
41
41
|
app.call(env)
|
42
42
|
rescue StandardError
|
43
|
-
[500, { "Content-Type"
|
43
|
+
[500, { "Content-Type": "text/html" }, ["Internal Server Error"]]
|
44
44
|
end
|
45
45
|
|
46
46
|
def log_request(request, env, status, headers, start_time, end_time)
|
@@ -75,7 +75,7 @@ module Datadog
|
|
75
75
|
exception_backtrace: exception.backtrace
|
76
76
|
)
|
77
77
|
|
78
|
-
raise
|
78
|
+
raise(exception)
|
79
79
|
end
|
80
80
|
end
|
81
81
|
end
|
data/sig/datadog/json_logger.rbs
CHANGED
@@ -1,6 +1,14 @@
|
|
1
1
|
module Datadog
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
class Error < StandardError
|
3
|
+
end
|
4
|
+
|
5
|
+
class JSONLogger < Logger
|
6
|
+
@default_formatter: singleton(Loggers::JSONFormatter)
|
7
|
+
|
8
|
+
def initialize: (?IO | StringIO | File | NilClass output) -> void
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def default_output: () -> IO
|
5
13
|
end
|
6
14
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Datadog
|
2
|
+
module Loggers
|
3
|
+
class JSONFormatter < Logger::Formatter
|
4
|
+
def self.call: (String severity, DateTime datetime, String progname, untyped msg) ?{ (untyped) -> untyped } -> ::String
|
5
|
+
|
6
|
+
def self.base_log_hash: (String severity, DateTime datetime, String progname) -> { dd: Hash[untyped, untyped], timestamp: String, severity: String, progname: String }
|
7
|
+
|
8
|
+
def self.formatter_for: ((String | Hash[Symbol, untyped] | Exception) msg) -> untyped
|
9
|
+
|
10
|
+
def self.correlation_hash: () -> { trace_id: Integer, span_id: Integer, env: String, service: String, version: String | Integer }
|
11
|
+
|
12
|
+
module HashFormatter
|
13
|
+
def self?.format: (Hash[Symbol, untyped] log_hash, Hash[untyped, untyped] msg) -> untyped
|
14
|
+
end
|
15
|
+
|
16
|
+
module ExceptionFormatter
|
17
|
+
def self?.format: (Hash[Symbol, untyped] log_hash, Exception exception) -> untyped
|
18
|
+
end
|
19
|
+
|
20
|
+
module StringFormatter
|
21
|
+
def self?.format: (Hash[Symbol, untyped] log_hash, String msg) -> untyped
|
22
|
+
end
|
23
|
+
|
24
|
+
module DefaultFormatter
|
25
|
+
def self?.format: (Hash[Symbol, untyped] log_hash, untyped msg) -> untyped
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Rack
|
2
|
+
class CommonLogger
|
3
|
+
def log: (untyped _env, untyped _status, untyped _response_headers, untyped _began_at) -> nil
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
module Datadog
|
8
|
+
class SinatraMiddleware
|
9
|
+
@app: untyped
|
10
|
+
|
11
|
+
@logger: Logger
|
12
|
+
|
13
|
+
attr_reader app: untyped
|
14
|
+
|
15
|
+
attr_reader logger: Logger
|
16
|
+
|
17
|
+
def initialize: (untyped app, Logger logger) -> void
|
18
|
+
|
19
|
+
def call: (untyped env) -> untyped
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def safely_process_request: (untyped env) -> untyped
|
24
|
+
|
25
|
+
def log_request: (Rack::Request request, untyped env, String status, Hash[String, String] headers, Time start_time, Time end_time) -> untyped
|
26
|
+
|
27
|
+
def calculate_duration: (Time start_time, Time end_time) -> Integer
|
28
|
+
|
29
|
+
def parse_query: (String query_string) -> Hash[String, String]
|
30
|
+
|
31
|
+
def handle_exception: (Exception exception) -> Exception
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
module Datadog
|
2
|
+
# Datadog APM tracing public API.
|
3
|
+
#
|
4
|
+
# The Datadog team ensures that public methods in this module
|
5
|
+
# only receive backwards compatible changes, and breaking changes
|
6
|
+
# will only occur in new major versions releases.
|
7
|
+
# @public_api
|
8
|
+
module Tracing
|
9
|
+
# (see Datadog::Tracing::Tracer#trace)
|
10
|
+
# @public_api
|
11
|
+
def self.trace: (untyped name, ?continue_from: untyped?, **untyped span_options) { () -> untyped } -> untyped
|
12
|
+
|
13
|
+
# (see Datadog::Tracing::Tracer#continue_trace!)
|
14
|
+
# @public_api
|
15
|
+
def self.continue_trace!: (untyped digest) { () -> untyped } -> untyped
|
16
|
+
|
17
|
+
# The tracer's internal logger instance.
|
18
|
+
# All tracing log output is handled by this object.
|
19
|
+
#
|
20
|
+
# The logger can be configured through {.configure},
|
21
|
+
# through {Datadog::Core::Configuration::Settings::DSL::Logger} options.
|
22
|
+
#
|
23
|
+
# @!attribute [r] logger
|
24
|
+
# @public_api
|
25
|
+
def self.logger: () -> untyped
|
26
|
+
|
27
|
+
# (see Datadog::Tracing::Tracer#active_trace)
|
28
|
+
# @public_api
|
29
|
+
def self.active_trace: () -> (nil | untyped)
|
30
|
+
|
31
|
+
# (see Datadog::Tracing::Tracer#active_span)
|
32
|
+
# @public_api
|
33
|
+
def self.active_span: () -> (nil | untyped)
|
34
|
+
|
35
|
+
# (see Datadog::Tracing::TraceSegment#keep!)
|
36
|
+
# If no trace is active, no action is taken.
|
37
|
+
# @public_api
|
38
|
+
def self.keep!: () -> untyped
|
39
|
+
|
40
|
+
# (see Datadog::Tracing::TraceSegment#reject!)
|
41
|
+
# If no trace is active, no action is taken.
|
42
|
+
# @public_api
|
43
|
+
def self.reject!: () -> untyped
|
44
|
+
|
45
|
+
# (see Datadog::Tracing::Tracer#active_correlation)
|
46
|
+
# @public_api
|
47
|
+
def self.correlation: () -> (nil | untyped)
|
48
|
+
|
49
|
+
# Textual representation of {.correlation}, which can be
|
50
|
+
# added to individual log lines in order to correlate them with the active
|
51
|
+
# trace.
|
52
|
+
#
|
53
|
+
# Example:
|
54
|
+
#
|
55
|
+
# ```
|
56
|
+
# MyLogger.log("#{Datadog::Tracing.log_correlation}] My message")
|
57
|
+
# # dd.env=prod dd.service=auth dd.version=13.8 dd.trace_id=5458478252992251 dd.span_id=7117552347370098 My message
|
58
|
+
# ```
|
59
|
+
#
|
60
|
+
# @return [String] correlation information
|
61
|
+
# @public_api
|
62
|
+
def self.log_correlation: () -> untyped
|
63
|
+
|
64
|
+
# Gracefully shuts down the tracer.
|
65
|
+
#
|
66
|
+
# The public tracing API will still respond to method calls as usual
|
67
|
+
# but might not internally perform the expected internal work after shutdown.
|
68
|
+
#
|
69
|
+
# This avoids errors being raised across the host application
|
70
|
+
# during shutdown while allowing for the graceful decommission of resources.
|
71
|
+
#
|
72
|
+
# {.shutdown!} cannot be reversed.
|
73
|
+
# @public_api
|
74
|
+
def self.shutdown!: () -> (nil | untyped)
|
75
|
+
|
76
|
+
# (see Datadog::Tracing::Pipeline.before_flush)
|
77
|
+
def self.before_flush: (*untyped processors) { () -> untyped } -> untyped
|
78
|
+
|
79
|
+
# Is the tracer collecting telemetry data in this process?
|
80
|
+
# @return [Boolean] `true` if the tracer is collecting data in this process, otherwise `false`.
|
81
|
+
def self.enabled?: () -> (false | untyped)
|
82
|
+
|
83
|
+
private
|
84
|
+
|
85
|
+
# DEV: components hosts both tracing and profiling inner objects today
|
86
|
+
def self.components: () -> untyped
|
87
|
+
|
88
|
+
def self.tracer: () -> untyped
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,362 @@
|
|
1
|
+
module Rack
|
2
|
+
class Request
|
3
|
+
self.@forwarded_priority: untyped
|
4
|
+
|
5
|
+
self.@x_forwarded_proto_priority: untyped
|
6
|
+
|
7
|
+
@env: untyped
|
8
|
+
|
9
|
+
@params: untyped
|
10
|
+
|
11
|
+
attr_accessor self.ip_filter: untyped
|
12
|
+
|
13
|
+
# The priority when checking forwarded headers. The default
|
14
|
+
# is <tt>[:forwarded, :x_forwarded]</tt>, which means, check the
|
15
|
+
# +Forwarded+ header first, followed by the appropriate
|
16
|
+
# <tt>X-Forwarded-*</tt> header. You can revert the priority by
|
17
|
+
# reversing the priority, or remove checking of either
|
18
|
+
# or both headers by removing elements from the array.
|
19
|
+
#
|
20
|
+
# This should be set as appropriate in your environment
|
21
|
+
# based on what reverse proxies are in use. If you are not
|
22
|
+
# using reverse proxies, you should probably use an empty
|
23
|
+
# array.
|
24
|
+
attr_accessor self.forwarded_priority: untyped
|
25
|
+
|
26
|
+
# The priority when checking either the <tt>X-Forwarded-Proto</tt>
|
27
|
+
# or <tt>X-Forwarded-Scheme</tt> header for the forwarded protocol.
|
28
|
+
# The default is <tt>[:proto, :scheme]</tt>, to try the
|
29
|
+
# <tt>X-Forwarded-Proto</tt> header before the
|
30
|
+
# <tt>X-Forwarded-Scheme</tt> header. Rack 2 had behavior
|
31
|
+
# similar to <tt>[:scheme, :proto]</tt>. You can remove either or
|
32
|
+
# both of the entries in array to ignore that respective header.
|
33
|
+
attr_accessor self.x_forwarded_proto_priority: untyped
|
34
|
+
|
35
|
+
ALLOWED_SCHEMES: ::Array["https" | "http" | "wss" | "ws"]
|
36
|
+
|
37
|
+
def initialize: (untyped env) -> void
|
38
|
+
|
39
|
+
def params: () -> untyped
|
40
|
+
|
41
|
+
def update_param: (untyped k, untyped v) -> untyped
|
42
|
+
|
43
|
+
def delete_param: (untyped k) -> untyped
|
44
|
+
|
45
|
+
module Env
|
46
|
+
@env: untyped
|
47
|
+
|
48
|
+
# The environment of the request.
|
49
|
+
attr_reader env: untyped
|
50
|
+
|
51
|
+
def initialize: (untyped env) -> void
|
52
|
+
|
53
|
+
# Predicate method to test to see if `name` has been set as request
|
54
|
+
# specific data
|
55
|
+
def has_header?: (untyped name) -> untyped
|
56
|
+
|
57
|
+
# Get a request specific value for `name`.
|
58
|
+
def get_header: (untyped name) -> untyped
|
59
|
+
|
60
|
+
# If a block is given, it yields to the block if the value hasn't been set
|
61
|
+
# on the request.
|
62
|
+
def fetch_header: (untyped name) { () -> untyped } -> untyped
|
63
|
+
|
64
|
+
# Loops through each key / value pair in the request specific data.
|
65
|
+
def each_header: () { () -> untyped } -> untyped
|
66
|
+
|
67
|
+
# Set a request specific value for `name` to `v`
|
68
|
+
def set_header: (untyped name, untyped v) -> untyped
|
69
|
+
|
70
|
+
# Add a header that may have multiple values.
|
71
|
+
#
|
72
|
+
# Example:
|
73
|
+
# request.add_header 'Accept', 'image/png'
|
74
|
+
# request.add_header 'Accept', '*/*'
|
75
|
+
#
|
76
|
+
# assert_equal 'image/png,*/*', request.get_header('Accept')
|
77
|
+
#
|
78
|
+
# http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2
|
79
|
+
def add_header: (untyped key, untyped v) -> untyped
|
80
|
+
|
81
|
+
# Delete a request specific value for `name`.
|
82
|
+
def delete_header: (untyped name) -> untyped
|
83
|
+
|
84
|
+
def initialize_copy: (untyped other) -> untyped
|
85
|
+
end
|
86
|
+
|
87
|
+
module Helpers
|
88
|
+
# The set of form-data media-types. Requests that do not indicate
|
89
|
+
# one of the media types present in this list will not be eligible
|
90
|
+
# for form-data / param parsing.
|
91
|
+
FORM_DATA_MEDIA_TYPES: ::Array["application/x-www-form-urlencoded" | "multipart/form-data"]
|
92
|
+
|
93
|
+
# The set of media-types. Requests that do not indicate
|
94
|
+
# one of the media types present in this list will not be eligible
|
95
|
+
# for param parsing like soap attachments or generic multiparts
|
96
|
+
PARSEABLE_DATA_MEDIA_TYPES: ::Array["multipart/related" | "multipart/mixed"]
|
97
|
+
|
98
|
+
# Default ports depending on scheme. Used to decide whether or not
|
99
|
+
# to include the port in a generated URI.
|
100
|
+
DEFAULT_PORTS: ::Hash[::String, 80 | 443]
|
101
|
+
|
102
|
+
# The address of the client which connected to the proxy.
|
103
|
+
HTTP_X_FORWARDED_FOR: "HTTP_X_FORWARDED_FOR"
|
104
|
+
|
105
|
+
# The contents of the host/:authority header sent to the proxy.
|
106
|
+
HTTP_X_FORWARDED_HOST: "HTTP_X_FORWARDED_HOST"
|
107
|
+
|
108
|
+
HTTP_FORWARDED: "HTTP_FORWARDED"
|
109
|
+
|
110
|
+
# The value of the scheme sent to the proxy.
|
111
|
+
HTTP_X_FORWARDED_SCHEME: "HTTP_X_FORWARDED_SCHEME"
|
112
|
+
|
113
|
+
# The protocol used to connect to the proxy.
|
114
|
+
HTTP_X_FORWARDED_PROTO: "HTTP_X_FORWARDED_PROTO"
|
115
|
+
|
116
|
+
# The port used to connect to the proxy.
|
117
|
+
HTTP_X_FORWARDED_PORT: "HTTP_X_FORWARDED_PORT"
|
118
|
+
|
119
|
+
# Another way for specifying https scheme was used.
|
120
|
+
HTTP_X_FORWARDED_SSL: "HTTP_X_FORWARDED_SSL"
|
121
|
+
|
122
|
+
def body: () -> untyped
|
123
|
+
|
124
|
+
def script_name: () -> untyped
|
125
|
+
|
126
|
+
def script_name=: (untyped s) -> untyped
|
127
|
+
|
128
|
+
def path_info: () -> untyped
|
129
|
+
|
130
|
+
def path_info=: (untyped s) -> untyped
|
131
|
+
|
132
|
+
def request_method: () -> untyped
|
133
|
+
|
134
|
+
def query_string: () -> untyped
|
135
|
+
|
136
|
+
def content_length: () -> untyped
|
137
|
+
|
138
|
+
def logger: () -> untyped
|
139
|
+
|
140
|
+
def user_agent: () -> untyped
|
141
|
+
|
142
|
+
# the referer of the client
|
143
|
+
def referer: () -> untyped
|
144
|
+
|
145
|
+
alias referrer referer
|
146
|
+
|
147
|
+
def session: () -> untyped
|
148
|
+
|
149
|
+
def session_options: () -> untyped
|
150
|
+
|
151
|
+
# Checks the HTTP request method (or verb) to see if it was of type DELETE
|
152
|
+
def delete?: () -> untyped
|
153
|
+
|
154
|
+
# Checks the HTTP request method (or verb) to see if it was of type GET
|
155
|
+
def get?: () -> untyped
|
156
|
+
|
157
|
+
# Checks the HTTP request method (or verb) to see if it was of type HEAD
|
158
|
+
def head?: () -> untyped
|
159
|
+
|
160
|
+
# Checks the HTTP request method (or verb) to see if it was of type OPTIONS
|
161
|
+
def options?: () -> untyped
|
162
|
+
|
163
|
+
# Checks the HTTP request method (or verb) to see if it was of type LINK
|
164
|
+
def link?: () -> untyped
|
165
|
+
|
166
|
+
# Checks the HTTP request method (or verb) to see if it was of type PATCH
|
167
|
+
def patch?: () -> untyped
|
168
|
+
|
169
|
+
# Checks the HTTP request method (or verb) to see if it was of type POST
|
170
|
+
def post?: () -> untyped
|
171
|
+
|
172
|
+
# Checks the HTTP request method (or verb) to see if it was of type PUT
|
173
|
+
def put?: () -> untyped
|
174
|
+
|
175
|
+
# Checks the HTTP request method (or verb) to see if it was of type TRACE
|
176
|
+
def trace?: () -> untyped
|
177
|
+
|
178
|
+
# Checks the HTTP request method (or verb) to see if it was of type UNLINK
|
179
|
+
def unlink?: () -> untyped
|
180
|
+
|
181
|
+
def scheme: () -> ("https" | "https" | untyped)
|
182
|
+
|
183
|
+
# The authority of the incoming request as defined by RFC3976.
|
184
|
+
# https://tools.ietf.org/html/rfc3986#section-3.2
|
185
|
+
#
|
186
|
+
# In HTTP/1, this is the `host` header.
|
187
|
+
# In HTTP/2, this is the `:authority` pseudo-header.
|
188
|
+
def authority: () -> untyped
|
189
|
+
|
190
|
+
# The authority as defined by the `SERVER_NAME` and `SERVER_PORT`
|
191
|
+
# variables.
|
192
|
+
def server_authority: () -> (nil | untyped)
|
193
|
+
|
194
|
+
def server_name: () -> untyped
|
195
|
+
|
196
|
+
def server_port: () -> untyped
|
197
|
+
|
198
|
+
def cookies: () -> untyped
|
199
|
+
|
200
|
+
def content_type: () -> untyped
|
201
|
+
|
202
|
+
def xhr?: () -> untyped
|
203
|
+
|
204
|
+
# The `HTTP_HOST` header.
|
205
|
+
def host_authority: () -> untyped
|
206
|
+
|
207
|
+
def host_with_port: (?untyped authority) -> untyped
|
208
|
+
|
209
|
+
# Returns a formatted host, suitable for being used in a URI.
|
210
|
+
def host: () -> untyped
|
211
|
+
|
212
|
+
# Returns an address suitable for being to resolve to an address.
|
213
|
+
# In the case of a domain name or IPv4 address, the result is the same
|
214
|
+
# as +host+. In the case of IPv6 or future address formats, the square
|
215
|
+
# brackets are removed.
|
216
|
+
def hostname: () -> untyped
|
217
|
+
|
218
|
+
def port: () -> untyped
|
219
|
+
|
220
|
+
def forwarded_for: () -> (untyped | nil)
|
221
|
+
|
222
|
+
def forwarded_port: () -> (untyped | nil)
|
223
|
+
|
224
|
+
def forwarded_authority: () -> (untyped | nil)
|
225
|
+
|
226
|
+
def ssl?: () -> untyped
|
227
|
+
|
228
|
+
def ip: () -> untyped
|
229
|
+
|
230
|
+
# The media type (type/subtype) portion of the CONTENT_TYPE header
|
231
|
+
# without any media type parameters. e.g., when CONTENT_TYPE is
|
232
|
+
# "text/plain;charset=utf-8", the media-type is "text/plain".
|
233
|
+
#
|
234
|
+
# For more information on the use of media types in HTTP, see:
|
235
|
+
# http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.7
|
236
|
+
def media_type: () -> untyped
|
237
|
+
|
238
|
+
# The media type parameters provided in CONTENT_TYPE as a Hash, or
|
239
|
+
# an empty Hash if no CONTENT_TYPE or media-type parameters were
|
240
|
+
# provided. e.g., when the CONTENT_TYPE is "text/plain;charset=utf-8",
|
241
|
+
# this method responds with the following Hash:
|
242
|
+
# { 'charset' => 'utf-8' }
|
243
|
+
def media_type_params: () -> untyped
|
244
|
+
|
245
|
+
# The character set of the request body if a "charset" media type
|
246
|
+
# parameter was given, or nil if no "charset" was specified. Note
|
247
|
+
# that, per RFC2616, text/* media types that specify no explicit
|
248
|
+
# charset are to be considered ISO-8859-1.
|
249
|
+
def content_charset: () -> untyped
|
250
|
+
|
251
|
+
# Determine whether the request body contains form-data by checking
|
252
|
+
# the request content-type for one of the media-types:
|
253
|
+
# "application/x-www-form-urlencoded" or "multipart/form-data". The
|
254
|
+
# list of form-data media types can be modified through the
|
255
|
+
# +FORM_DATA_MEDIA_TYPES+ array.
|
256
|
+
#
|
257
|
+
# A request body is also assumed to contain form-data when no
|
258
|
+
# content-type header is provided and the request_method is POST.
|
259
|
+
def form_data?: () -> untyped
|
260
|
+
|
261
|
+
# Determine whether the request body contains data by checking
|
262
|
+
# the request media_type against registered parse-data media-types
|
263
|
+
def parseable_data?: () -> untyped
|
264
|
+
|
265
|
+
# Returns the data received in the query string.
|
266
|
+
def GET: () -> untyped
|
267
|
+
|
268
|
+
# Returns the data received in the request body.
|
269
|
+
#
|
270
|
+
# This method support both application/x-www-form-urlencoded and
|
271
|
+
# multipart/form-data.
|
272
|
+
def POST: () -> untyped
|
273
|
+
|
274
|
+
# The union of GET and POST data.
|
275
|
+
#
|
276
|
+
# Note that modifications will not be persisted in the env. Use update_param or delete_param if you want to destructively modify params.
|
277
|
+
def params: () -> untyped
|
278
|
+
|
279
|
+
# Destructively update a parameter, whether it's in GET and/or POST. Returns nil.
|
280
|
+
#
|
281
|
+
# The parameter is updated wherever it was previous defined, so GET, POST, or both. If it wasn't previously defined, it's inserted into GET.
|
282
|
+
#
|
283
|
+
# <tt>env['rack.input']</tt> is not touched.
|
284
|
+
def update_param: (untyped k, untyped v) -> (nil | untyped)
|
285
|
+
|
286
|
+
# Destructively delete a parameter, whether it's in GET or POST. Returns the value of the deleted parameter.
|
287
|
+
#
|
288
|
+
# If the parameter is in both GET and POST, the POST value takes precedence since that's how #params works.
|
289
|
+
#
|
290
|
+
# <tt>env['rack.input']</tt> is not touched.
|
291
|
+
def delete_param: (untyped k) -> untyped
|
292
|
+
|
293
|
+
def base_url: () -> ::String
|
294
|
+
|
295
|
+
# Tries to return a remake of the original request URL as a string.
|
296
|
+
def url: () -> untyped
|
297
|
+
|
298
|
+
def path: () -> untyped
|
299
|
+
|
300
|
+
def fullpath: () -> (untyped | ::String)
|
301
|
+
|
302
|
+
def accept_encoding: () -> untyped
|
303
|
+
|
304
|
+
def accept_language: () -> untyped
|
305
|
+
|
306
|
+
def trusted_proxy?: (untyped ip) -> untyped
|
307
|
+
|
308
|
+
# shortcut for <tt>request.params[key]</tt>
|
309
|
+
def []: (untyped key) -> untyped
|
310
|
+
|
311
|
+
# shortcut for <tt>request.params[key] = value</tt>
|
312
|
+
#
|
313
|
+
# Note that modifications will not be persisted in the env. Use update_param or delete_param if you want to destructively modify params.
|
314
|
+
def []=: (untyped key, untyped value) -> untyped
|
315
|
+
|
316
|
+
# like Hash#values_at
|
317
|
+
def values_at: (*untyped keys) -> untyped
|
318
|
+
|
319
|
+
private
|
320
|
+
|
321
|
+
def default_session: () -> ::Hash[untyped, untyped]
|
322
|
+
|
323
|
+
# Assist with compatibility when processing `X-Forwarded-For`.
|
324
|
+
def wrap_ipv6: (untyped host) -> (::String | untyped)
|
325
|
+
|
326
|
+
def parse_http_accept_header: (untyped header) -> untyped
|
327
|
+
|
328
|
+
# Get an array of values set in the RFC 7239 `Forwarded` request header.
|
329
|
+
def get_http_forwarded: (untyped token) -> untyped
|
330
|
+
|
331
|
+
def query_parser: () -> untyped
|
332
|
+
|
333
|
+
def parse_query: (untyped qs, ?::String d) -> untyped
|
334
|
+
|
335
|
+
def parse_multipart: () -> untyped
|
336
|
+
|
337
|
+
def expand_param_pairs: (untyped pairs, ?untyped query_parser) -> untyped
|
338
|
+
|
339
|
+
def split_header: (untyped value) -> (untyped | ::Array[untyped])
|
340
|
+
|
341
|
+
AUTHORITY: ::Regexp
|
342
|
+
|
343
|
+
def split_authority: (untyped authority) -> ::Array[untyped]
|
344
|
+
|
345
|
+
def reject_trusted_ip_addresses: (untyped ip_addresses) -> untyped
|
346
|
+
|
347
|
+
FORWARDED_SCHEME_HEADERS: { proto: untyped, scheme: untyped }
|
348
|
+
|
349
|
+
def forwarded_scheme: () -> (untyped | nil)
|
350
|
+
|
351
|
+
def allowed_scheme: (untyped header) -> (untyped | nil)
|
352
|
+
|
353
|
+
def forwarded_priority: () -> untyped
|
354
|
+
|
355
|
+
def x_forwarded_proto_priority: () -> untyped
|
356
|
+
end
|
357
|
+
|
358
|
+
include Env
|
359
|
+
|
360
|
+
include Helpers
|
361
|
+
end
|
362
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: datadog-json_logger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eth3rnit3
|
@@ -14,16 +14,16 @@ dependencies:
|
|
14
14
|
name: ddtrace
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.16
|
19
|
+
version: '1.16'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.16
|
26
|
+
version: '1.16'
|
27
27
|
description: This gem provides easy integration for connecting a ruby application
|
28
28
|
to Datadog's logging and tracing services.
|
29
29
|
email:
|
@@ -35,12 +35,14 @@ files:
|
|
35
35
|
- ".rspec"
|
36
36
|
- ".rubocop.yml"
|
37
37
|
- ".ruby-version"
|
38
|
+
- ".rubycritic.yml"
|
38
39
|
- CHANGELOG.md
|
39
40
|
- CODE_OF_CONDUCT.md
|
40
41
|
- Dockerfile.nexus
|
41
42
|
- LICENSE.txt
|
42
43
|
- README.md
|
43
44
|
- Rakefile
|
45
|
+
- Steepfile
|
44
46
|
- datadog-json_logger.gemspec
|
45
47
|
- lib/datadog/json_logger.rb
|
46
48
|
- lib/datadog/loggers/json_formatter.rb
|
@@ -48,6 +50,11 @@ files:
|
|
48
50
|
- lib/datadog/sinatra_middleware.rb
|
49
51
|
- nexus_release.sh
|
50
52
|
- sig/datadog/json_logger.rbs
|
53
|
+
- sig/datadog/loggers/json_formatter.rbs
|
54
|
+
- sig/datadog/loggers/version.rbs
|
55
|
+
- sig/datadog/sinatra_middleware.rbs
|
56
|
+
- sig/datadog/tracing.rbs
|
57
|
+
- sig/rack/request.rbs
|
51
58
|
homepage: https://github.com/eth3rnit3/datadog-json_logger
|
52
59
|
licenses:
|
53
60
|
- MIT
|