Fix using SemanticLogger#log(severity, message, progname) #2748
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.
SemanticLogger
provides interface which is fully compatible withLogger
interfaceIt is possible to use
SemanticLogger#add
andSemanticLogger#log
instance methods onSemanticLogger
as it would be just plainLogger
Datadog instrumentation doesn't expect that first argument in method
#log
might be notSemanticLogger::Log
but severity level likeLogger::WARN
as result fails with errorNoMethodError: undefined method 'named_tags' for 2:Integer
.Originally met issue in Rails project, here is specs:
When have configuration for datadog:
When have enabled
:rails' instrumentation, ':semantic_logger
added right away as there isSemanticLogger
on project.Real case scenario is that on project there might be some external gems that may allow to provide logger as part of it's configuration, but may work with logger as it's plain ruby's
Logger
and use#add
or#log
methods.In case of using
#log
it causes failure because instrumentation prepended and there is no safeguard on first argumentlog
Example to reproduce having rails with setup
datadog
to instrumentrails
andsemantic_logger
installed: