beam-telemetry/telemetry_metrics

Augmenting telemetry metrics metadata with process information

josevalim opened this issue · 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.

automatically adds it to the metric

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

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.

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.