Skip to content

[Part0] Support Activity Status and status description in Console Exporter.#3061

Merged
cijothomas merged 9 commits into
open-telemetry:mainfrom
Yun-Ting:yunl/ActivityStatusConsole
Mar 17, 2022
Merged

[Part0] Support Activity Status and status description in Console Exporter.#3061
cijothomas merged 9 commits into
open-telemetry:mainfrom
Yun-Ting:yunl/ActivityStatusConsole

Conversation

@Yun-Ting

@Yun-Ting Yun-Ting commented Mar 16, 2022

Copy link
Copy Markdown
Contributor

Related to #2569.

Changes

Added support to to set status with Activity.Status, which was introduced in System.Diagnostic.DiagnosticSource 6.0.0 to ConsoleExporter.
The same idea will be applied to other exporters.

Case 1:
Setting activity status to be OK.
activity.SetStatus(ActivityStatusCode.Ok);
Output:
StatusCode : OK

Case 2:
Setting activity status to be ERROR with description.
activity.SetStatus(ActivityStatusCode.Error, "desc");
Output:

StatusCode : ERROR
Error : desc

Case 3:
Setting activity tag to be OK.
activity.SetTag("otel.status_code", "OK");
Output:

Activity.Tags:
   StatusCode : OK

Case 4:
Setting activity tag to be ERROR with description.

activity.SetTag("otel.status_code", "ERROR");
activity.SetTag("otel.status_description", "desc");

Output:

Activity.Tags:
   StatusCode : ERROR
   Error : desc

Case 5:
Activity status take precedence over activity tag when both were set.

activity.SetStatus(ActivityStatusCode.Ok);
activity.SetTag("otel.status_code", "ERROR");
activity.SetTag("otel.status_description", "desc");

Output:

Activity.Tags:
StatusCode : OK

Case 6:
Activity status take precedence over activity tag when both were set.

activity.SetStatus(ActivityStatusCode.Error, "desc");
activity.SetTag("otel.status_code", "OK");

Output:

Activity.Tags:
StatusCode : ERROR
Error : desc

For significant contributions please make sure you have completed the following items:

  • Appropriate CHANGELOG.md updated for non-trivial changes
  • Design discussion issue #
  • Changes in public API reviewed

@Yun-Ting Yun-Ting marked this pull request as ready for review March 17, 2022 00:00
@Yun-Ting Yun-Ting requested a review from a team March 17, 2022 00:00
@codecov

codecov Bot commented Mar 17, 2022

Copy link
Copy Markdown

Codecov Report

Merging #3061 (21f8eec) into main (b6169aa) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #3061   +/-   ##
=======================================
  Coverage   84.70%   84.70%           
=======================================
  Files         259      259           
  Lines        9119     9119           
=======================================
  Hits         7724     7724           
  Misses       1395     1395           

Comment thread src/OpenTelemetry.Exporter.Console/ConsoleActivityExporter.cs Outdated
Comment thread src/OpenTelemetry.Exporter.Console/ConsoleActivityExporter.cs Outdated
Comment thread src/OpenTelemetry.Exporter.Console/ConsoleActivityExporter.cs
Comment thread src/OpenTelemetry.Exporter.Console/ConsoleActivityExporter.cs Outdated
if (!string.IsNullOrEmpty(activity.StatusDescription))
{
this.WriteLine($" StatusCode : {statusCode}");
this.WriteLine($"Error : {activity.StatusDescription}");

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.

Remove "Error". Just Status Description is good enough here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Maybe something like:
this.WriteLine($"Status Description : {activity.StatusDescription}");
?

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.

yes

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@cijothomas cijothomas 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.

nit comment. may be addressed separate

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