Skip to content

Commit

Permalink
[Part0] Support Activity Status and status description in Console Exp…
Browse files Browse the repository at this point in the history
…orter. (#3061)
  • Loading branch information
Yun-Ting authored Mar 17, 2022
1 parent b6169aa commit a1e7167
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
6 changes: 4 additions & 2 deletions src/OpenTelemetry.Exporter.Console/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

## Unreleased

Added StatusCode, StatusDescription support to
`ConsoleActivityExporter`.
* Added StatusCode, StatusDescription support to
`ConsoleActivityExporter`.
([#2929](https://github.com/open-telemetry/opentelemetry-dotnet/pull/2929)
[#3061](https://github.com/open-telemetry/opentelemetry-dotnet/pull/3061))

## 1.2.0-rc3

Expand Down
19 changes: 12 additions & 7 deletions src/OpenTelemetry.Exporter.Console/ConsoleActivityExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,25 +71,30 @@ public override ExportResult Export(in Batch<Activity> batch)
continue;
}

var array = tag.Value as Array;

if (array == null)
if (tag.Value is not Array array)
{
this.WriteLine($" {tag.Key}: {tag.Value}");
continue;
}

this.WriteLine($" {tag.Key}: [{string.Join(", ", array.Cast<object>())}]");
}
}

if (!string.IsNullOrEmpty(statusCode))
if (activity.Status != ActivityStatusCode.Unset)
{
this.WriteLine($"StatusCode : {activity.Status}");
if (!string.IsNullOrEmpty(activity.StatusDescription))
{
this.WriteLine($" StatusCode : {statusCode}");
this.WriteLine($"Error : {activity.StatusDescription}");
}

}
else if (!string.IsNullOrEmpty(statusCode))
{
this.WriteLine($" StatusCode : {statusCode}");
if (!string.IsNullOrEmpty(statusDesc))
{
this.WriteLine($" StatusDescription : {statusDesc}");
this.WriteLine($" Error : {statusDesc}");
}
}

Expand Down

0 comments on commit a1e7167

Please sign in to comment.