krojew / tracing-elastic-apm

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Formatting Incorrect in apm

kmyers608 opened this issue · comments

I am currently using layers in my subscriber from this crate and fmt::Layer::default(). But noticed that the transactions only show on elastic apm as "HTTP Request" rather than something like "POST /route", additionally there is no http meta data shown on the transaction. Do I need to add another layer to format the trace correctly for apm? If so, what layer should I be including?

It is possible to attach metadata to APM, but at the moment, there's no way to pass that metadata to the layer through tracing.

What would need to be change to support sending metadata? I would be willing to open another PR if you could point me in the right direction.

There are several ways to do it. The proper way would be to add arbitrary structured data in tracing for https://docs.rs/tracing/0.1.26/tracing/field/trait.Visit.html. A workaround would be to pass everything as strings via some predefined attribute names. This is a hack and doesn't scale well. In your case, you would need to somehow pass https://github.com/krojew/tracing-elastic-apm/blob/master/src/model.rs#L205 into tracing.

Thank you I will look into that when I get some time and close this since the issue is outside the scope of this crate