Log context conversion to tags #539
Description
In some languages log context is available (e.g. Java and .NET). Think of it as a Hashmap / Dictionary where you can store values which will then be printed with every emitted log entry.
In Java this is called MDC (Mapped Diagnostic Context). Here are some examples:
- https://www.slf4j.org/manual.html#mdc
- https://logback.qos.ch/manual/mdc.html
- https://logging.apache.org/log4j/2.x/manual/thread-context.html
Users have asked for context entries to be converted to Sentry tags (getsentry/sentry-java#1148 and getsentry/sentry-java#1054). This feature only existed in our .NET SDK. The config option there allows users to enable / disable the feature completely, but no fine grained control over which entries are converted to tags.
For Java we went with a bit more control over which entries will be picked up automatically from the MDC by adding a new config option called contextTags
which can have a list of log context entry names (which have to match exactly, no glob / regex / similar for now). See this PR (getsentry/sentry-java#1954) for more detail.
Our idea for future improvement on this feature (if needed) was to support globs in addition to exact entry names, e.g. myPrefix.*
to automatically convert all entries starting with myPrefix.
as Sentry tags. We can then also use this to have a convention of automatically converting all entries starting with sentry.tag.
by making the default ["sentry.tag.*"]
. This convention was also part of the old Java SDK (1.x) [TODO link].
When something similar is implemented, the default should be to not create too many tags automatically as they come at a cost.