Draft
Conversation
Making the formatter available outside the IOTarget means other targets can also use it. This will be helpful when I add a LogTarget. This also adds some very basic tests (for my own sanity) for the IOTarget and JSONFormatter classes.
As it was, the formatters were doing both transforms on the keys (specific to a particular service) AND formatting the telemetry data. By separating those responsibilities, we can mix and match different Targets, Formatters, and Transforms to get the output needed for different consumers.
These are useful for custom targets that might not need/want any transforms for formatting, or to mix-and-match. For example, image a custom `LogTarget` that can be configured with a `:logger` option. It could be that the logger itself already knows how to format they telemetry data, (e.g., into key/value pairs), and so we don't want/need the Target to do any formatting. This allows this plugin's config to look like this: ```ruby Puma::Plugin::Telemetry.configure do |config| config.add_target(CustomLogTarget, logger: Logfmt.logger, transform: :cloud_watch, formatter: :noop) end ```
Which defaults to the `:json` formatter with a `:passthrough` transform. For now…
This is also the default `formatter:` of the new LogTarget.
It will pull from the ENV `L2MET_SOURCE` and then `DYNO`, falling back to building a string based on the current Host name and executing program name.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is the 3rd PR in a series of PRs (see #25 and #26) to expose a mechanism for folks to build their own targets, formatters, and transforms.
This PR adds at the L2Met transform. This is particularly useful for folks running on Heroku. Once #25 and #26 are merged, I'll rebase this atop them, leaving only the L2Met-related commits.