wingtips
wingtips copied to clipboard
Allow full control over log output format
Users might want to fully control the log message output of distributed traces. To allow for this, SpanLoggingRepresentation should be refactored to an interface (with the existing JSON and KEY_VALUE enums continuing as available options people can use). Then Tracer.completeAndLogSpan() should be refactored to delegate the log message to the interface so that users can fully define the log message and format themselves if desired.
One possible solution:
- Rename
SpanLoggingRepresentationinto an interface namedSpanLoggingStrategy. - The
SpanLoggingStrategyinterface should have a single method:SpanLoggingStrategy.logCompletedSpan(Span completedSpan, Logger loggerToUse, String infoTag). -
Tracer.completeAndLogSpan()should delegate to whateverSpanLoggingStrategyis registered with it by replacing theloggerToUse.info(...)line with the newSpanLoggingStrategymethod call. - Migrate the existing
JSONandKEY_VALUESpanLoggingRepresentationenum values to a different enum namedDefaultSpanLoggingStrategyOptionsthat implementsSpanLoggingStrategyand results in the same log messages we see with the current code.