puma-plugin-telemetry_too 0.0.1.alpha1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 6c682b1fe20857520c6a607906dd69ddd84b42578b47eb774942aed89245b0eb
4
+ data.tar.gz: 74e52f5636942939be701e6095dbb81da1b124bc87fee0a8569a0a90f986d1c9
5
+ SHA512:
6
+ metadata.gz: b60248fbb6767b8b46cc1b0566cb717a77e406febd159df2c85142ebd67f09f8c379ae7cff758a92cafb24a9b3d3b978c58aba4720eee636e02a6802573e5b29
7
+ data.tar.gz: c3154f1ec4e3c4a6171b02ba8d85bd2b731fcad86ba25bf2dc5967942f83c092abe7ebb94cac86a55362de528ae44f081e3065bcbad923396eb3cc60efee7e88
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ require:
2
+ - rubocop-performance
3
+
4
+ AllCops:
5
+ TargetRubyVersion: 3.2
6
+ NewCops: enable
7
+
8
+ Metrics/BlockLength:
9
+ Exclude:
10
+ - spec/**/*
11
+ Metrics/ClassLength:
12
+ Exclude:
13
+ - spec/**/*
data/.tool-versions ADDED
@@ -0,0 +1 @@
1
+ ruby 2.6.10
data/CHANGELOG.md ADDED
@@ -0,0 +1,115 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased] TBD
9
+
10
+ ### Changed TBD
11
+ - Forked and renamed Gem to `puma-plugin-telemetry_too`
12
+
13
+ ### Added
14
+ - Introduce new `formatter:` options: `:json` and `:passthrough`
15
+ - Introduce new `transform:` options: `:cloud_watch` and `:passthrough`
16
+ - Introduce new `LogTarget` for logging metrics to any `::Logger` compatible logger
17
+ - Support for Puma 7
18
+
19
+ ## [1.1.4] 2025-05-29
20
+
21
+ ### Changed
22
+ - Updated gems in the Gemfile.lock
23
+
24
+ ### Added
25
+ - Support for 'ubuntu-24.04'
26
+ - Support for Ruby 3.4
27
+
28
+ ### Dropped
29
+ - Support for 'ubuntu-20.04'
30
+ - Support for Ruby 2.6 and 2.7
31
+
32
+ ## [1.1.3] 2024-05-13
33
+
34
+ ### Changed
35
+ - Updated gems in the Gemfile.lock
36
+
37
+ ### Added
38
+ - Support for Ruby 3.2 and 3.3
39
+
40
+ ### Dropped
41
+ - Check for support for 'ubuntu-18.04'
42
+
43
+ ## [1.1.2] 2022-12-28
44
+
45
+ - Add Puma 6 compatibility
46
+
47
+ ## [1.1.1] 2022-06-22
48
+
49
+ Public release.
50
+
51
+ ## [1.1.0] 2022-06-22
52
+
53
+ Out of beta testing, reading for usage. Following is a recap from Alpha & Beta releases.
54
+
55
+ ### Added
56
+ - new metric: `sockets.backlog` (disabled by default), pulls information from Puma
57
+ sockets about the state of their backlogs. This together with `queue.backlog`
58
+ allows for full insights into total number of requests waiting to be processed
59
+ - `config.sockets_telemetry!` option to enable sockets telemetry
60
+ - `config.socket_parser` option to allow custom parser implementation as needed
61
+ - Datadog widgets examples under `docs/examples.md`
62
+
63
+ ## [1.1.0 Beta] ???
64
+ ### Added
65
+
66
+ Different ways to parse `Socket::Option`. Mainly due to the fact that `#inspect` can't
67
+ generate proper data on AWS Fargate, which runs Amazon Linux 2 with 4.14 kernel. So now
68
+ besides `#inspect` there's also `#unpack` that parses binary data and picks proper field.
69
+
70
+ It depends on the kernel, but new fields are usually added at the end of the `tcp_info`
71
+ struct, so it should more or less stay stable.
72
+
73
+ You can configure it by passing in `config.socket_parser = :inspect` or
74
+ `config.socket_parser = ->(opt) { your implementation }`.
75
+
76
+ ## [1.1.0 Alpha] ???
77
+ ### Added
78
+
79
+ Socket telemetry, and to be more precise new metric: `sockets.backlog`. If enabled it will
80
+ pull information from Puma sockets about the state of their backlogs (requests waiting to
81
+ be acknowledged by Puma). It will be exposed under `sockets-backlog` metric.
82
+
83
+ You can enable and test it via `config.sockets_telemetry!` option.
84
+
85
+ ## [1.0.0] 2021-09-08
86
+ ### Added
87
+ - Release to GitHub Packages
88
+ - Explicitly flush Datadog metrics after publishing them
89
+ - Middleware for measuring and tracking request queue time
90
+
91
+ ### Changed
92
+ - Replace `statsd.batch` with direct calls, as it aggregates metrics internally by default now.
93
+ Also `#batch` method is deprecated and will be removed in version 6 of Datadog Statsd client.
94
+
95
+ ## [0.3.1] 2021-03-26
96
+ ### Changed
97
+ - IO target replaces dots in telemetry keys with dashes for better integration with AWS CloudWatch
98
+
99
+ ## [0.3.0] 2020-12-21
100
+ ### Added
101
+ - Datadog Target integration tests
102
+
103
+ ### Fixed
104
+ - Datadog Target
105
+
106
+ ## [0.2.0] 2020-12-21
107
+ ### Fixed
108
+ - Removed debugging information
109
+
110
+ ## [0.1.0] 2020-12-18
111
+ ### Added
112
+ - Core Plugin
113
+ - Telemetry generation
114
+ - IO Target with JSON formatter
115
+ - Datadog Statsd Target
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at tnt@babbel.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Babbel GmbH
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,190 @@
1
+ # Puma::Plugin::TelemetryToo
2
+
3
+ NOTE: This is a fork of `puma-plugin-telemetry`, modified to:
4
+
5
+ - Support Puma 7
6
+ - Add `LogTarget`, with custom `formatter:` and `transform:` options
7
+ - Warn about socket telemetry on unsupported platforms
8
+
9
+ Puma plugin which should be able to handle all your metric needs regarding your webserver:
10
+
11
+ - ability to publish basic puma statistics (like queue backlog) to both logs and Datadog
12
+ - ability to add custom target whenever you need it
13
+ - ability to monitor puma socket listen queue (!)
14
+ - ability to report requests queue time via custom rack middleware - the time request spent between being accepted by Load Balancer and start of its processing by Puma worker
15
+
16
+ ## Install
17
+
18
+ Add this line to your application's Gemfile:
19
+
20
+ ```ruby
21
+ gem "puma-plugin-telemetry_too"
22
+ ```
23
+
24
+ And then execute:
25
+
26
+ ```console
27
+ $ bundle install
28
+ ```
29
+
30
+ Or install it yourself as:
31
+
32
+ ```console
33
+ $ gem install puma-plugin-telemetry_too
34
+ ```
35
+
36
+ ## Usage
37
+
38
+ In your puma configuration file (i.e. `config/puma.rb` or `config/puma/<env>.rb`):
39
+
40
+ ```ruby
41
+ plugin "telemetry"
42
+
43
+ Puma::Plugin::TelemetryToo.configure do |config|
44
+ config.enabled = true
45
+
46
+ # << here rest of the configuration, examples below
47
+ end
48
+ ```
49
+
50
+ ### Basic IO Target
51
+
52
+ A basic I/O target will emit telemetry data to `STDOUT`, formatted in JSON.
53
+
54
+ ```ruby
55
+ config.add_target(:io)
56
+ ```
57
+
58
+ #### Options
59
+
60
+ This target has configurable `formatter:` and `transform:` options.
61
+ The `formatter:` options are
62
+
63
+ * `:json` _(default)_ - Print the logs in JSON.
64
+ * `:logfmt` - Print the logs in key/value pairs, as per `logfmt`.
65
+ * `:passthrough` - A pass-through formatter which returns the telemetry `Hash` unaltered, passing it directly to the `io:` instance.
66
+
67
+ The `transform:` options are
68
+
69
+ * `:cloud_watch` _(default)_ - Transforms telemetry keys, replacing dots with dashes to support AWS CloudWatch Log Metrics filters.
70
+ * `:logfmt` - Transforms telemetry keys, prepending `sample#` for [L2Met][l2met] consumption.
71
+ * `:passthrough` - A pass-through transform which returns the telemetry `Hash` unaltered.
72
+
73
+ ### Log target
74
+
75
+ While emitting to `STDOUT` via the basic `IOTarget` can work for getting telemetry into logs, we also provide an explicit `LogTarget`.
76
+ This target will defaults to emitting telemetry at the `INFO` log level via a [standard library `::Logger`][logger] instance.
77
+ That default logger will print to `STDOUT` in [the `logfmt` format][logfmt].
78
+
79
+ ```ruby
80
+ config.add_target(:log)
81
+ ```
82
+
83
+ You can pass an explicit `logger:` option if you wanted to, for example, use the same logger as Rails.
84
+
85
+ ```ruby
86
+ config.add_target(:log, logger: Rails.logger)
87
+ ```
88
+
89
+ This target also has configurable `formatter:` and `transform:` options.
90
+ The [possible options are the same as for the `IOTarget`](#options), but the defaults are different.
91
+ The `LogTarget` defaults to `formatter: :logfmt`, and `transform: :passthrough`.
92
+
93
+ [l2met]: https://github.com/ryandotsmith/l2met "l2met - Logs to metrics"
94
+ [logfmt]: https://brandur.org/logfmt "logfmt - Structured log format"
95
+ [logger]: https://rubyapi.org/o/logger "Ruby's Logger, from the stdlib"
96
+
97
+ ### Datadog StatsD target
98
+
99
+ A target for the Datadog StatsD client, that uses batch operation to publish metrics.
100
+
101
+ **NOTE** Be sure to have the `dogstatsd` gem installed.
102
+
103
+ ```ruby
104
+ config.add_target(:dogstatsd, client: Datadog::Statsd.new)
105
+ ```
106
+
107
+ You can provide all the tags, namespaces, and other configuration options as always to `Datadog::Statsd.new` method.
108
+
109
+ ### All available options
110
+
111
+ For detailed documentation checkout [`Puma::Plugin::TelemetryToo::Config`](./lib/puma/plugin/telemetry_too/config.rb) class.
112
+
113
+ ```ruby
114
+ Puma::Plugin::TelemetryToo.configure do |config|
115
+ config.enabled = true
116
+ config.initial_delay = 10
117
+ config.frequency = 30
118
+ config.puma_telemetry = %w[workers.requests_count queue.backlog queue.capacity]
119
+ config.socket_telemetry!
120
+ config.socket_parser = :inspect
121
+ config.add_target :io, io: StringIO.new, formatter: :json, transform: :passthrough
122
+ config.add_target :dogstatsd, client: Datadog::Statsd.new(tags: { env: ENV["RAILS_ENV"] })
123
+ end
124
+ ```
125
+
126
+ ### Custom Targets
127
+
128
+ Target is a simple object that implements `call` methods that accepts `telemetry` hash object. This means it can be super simple `proc` or some sophisticated class calling some external API.
129
+
130
+ Just be mindful that if the API takes long to call, it will slow down frequency with which telemetry will get reported.
131
+
132
+ ```ruby
133
+ # Example key/value log to `STDOUT` target
134
+ config.add_target ->(telemetry) { puts telemetry.map { |k, v| "#{k}=#{v.inspect}" }.join(" ") }
135
+ ```
136
+
137
+ ## Extra middleware
138
+
139
+ This gems comes together with middleware for measuring request queue time, which will be reported in `request.env` and published to given StatsD client.
140
+
141
+ Example configuration:
142
+
143
+ ```ruby
144
+ # in Gemfile add `require` part
145
+ gem "puma-plugin-telemetry_too", require: ["rack/request_queue_time_middleware"]
146
+
147
+ # in initializer, i.e. `request_queue_time.rb`
148
+ Rails.application.config.middleware.insert_after(
149
+ 0,
150
+ RequestQueueTimeMiddleware,
151
+ statsd: Datadog::Statsd.new(namespace: "ruby.puma", tags: { "app" => "accounts" })
152
+ )
153
+
154
+ Rails.application.config.log_tags ||= {}
155
+ Rails.application.config.log_tags[:queue_time] = ->(req) { req.env[::RequestQueueTimeMiddleware::ENV_KEY] }
156
+ ```
157
+
158
+ This will provide proper metric in Datadog and in logs as well. Logs can be transformed into log metrics and used for auto scaling purposes.
159
+
160
+ ## Development
161
+
162
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
163
+
164
+ To install this gem onto your local machine, run `bundle exec rake install`.
165
+
166
+ ## Release
167
+
168
+ All gem releases are manual, in order to create a new release follow:
169
+
170
+ 1. Create new PR (this could be included in feature PR, if it's meant to be released)
171
+ - update `VERSION`, we use [Semantic Versioning](https://semver.org/spec/v2.0.0.html)
172
+ - update `CHANGELOG`
173
+ - merge
174
+ 2. Draft new release via Github Releases
175
+ - use `v#{VERSION}` as a tag, i.e. `v0.1.0`
176
+ - add release notes based on the Changelog
177
+ - create
178
+ 3. Gem will get automatically published to given rubygems server
179
+
180
+ ## Contributing
181
+
182
+ Bug reports and pull requests are welcome on GitHub at https://github.com/stevenharman/puma-plugin-telemetry_too.
183
+
184
+ ## License
185
+
186
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
187
+
188
+ ## Code of Conduct
189
+
190
+ Everyone interacting in the puma-plugin-telemetry_too project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/stevenharman/puma-plugin-telemetry_too/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+ require 'rubocop/rake_task'
6
+
7
+ RSpec::Core::RakeTask.new(:spec)
8
+ RuboCop::RakeTask.new
9
+
10
+ task default: %i[rubocop spec]
Binary file
data/docs/examples.md ADDED
@@ -0,0 +1,163 @@
1
+ ## Keeping track of waiting requests
2
+
3
+ There are requests waiting in 2 places:
4
+ - socket
5
+ - queue
6
+
7
+ Their sum is a total number of accepted requests waiting.
8
+
9
+ Puma configuration
10
+
11
+ ```ruby
12
+ plugin :telemetry
13
+
14
+ Puma::Plugin::TelemetryToo.configure do |config|
15
+ config.enabled = true
16
+ config.initial_delay = 10
17
+
18
+ config.puma_telemetry = %w[queue.backlog]
19
+
20
+ config.socket_telemetry!
21
+
22
+ config.add_target :dogstatsd, client: Datadog::Statsd.new(tags: %w[your tags], namespace: "ruby.puma")
23
+ end
24
+ ```
25
+
26
+ Example Datadog widget and it's configuration. Depending on what you prefer to see, you might replace `rollup(max)` with `rollup(sum)` whenever you want to see maximum value or sum across the aggregated time frame.
27
+
28
+ | :point_up: | Remember to update tags after initial setup! |
29
+ |---------------|:---------------------------------------------|
30
+
31
+ ![Datadog Widget, barchart showcasing sockets & queue backlog sizes stacked up](example-datadog_backlog_size.png "Datadog Widget")
32
+
33
+ ```json
34
+ {
35
+ "viz": "timeseries",
36
+ "requests": [
37
+ {
38
+ "style": {
39
+ "palette": "dog_classic",
40
+ "type": "solid",
41
+ "width": "normal"
42
+ },
43
+ "type": "bars",
44
+ "formulas": [
45
+ {
46
+ "alias": "queue",
47
+ "formula": "query1"
48
+ },
49
+ {
50
+ "alias": "socket",
51
+ "formula": "query2"
52
+ }
53
+ ],
54
+ "response_format": "timeseries",
55
+ "on_right_yaxis": false,
56
+ "queries": [
57
+ {
58
+ "query": "max:ruby.puma.queue.backlog{}.rollup(max)",
59
+ "data_source": "metrics",
60
+ "name": "query1"
61
+ },
62
+ {
63
+ "query": "max:ruby.puma.sockets.backlog{}.rollup(max)",
64
+ "data_source": "metrics",
65
+ "name": "query2"
66
+ }
67
+ ]
68
+ }
69
+ ],
70
+ "yaxis": {
71
+ "include_zero": true,
72
+ "max": "auto",
73
+ "scale": "linear",
74
+ "min": "auto",
75
+ "label": ""
76
+ },
77
+ "markers": []
78
+ }
79
+ ```
80
+
81
+ ## Keeping track of request queue time
82
+
83
+ The time request spent waiting to be processed, between it's accepted by Load Balancer till it starts going through Rack Middleware in your application. Holy grail of autoscaling.
84
+
85
+ Example configuration of middleware, i.e. in case of Rails it could be placed under `config/initializers/request_queue_time.rb`
86
+
87
+ ```ruby
88
+ Rails.application.config.middleware.insert_after(
89
+ 0,
90
+ RequestQueueTimeMiddleware,
91
+ statsd: Datadog::Statsd.new(namespace: "ruby.puma", tags: %w[your tags])
92
+ )
93
+ ```
94
+
95
+ If you are utilizing tags in your logs, you might also want to add this measurement as follows:
96
+
97
+ ```ruby
98
+ Rails.application.config.log_tags ||= {}
99
+ Rails.application.config.log_tags[:queue_time] = ->(req) { req.env[::RequestQueueTimeMiddleware::ENV_KEY] }
100
+ ```
101
+
102
+ Example Datadog widget with configuration.
103
+
104
+ | :point_up: | Remember to update tags after initial setup! |
105
+ |---------------|:---------------------------------------------|
106
+
107
+ ![Datadog Widget, barchart showcasing sockets & queue backlog sizes stacked up](example-datadog_queue_time.png "Datadog Widget")
108
+
109
+ ```json
110
+ {
111
+ "viz": "timeseries",
112
+ "requests": [
113
+ {
114
+ "style": {
115
+ "palette": "dog_classic",
116
+ "type": "solid",
117
+ "width": "normal"
118
+ },
119
+ "type": "line",
120
+ "response_format": "timeseries",
121
+ "queries": [
122
+ {
123
+ "query": "max:ruby.puma.queue.time.max{}",
124
+ "data_source": "metrics",
125
+ "name": "query1"
126
+ },
127
+ {
128
+ "query": "max:ruby.puma.queue.time.95percentile{}",
129
+ "data_source": "metrics",
130
+ "name": "query2"
131
+ },
132
+ {
133
+ "query": "max:ruby.puma.queue.time.median{}",
134
+ "data_source": "metrics",
135
+ "name": "query3"
136
+ }
137
+ ],
138
+ "formulas": [
139
+ {
140
+ "alias": "max",
141
+ "formula": "query1"
142
+ },
143
+ {
144
+ "alias": "p95",
145
+ "formula": "query2"
146
+ },
147
+ {
148
+ "alias": "median",
149
+ "formula": "query3"
150
+ }
151
+ ]
152
+ }
153
+ ],
154
+ "yaxis": {
155
+ "include_zero": true,
156
+ "max": "auto",
157
+ "scale": "linear",
158
+ "min": "auto",
159
+ "label": ""
160
+ },
161
+ "markers": []
162
+ }
163
+ ```