docbrown/lib/instrumentation.rb
Christine Yen cff6b5d589 Add Honeycomb gem and initial instrumentation (#695)
* Add basic Honeycomb initializers

* Add some basic instrumentation, capture basic IDs

* Correctly alphabetize Gemfile, embed env in dataset names

* Actually reorder Gemfile because I can read

* Add custom tracing instrumentation to RssReader

* Improve timing/tracing info in RssReader

* Even make sure Errors show up in trace if possible

* Make sure we capture this as Rails traffic

* Swap in dev/test Libhoney::Clients as appropriate

* Move context-snagging bits into lib/instrumentation.rb

* Merging Gemfile lines seems to be my Achilles heel
2018-11-28 10:08:27 -05:00

20 lines
532 B
Ruby

module Instrumentation
def add_param_context(*keys)
keys.each do |key|
honeycomb_metadata[key] = params[key]
end
end
def add_context(metadata)
metadata.each do |key, value|
honeycomb_metadata[key] = value
end
end
def append_to_honeycomb(request, controller_name)
honeycomb_metadata["trace.trace_id"] = request.request_id
honeycomb_metadata["trace.span_id"] = request.request_id
honeycomb_metadata[:service_name] = "rails"
honeycomb_metadata[:name] = controller_name
end
end