Skip to content

ConsoleLogRecordExporter modified to support Message and StateValues#1871

Merged
cijothomas merged 4 commits into
mainfrom
cijothomas/consolelogexporter
Mar 8, 2021
Merged

ConsoleLogRecordExporter modified to support Message and StateValues#1871
cijothomas merged 4 commits into
mainfrom
cijothomas/consolelogexporter

Conversation

@cijothomas

Copy link
Copy Markdown
Member

#1869 expanded LogRecord to have formatted message and higher-perf StateValues.
This PR is modifying ConsoleExporter to support these additional fields.

When right options are enabled, the following output is produced.
image

@cijothomas cijothomas requested a review from a team March 6, 2021 15:56
@codecov

codecov Bot commented Mar 6, 2021

Copy link
Copy Markdown

Codecov Report

Merging #1871 (128a792) into main (cb066cb) will decrease coverage by 0.45%.
The diff coverage is 78.36%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1871      +/-   ##
==========================================
- Coverage   83.77%   83.32%   -0.46%     
==========================================
  Files         187      189       +2     
  Lines        5967     6123     +156     
==========================================
+ Hits         4999     5102     +103     
- Misses        968     1021      +53     
Impacted Files Coverage Δ
src/OpenTelemetry/Logs/OpenTelemetryLogger.cs 26.82% <20.54%> (-44.60%) ⬇️
src/OpenTelemetry/Logs/LogRecord.cs 82.50% <77.77%> (-5.00%) ⬇️
.../OpenTelemetry/Logs/OpenTelemetryLoggerProvider.cs 77.55% <88.23%> (+7.09%) ⬆️
...rc/OpenTelemetry/Trace/TracerProviderBuilderSdk.cs 88.46% <88.88%> (-2.28%) ⬇️
src/OpenTelemetry/Trace/ExceptionProcessor.cs 90.90% <90.90%> (ø)
src/OpenTelemetry/Trace/TracerProviderSdk.cs 95.16% <98.64%> (+4.38%) ⬆️
...metryProtocol/Implementation/ActivityExtensions.cs 86.89% <100.00%> (+0.05%) ⬆️
...ry.Instrumentation.AspNet/AspNetInstrumentation.cs 100.00% <100.00%> (ø)
...umentation.AspNet/Implementation/HttpInListener.cs 89.10% <100.00%> (ø)
...entation.AspNet/TracerProviderBuilderExtensions.cs 100.00% <100.00%> (ø)
... and 24 more

this.WriteLine($"{"LogRecord.State:".PadRight(rightPaddingLength)}{logRecord.State}");
if (logRecord.Message != null)
{
this.WriteLine($"{"LogRecord.Message:".PadRight(rightPaddingLength)}{logRecord.Message}");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, I am wondering if we could output a markdown table, similar like what Benchmark.Net did?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let me try to get that! would make the getting-started readme looks nicer.

@reyang reyang left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

this.WriteLine("LogRecord.StateValues (Key:Value):");
for (int i = 0; i < logRecord.StateValues.Count; i++)
{
this.WriteLine($"{logRecord.StateValues[i].Key.PadRight(rightPaddingLength)}:{logRecord.StateValues[i].Value}");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This padding would leave : on the right, a bit weird.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can see it in the picture in the description, it does look a bit odd.

@CodeBlanch CodeBlanch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cijothomas cijothomas merged commit f252428 into main Mar 8, 2021
@cijothomas cijothomas deleted the cijothomas/consolelogexporter branch March 8, 2021 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants