lumberjack_data_dog_device 1.0.0 → 1.1.0
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 +4 -4
- data/.github/dependabot.yml +12 -0
- data/.github/workflows/continuous_integration.yml +46 -0
- data/.standard.yml +8 -0
- data/CHANGE_LOG.md +30 -2
- data/README.md +37 -3
- data/VERSION +1 -1
- data/lib/lumberjack_data_dog_device.rb +29 -15
- data/lumberjack_data_dog_device.gemspec +11 -12
- metadata +14 -39
- /data/{MIT_LICENSE → MIT_LICENSE.txt} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: addf5b5690d7de27ea3f61b97f0df001a6f8315b6b47cc5252a013ab3dfa9036
|
4
|
+
data.tar.gz: db399010d354397291f19a9173691b875939e33e2db33152dd932d4969371856
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b7c71c685bc86d831d346911cde9dfd6d101a61b7ff1c5df244c13252446628ca10e186a5107de16c12d9aff79848b820ce183ebaec26b6067a7b37ff3eecb1
|
7
|
+
data.tar.gz: 17c5c871ded8343cb7f8ba1b21162f3eeca41244a313932b0c1f3a3328edc74b449ea23cc79bdf87bae4ff5559bd30ba613568f50375efb96ce6d2fe7eadd38e
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# Dependabot update strategy
|
2
|
+
version: 2
|
3
|
+
updates:
|
4
|
+
- package-ecosystem: bundler
|
5
|
+
directory: "/"
|
6
|
+
schedule:
|
7
|
+
interval: daily
|
8
|
+
allow:
|
9
|
+
# Automatically keep all runtime dependencies updated
|
10
|
+
- dependency-name: "*"
|
11
|
+
dependency-type: "production"
|
12
|
+
versioning-strategy: lockfile-only
|
@@ -0,0 +1,46 @@
|
|
1
|
+
name: Continuous Integration
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- master
|
7
|
+
- actions-*
|
8
|
+
tags:
|
9
|
+
- v*
|
10
|
+
pull_request:
|
11
|
+
branches-ignore:
|
12
|
+
- actions-*
|
13
|
+
workflow_dispatch:
|
14
|
+
|
15
|
+
env:
|
16
|
+
BUNDLE_CLEAN: "true"
|
17
|
+
BUNDLE_PATH: vendor/bundle
|
18
|
+
BUNDLE_JOBS: 3
|
19
|
+
BUNDLE_RETRY: 3
|
20
|
+
|
21
|
+
jobs:
|
22
|
+
build:
|
23
|
+
name: ${{ matrix.ruby }} build
|
24
|
+
runs-on: ubuntu-latest
|
25
|
+
strategy:
|
26
|
+
matrix:
|
27
|
+
include:
|
28
|
+
- ruby: "ruby"
|
29
|
+
standardrb: true
|
30
|
+
- ruby: "3.0"
|
31
|
+
- ruby: "2.7"
|
32
|
+
- ruby: "2.5"
|
33
|
+
steps:
|
34
|
+
- uses: actions/checkout@v2
|
35
|
+
- name: Set up Ruby
|
36
|
+
uses: ruby/setup-ruby@v1
|
37
|
+
with:
|
38
|
+
ruby-version: ${{ matrix.ruby}}
|
39
|
+
- name: Install gems
|
40
|
+
run: |
|
41
|
+
bundle install
|
42
|
+
- name: Run Tests
|
43
|
+
run: bundle exec rake
|
44
|
+
- name: standardrb
|
45
|
+
if: matrix.standardrb
|
46
|
+
run: bundle exec standardrb
|
data/.standard.yml
ADDED
data/CHANGE_LOG.md
CHANGED
@@ -1,3 +1,31 @@
|
|
1
|
-
#
|
1
|
+
# Changelog
|
2
|
+
All notable changes to this project will be documented in this file.
|
2
3
|
|
3
|
-
|
4
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
5
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
|
+
|
7
|
+
## 1.1.0
|
8
|
+
|
9
|
+
### Fixed
|
10
|
+
|
11
|
+
- Fixed the stack trace on errors to be logged in the correct `error.stack` tag rather than `error.trace`.
|
12
|
+
|
13
|
+
### Removed
|
14
|
+
|
15
|
+
- Removed support for Ruby 2.4.
|
16
|
+
|
17
|
+
## 1.0.1
|
18
|
+
|
19
|
+
### Added
|
20
|
+
|
21
|
+
- Add optional max_message_length to limit the length of message payload.
|
22
|
+
|
23
|
+
### Changed
|
24
|
+
|
25
|
+
- Format non-hashes in log messages as strings to prevent stack overflow on objects that cannot be serialized to JSON.
|
26
|
+
|
27
|
+
## 1.0.0
|
28
|
+
|
29
|
+
### Added
|
30
|
+
|
31
|
+
- Initial release
|
data/README.md
CHANGED
@@ -1,10 +1,14 @@
|
|
1
1
|
# Lumberjack DataDog Device
|
2
2
|
|
3
|
-
[](https://github.com/bdurand/lumberjack_data_dog_device/actions/workflows/continuous_integration.yml)
|
4
|
+
[](https://github.com/testdouble/standard)
|
5
|
+
[](https://badge.fury.io/rb/lumberjack_data_dog_device)
|
5
6
|
|
6
7
|
This gem provides a logging device that produces JSON output that matches the standard fields defined for [DataDog logging](https://docs.datadoghq.com/logs/processing/attributes_naming_convention/).
|
7
8
|
|
9
|
+
> [!WARNING]
|
10
|
+
> This gem is no longer being maintained. It has been replaced by the [`lumberjack_data_dog`](https://github.com/bdurand/lumberjack_data_dog) gem.
|
11
|
+
|
8
12
|
* The time will be sent as "timestamp" with a precision in microseconds.
|
9
13
|
|
10
14
|
* The severity will be sent as "status" with a string label (DEBUG, INFO, WARN, ERROR, FATAL).
|
@@ -21,7 +25,9 @@ This gem provides a logging device that produces JSON output that matches the st
|
|
21
25
|
|
22
26
|
* All other tags are sent as is. If a tag name includes a dot, it will be sent as a nested JSON structure.
|
23
27
|
|
24
|
-
This device extends from [`Lumberjack::JsonDevice`](). It is not tied to Data Dog in any way other than that it is opinionated about how to map and format some log tags. It can be used with other services or pipelines without issue.
|
28
|
+
This device extends from [`Lumberjack::JsonDevice`](https://github.com/bdurand/lumberjack_json_device). It is not tied to Data Dog in any way other than that it is opinionated about how to map and format some log tags. It can be used with other services or pipelines without issue.
|
29
|
+
|
30
|
+
You can optionally specify a maximum message length with the `max_message_length` option on the device. Doing so will trucate the message payload to keep it under this number of characters. This option is provided because JSON payloads get messed up and cannot be parsed if they get too big.
|
25
31
|
|
26
32
|
## Example
|
27
33
|
|
@@ -35,3 +41,31 @@ logger.tag("http.method" => request.method, "http.url" => request.url) do
|
|
35
41
|
)
|
36
42
|
end
|
37
43
|
```
|
44
|
+
|
45
|
+
## Installation
|
46
|
+
|
47
|
+
Add this line to your application's Gemfile:
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
gem "lumberjack_data_dog_device"
|
51
|
+
```
|
52
|
+
|
53
|
+
And then execute:
|
54
|
+
```bash
|
55
|
+
$ bundle install
|
56
|
+
```
|
57
|
+
|
58
|
+
Or install it yourself as:
|
59
|
+
```bash
|
60
|
+
$ gem install lumberjack_data_dog_device
|
61
|
+
```
|
62
|
+
|
63
|
+
## Contributing
|
64
|
+
|
65
|
+
Open a pull request on GitHub.
|
66
|
+
|
67
|
+
Please use the [standardrb](https://github.com/testdouble/standard) syntax and lint your code with `standardrb --fix` before submitting.
|
68
|
+
|
69
|
+
## License
|
70
|
+
|
71
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.1.0
|
@@ -8,39 +8,48 @@ module Lumberjack
|
|
8
8
|
#
|
9
9
|
# See https://docs.datadoghq.com/logs/log_collection
|
10
10
|
class DataDogDevice < JsonDevice
|
11
|
-
|
12
11
|
module ExceptionHash
|
13
|
-
|
14
12
|
protected
|
15
|
-
|
13
|
+
|
16
14
|
def exception_hash(exception, device)
|
17
15
|
hash = {"kind" => exception.class.name}
|
18
16
|
hash["message"] = exception.message unless exception.message.nil?
|
17
|
+
|
19
18
|
trace = exception.backtrace
|
20
|
-
if trace && device
|
19
|
+
if trace && device&.respond_to?(:backtrace_cleaner) && device.backtrace_cleaner
|
21
20
|
trace = device.backtrace_cleaner.call(trace)
|
22
21
|
end
|
23
|
-
hash["
|
22
|
+
hash["stack"] = trace if trace
|
23
|
+
|
24
24
|
hash
|
25
25
|
end
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
# Formatter to format a messge as an error if it is an exception.
|
29
29
|
class MessageExceptionFormatter
|
30
30
|
include ExceptionHash
|
31
|
-
|
31
|
+
|
32
32
|
def initialize(device = nil)
|
33
33
|
@device = device
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
36
|
def call(object)
|
37
37
|
if object.is_a?(Exception)
|
38
38
|
{
|
39
39
|
"message" => object.inspect,
|
40
40
|
"error" => exception_hash(object, @device)
|
41
41
|
}
|
42
|
+
elsif object.is_a?(Hash)
|
43
|
+
{"message" => object}
|
44
|
+
elsif object.nil?
|
45
|
+
{"message" => nil}
|
42
46
|
else
|
43
|
-
|
47
|
+
message = object.to_s
|
48
|
+
max_message_length = @device.max_message_length
|
49
|
+
if max_message_length && message.length > max_message_length
|
50
|
+
message = message[0, max_message_length]
|
51
|
+
end
|
52
|
+
{"message" => message}
|
44
53
|
end
|
45
54
|
end
|
46
55
|
end
|
@@ -115,7 +124,7 @@ module Lumberjack
|
|
115
124
|
if value.is_a?(Numeric)
|
116
125
|
value = (value.to_f * @multiplier).round
|
117
126
|
end
|
118
|
-
{
|
127
|
+
{"duration" => value}
|
119
128
|
end
|
120
129
|
end
|
121
130
|
|
@@ -124,14 +133,19 @@ module Lumberjack
|
|
124
133
|
# One use for it is to keep stack traces clean and prevent them from overflowing the limit on
|
125
134
|
# the payload size for an individual log entry.
|
126
135
|
attr_accessor :backtrace_cleaner
|
127
|
-
|
128
|
-
|
129
|
-
|
136
|
+
|
137
|
+
# You can specify a limit on the message size. Messages over this size will be split into multiple
|
138
|
+
# log entries to prevent overflowing the limit on message size which makes the log entries unparseable.
|
139
|
+
attr_accessor :max_message_length
|
140
|
+
|
141
|
+
def initialize(stream_or_device, backtrace_cleaner: nil, max_message_length: nil, **args)
|
142
|
+
super(stream_or_device, mapping: data_dog_mapping, **args)
|
130
143
|
self.backtrace_cleaner = backtrace_cleaner
|
144
|
+
self.max_message_length = max_message_length
|
131
145
|
end
|
132
|
-
|
146
|
+
|
133
147
|
private
|
134
|
-
|
148
|
+
|
135
149
|
def data_dog_mapping
|
136
150
|
{
|
137
151
|
time: "timestamp",
|
@@ -1,8 +1,8 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
|
-
spec.name =
|
3
|
-
spec.version = File.read(File.
|
4
|
-
spec.authors = [
|
5
|
-
spec.email = [
|
2
|
+
spec.name = "lumberjack_data_dog_device"
|
3
|
+
spec.version = File.read(File.join(__dir__, "VERSION")).strip
|
4
|
+
spec.authors = ["Brian Durand"]
|
5
|
+
spec.email = ["bbdurand@gmail.com"]
|
6
6
|
|
7
7
|
spec.summary = "A logging device for sending logs to DataDog in JSON format."
|
8
8
|
spec.homepage = "https://github.com/bdurand/lumberjack_data_dog_device"
|
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
|
11
11
|
# Specify which files should be added to the gem when it is released.
|
12
12
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
13
|
-
ignore_files = %w
|
13
|
+
ignore_files = %w[
|
14
14
|
.gitignore
|
15
15
|
.travis.yml
|
16
16
|
Appraisals
|
@@ -19,15 +19,14 @@ Gem::Specification.new do |spec|
|
|
19
19
|
Rakefile
|
20
20
|
gemfiles/
|
21
21
|
spec/
|
22
|
-
|
23
|
-
spec.files = Dir.chdir(
|
24
|
-
`git ls-files -z`.split("\x0").reject{ |f| ignore_files.any?{ |path| f.start_with?(path) } }
|
22
|
+
]
|
23
|
+
spec.files = Dir.chdir(__dir__) do
|
24
|
+
`git ls-files -z`.split("\x0").reject { |f| ignore_files.any? { |path| f.start_with?(path) } }
|
25
25
|
end
|
26
26
|
|
27
|
-
spec.require_paths = [
|
27
|
+
spec.require_paths = ["lib"]
|
28
28
|
|
29
|
-
spec.
|
29
|
+
spec.required_ruby_version = ">= 2.5"
|
30
30
|
|
31
|
-
spec.
|
32
|
-
spec.add_development_dependency "rake"
|
31
|
+
spec.add_dependency "lumberjack_json_device", ">=2.0"
|
33
32
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lumberjack_data_dog_device
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Durand
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-07-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lumberjack_json_device
|
@@ -16,51 +16,26 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2.0'
|
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: '
|
27
|
-
|
28
|
-
name: rspec
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '3.0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '3.0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rake
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
description:
|
26
|
+
version: '2.0'
|
27
|
+
description:
|
56
28
|
email:
|
57
29
|
- bbdurand@gmail.com
|
58
30
|
executables: []
|
59
31
|
extensions: []
|
60
32
|
extra_rdoc_files: []
|
61
33
|
files:
|
34
|
+
- ".github/dependabot.yml"
|
35
|
+
- ".github/workflows/continuous_integration.yml"
|
36
|
+
- ".standard.yml"
|
62
37
|
- CHANGE_LOG.md
|
63
|
-
- MIT_LICENSE
|
38
|
+
- MIT_LICENSE.txt
|
64
39
|
- README.md
|
65
40
|
- VERSION
|
66
41
|
- lib/lumberjack_data_dog_device.rb
|
@@ -69,7 +44,7 @@ homepage: https://github.com/bdurand/lumberjack_data_dog_device
|
|
69
44
|
licenses:
|
70
45
|
- MIT
|
71
46
|
metadata: {}
|
72
|
-
post_install_message:
|
47
|
+
post_install_message:
|
73
48
|
rdoc_options: []
|
74
49
|
require_paths:
|
75
50
|
- lib
|
@@ -77,15 +52,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
77
52
|
requirements:
|
78
53
|
- - ">="
|
79
54
|
- !ruby/object:Gem::Version
|
80
|
-
version: '
|
55
|
+
version: '2.5'
|
81
56
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
57
|
requirements:
|
83
58
|
- - ">="
|
84
59
|
- !ruby/object:Gem::Version
|
85
60
|
version: '0'
|
86
61
|
requirements: []
|
87
|
-
rubygems_version: 3.
|
88
|
-
signing_key:
|
62
|
+
rubygems_version: 3.4.10
|
63
|
+
signing_key:
|
89
64
|
specification_version: 4
|
90
65
|
summary: A logging device for sending logs to DataDog in JSON format.
|
91
66
|
test_files: []
|
File without changes
|