Skip to content

Commit 60066b8

Browse files
author
Leszek Zalewski
authored
Merge pull request #8 from lessonnine/fix-io-target-for-cloudwatch
Fix io target for cloudwatch
2 parents eae449b + f0ea570 commit 60066b8

File tree

5 files changed

+33
-22
lines changed

5 files changed

+33
-22
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.3.1] - 2021-03-26
11+
### Changed
12+
- IO target replaces dots in telemetry keys with dashes for better integration with AWS CloudWatch
13+
1014
## [0.3.0] - 2020-12-21
1115
### Added
1216
- Datadog Target integration tests

Gemfile.lock

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,57 @@
11
PATH
22
remote: .
33
specs:
4-
puma-plugin-telemetry (0.3.0)
4+
puma-plugin-telemetry (0.3.1)
55
puma (>= 5.0)
66

77
GEM
88
remote: https://rubygems.org/
99
specs:
10-
ast (2.4.1)
10+
ast (2.4.2)
1111
diff-lcs (1.4.4)
12-
dogstatsd-ruby (4.8.2)
13-
nio4r (2.5.4)
12+
dogstatsd-ruby (4.8.3)
13+
nio4r (2.5.7)
1414
parallel (1.20.1)
15-
parser (2.7.2.0)
15+
parser (3.0.0.0)
1616
ast (~> 2.4.1)
17-
puma (5.1.1)
17+
puma (5.2.2)
1818
nio4r (~> 2.0)
1919
rainbow (3.0.0)
2020
rake (12.3.3)
21-
regexp_parser (2.0.0)
21+
regexp_parser (2.1.1)
2222
rexml (3.2.4)
2323
rspec (3.10.0)
2424
rspec-core (~> 3.10.0)
2525
rspec-expectations (~> 3.10.0)
2626
rspec-mocks (~> 3.10.0)
27-
rspec-core (3.10.0)
27+
rspec-core (3.10.1)
2828
rspec-support (~> 3.10.0)
29-
rspec-expectations (3.10.0)
29+
rspec-expectations (3.10.1)
3030
diff-lcs (>= 1.2.0, < 2.0)
3131
rspec-support (~> 3.10.0)
32-
rspec-mocks (3.10.0)
32+
rspec-mocks (3.10.2)
3333
diff-lcs (>= 1.2.0, < 2.0)
3434
rspec-support (~> 3.10.0)
35-
rspec-support (3.10.0)
36-
rubocop (1.5.2)
35+
rspec-support (3.10.2)
36+
rubocop (1.12.0)
3737
parallel (~> 1.10)
38-
parser (>= 2.7.1.5)
38+
parser (>= 3.0.0.0)
3939
rainbow (>= 2.2.2, < 4.0)
4040
regexp_parser (>= 1.8, < 3.0)
4141
rexml
4242
rubocop-ast (>= 1.2.0, < 2.0)
4343
ruby-progressbar (~> 1.7)
44-
unicode-display_width (>= 1.4.0, < 2.0)
45-
rubocop-ast (1.3.0)
44+
unicode-display_width (>= 1.4.0, < 3.0)
45+
rubocop-ast (1.4.1)
4646
parser (>= 2.7.1.5)
47-
rubocop-performance (1.9.1)
47+
rubocop-performance (1.10.2)
4848
rubocop (>= 0.90.0, < 2.0)
4949
rubocop-ast (>= 0.4.0)
50-
rubocop-rspec (2.0.1)
50+
rubocop-rspec (2.2.0)
5151
rubocop (~> 1.0)
5252
rubocop-ast (>= 1.1.0)
53-
ruby-progressbar (1.10.1)
54-
unicode-display_width (1.7.0)
53+
ruby-progressbar (1.11.0)
54+
unicode-display_width (2.0.0)
5555

5656
PLATFORMS
5757
ruby

lib/puma/plugin/telemetry/targets/io_target.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,15 @@ class IOTarget
1212
# JSON formatter for IO, expects `call` method accepting telemetry hash
1313
#
1414
class JSONFormatter
15+
# NOTE: Replace dots with dashes for better support of AWS CloudWatch
16+
# Log Metric filters, as they don't support dots in key names.
1517
def self.call(telemetry)
16-
::JSON.dump(telemetry.merge(name: "Puma::Plugin::Telemetry", message: "Publish telemetry"))
18+
log = telemetry.transform_keys { |k| k.tr(".", "-") }
19+
20+
log["name"] = "Puma::Plugin::Telemetry"
21+
log["message"] = "Publish telemetry"
22+
23+
::JSON.dump(log)
1724
end
1825
end
1926

lib/puma/plugin/telemetry/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
module Puma
44
class Plugin
55
module Telemetry
6-
VERSION = "0.3.0"
6+
VERSION = "0.3.1"
77
end
88
end
99
end

spec/integration/plugin_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class Plugin
6262
context "when subset of telemetry" do
6363
let(:config) { "puma_telemetry_subset" }
6464
let(:expected_telemetry) do
65-
"{\"queue.backlog\":0,\"workers.spawned_threads\":2,\"workers.max_threads\":4,\"name\":\"Puma::Plugin::Telemetry\",\"message\":\"Publish telemetry\"}\n" # rubocop:disable Layout/LineLength
65+
"{\"queue-backlog\":0,\"workers-spawned_threads\":2,\"workers-max_threads\":4,\"name\":\"Puma::Plugin::Telemetry\",\"message\":\"Publish telemetry\"}\n" # rubocop:disable Layout/LineLength
6666
end
6767

6868
it "logs only selected telemetry" do

0 commit comments

Comments
 (0)