Custom context for set_custom_context
How can I send an error message without exception, but with additional information?
ElasticAPM.report - sends error data
ElasticAPM.report_message - just sends text
I would like to send a message in which there is no Exception but at the same time there is another meaningful load, the user's name, data about the model with which he worked, etc. those.
ElasticAPM.set_custom_context fails to set for ElasticAPM.report_message
Here it is done in sentry https://docs.sentry.io/clients/ruby/context/
I think this might be a bug. Let me investigate a bit – thanks for reporting.
@mikker
I checked (ElasticAPM.report_message("dsds") ) the work separately ElasticAPM.report_message, when I call in the application, I get an error error json ### Problem validating JSON document against schema: I [#] S [#] does not validate with \ "error # " \ n https://pastebin.com/A8zHNMNr
Run through the console console is successful.
I think we need a with_custom_context method for this. If we are outside transactions, we have no way to store the context nor define when the custom context from set_custom_context should be un-set.
Would that solve your use case?
ElasticAPM.with_custom_context my_thing: 'something' do
begin
explode
rescue Exception => e
ElasticAPM.report e # will have custom: { my_thing: 'something' }
end
end