telemetry_metrics icon indicating copy to clipboard operation
telemetry_metrics copied to clipboard

Augmenting telemetry metrics metadata with process information

Open josevalim opened this issue 5 years ago • 5 comments

Sometimes people may want to send their metrics based on some parameter that is external to the metric. For example, multi-tenant applications may want to segregate their data in someway.

Generally speaking, the way to do this is by attaching some metadata in the process dictionary. We could do our own book keeping on telemetry but maybe the simplest approach is to have something like :logger_metadata that retrieves the data from Erlang's logger and automatically adds it to the metric?

I am not sure this is the best way to go (especially because it is not decided yet if Elixir will merge its metadata with Erlang's) but I thought I would open this up for discussion.

josevalim avatar Mar 14 '19 15:03 josevalim

automatically adds it to the metric

Do you mean adding it to the set of avaialble tags, i.e. merging it with event metadata?

arkgil avatar Mar 15 '19 09:03 arkgil

Yes, something like logger_tags maybe?

José Valimwww.plataformatec.com.br http://www.plataformatec.com.br/Founder and Director of R&D

josevalim avatar Mar 15 '19 09:03 josevalim

I'm only wondering what happens if the same key is found in both event metadata and logger_tags - which one should tak precedence? IMO logger_tags should override metadata, because if we want to rely on the procdict, we usually also control it, so we can always rename the key so that there are no conflicts.

arkgil avatar Mar 15 '19 10:03 arkgil

Agreed. But yeah, I would wait a bit until we unify logging metadata in the Elixir front too.

José Valimwww.plataformatec.com.br http://www.plataformatec.com.br/Founder and Director of R&D

josevalim avatar Mar 15 '19 10:03 josevalim

Hm, I've considered using logger metadata for opencensus tags, maybe we should. I think the main reason to not was that span context doesn't fit well in logger metadata. We set logger metadata for each span context but formatted to what you'd expect in logs, not the actual span context record which has integers not strings. So we are messing with the pdict anyway. But for tags it may make sense to just use logger metadata, especially if telemetry_metrics will want to grab from there.

tsloughter avatar Apr 23 '19 15:04 tsloughter