What do folks think of making the output function used by ConsoleSpanExporter.export customizable? Currently it uses print(span) but there are situations where a user may want to perform a transform on span before outputting it, or to output another data structure entirely.
To be more concrete, we currently have downstream infrastructure that requires our telemetry data to be in a specific dictionary format when written to stdout. We'd like to still use the ConsoleSpanExporter to write to stdout, but need to convert the span to our dict object before doing so.
Currently we are addressing this by writing a custom exporter class that inherits from SpanExporter and writes our custom data to stdout in its export method. Another solution though would be to allow ConsoleSpanExporter to take a keyword argument to its __init__ method that would default to print but would also allow custom output functions. It would then use the passed function in ConsoleSpanExporter.export to output to stdout.
Do folks see any value in adding this functionality here, rather than requiring users who want to do custom console output to write their own exporter classes? Also happy to write up the proposed solution as a PR if folks think that would be helpful.
What do folks think of making the output function used by
ConsoleSpanExporter.exportcustomizable? Currently it usesprint(span)but there are situations where a user may want to perform a transform onspanbefore outputting it, or to output another data structure entirely.To be more concrete, we currently have downstream infrastructure that requires our telemetry data to be in a specific dictionary format when written to stdout. We'd like to still use the
ConsoleSpanExporterto write to stdout, but need to convert thespanto ourdictobject before doing so.Currently we are addressing this by writing a custom exporter class that inherits from
SpanExporterand writes our custom data to stdout in itsexportmethod. Another solution though would be to allowConsoleSpanExporterto take a keyword argument to its__init__method that would default toprintbut would also allow custom output functions. It would then use the passed function inConsoleSpanExporter.exportto output to stdout.Do folks see any value in adding this functionality here, rather than requiring users who want to do custom console output to write their own exporter classes? Also happy to write up the proposed solution as a PR if folks think that would be helpful.