-
Notifications
You must be signed in to change notification settings - Fork 651
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sdk: fix ConsoleSpanExporter #455
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -270,12 +270,14 @@ class ConsoleSpanExporter(SpanExporter): | |||||
def __init__( | ||||||
self, | ||||||
out: typing.IO = sys.stdout, | ||||||
formatter: typing.Callable[[Span], str] = str, | ||||||
formatter: typing.Callable[[Span], str] = lambda span: str(span) | ||||||
+ "\n", | ||||||
): | ||||||
self.out = out | ||||||
self.formatter = formatter | ||||||
|
||||||
def export(self, spans: typing.Sequence[Span]) -> SpanExportResult: | ||||||
for span in spans: | ||||||
self.out.write(self.formatter(span)) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider doing this to avoid two linebreaks for formatters that do end in a newline:
Suggested change
with this in the module: def endline(line):
if line.endswith(os.linesep):
return line
return line + os.linesep I haven't checked for windows, but suspect you do want There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not totally sure about this one, I think we should let full control to the user, for instance, there could be a case where the user doesn't want to have line breaks at all and use another separator. I totally agree about the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Btw, if a formatter ends with a linebreak there would not be two linebreaks, I only adding a linebreak to the default formatter. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think agreed to not force lineseps, formatter should control that (and the flush handles this anyway). |
||||||
self.out.flush() | ||||||
return SpanExportResult.SUCCESS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Along with the other comment suggestion only.