opencensus-erlang icon indicating copy to clipboard operation
opencensus-erlang copied to clipboard

Logs

Open deadtrickster opened this issue 6 years ago • 5 comments

This was asked on Gitter and I decided to describe how we do this and start discussion of possible directions.

We

  • use lager;
  • mainly use ocp;
  • log with tags - here a simple macro wrapper was needed so the tags context doesn't pollute logging code. Tags are prepended to the original log message;
  • log spans to a special lager sink. This means we can manage this stream independently from defaults. We log spans when they created iff "log" attribute is present. At first we logged spans in a special reporter but decided to use macros again and log synchronously;

I'm ok with lager (esp sinks) and would like to have logging here directly:

{lager_extra_sinks, [oc_log]}
  • oc_log:/1,2,3 - just like lager:level but prepends tags (can be filtered I guess);
  • something for logging spans :-), perhaps hook to oc_trace:start_span/finish_span.

deadtrickster avatar Apr 01 '18 10:04 deadtrickster

From slack - @tsloughter: "I've been wanting to add docs about tags use with lager metadata".

deadtrickster avatar Apr 02 '18 11:04 deadtrickster

Here's the lager docs on what I was thinking of https://github.com/erlang-lager/lager/#setting-dynamic-metadata-at-compile-time

tsloughter avatar Apr 02 '18 18:04 tsloughter

Investigating this more, and not wanting to require lager, I think the best option is to wait for the new OTP logger and use it to set the metadata when a span is created. Hopefully this will be OTP 21.

tsloughter avatar May 01 '18 14:05 tsloughter

Just to update this thread, now on OTP-21 the logger metadata will be set to include the trace and span ids.

Next I'll add information to the readme at least about how to use them in logger's default formatter.

tsloughter avatar Jun 10 '18 21:06 tsloughter

I think we can close it now as support for that landed via supporting OTP 21 logger.

hauleth avatar Dec 07 '18 13:12 hauleth