Closed maniax89 closed 3 years ago
logger.info(metric: 'foo')
is referred to a "metrics only" log event. By design these metrics are not output to human readable text output destinations. For example they are written to the JSON output appender, which is how we forward these metrics only events to Splunk.
All of the built-in destinations are documented: https://rocketjob.github.io/semantic_logger/appenders.html Of course, you can create your own appender for any other destination that you want to send events/metrics to.
The most complete metrics only appender currently implemented is for Signalfx since it supports metrics as well as dimensions. It ignores all log events that do not have metrics.
I guess my question is whether or not I can take the existing log subscribers for the action controller that get monkey patched in this library and somehow hook into them and intercept the info/error to add additional information in order to trigger a metric subscriber to fire as well
Using named tags will add any additional data to the action controller log messages. For example:
config.log_tags = {
request_id: :request_id,
ip: :remote_ip,
user: -> request { request.cookie_jar['login'] }
}
Rails also has a built-in mechanism to add custom data to its payload from any controller by implementing append_info_to_payload
. For an example, look for Adding custom data to the Rails Completed log message
: https://rocketjob.github.io/semantic_logger/rails.html
Environment
Provide at least:
Expected Behavior
metrics:
key is provided on thelogger.info
orlogger.error
calls. I can see it working when I do something likelogger.info(metric: 'foo')
but I don't see it happening for any of the ActionController log messages even after I configured a custom formatter (which I believe happens after the events are triggered, which makes sense)