Skip to content
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

[Instrumentation.GrpcCore] Record exceptions as activity events flag #1648

Merged
merged 23 commits into from
May 17, 2024

Conversation

IliaBrahinets
Copy link
Member

@IliaBrahinets IliaBrahinets commented Apr 12, 2024

Changes

RecordException flag has been added in both ServerTracingInterceptorOptions and ClientTracingInterceptorOptions. When set to true exceptions are recored as activity events.

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

@IliaBrahinets IliaBrahinets requested a review from a team April 12, 2024 22:57
Copy link

linux-foundation-easycla bot commented Apr 12, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

Copy link

codecov bot commented Apr 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.17%. Comparing base (71655ce) to head (0d3464a).
Report is 251 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1648      +/-   ##
==========================================
+ Coverage   73.91%   80.17%   +6.25%     
==========================================
  Files         267      116     -151     
  Lines        9615     3077    -6538     
==========================================
- Hits         7107     2467    -4640     
+ Misses       2508      610    -1898     
Flag Coverage Δ
unittests-Solution 80.17% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

see 257 files with indirect coverage changes

@Kielek Kielek added the comp:instrumentation.grpccore Things related to OpenTelemetry.Instrumentation.GrpcCore label Apr 19, 2024
@IliaBrahinets
Copy link
Member Author

@cijothomas , @Kielek I've made suggested changes. Ready for another review

@Kielek Kielek requested a review from cijothomas April 24, 2024 16:19
Copy link
Contributor

@Kielek Kielek left a comment

Choose a reason for hiding this comment

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

@cijothomas, based on https://github.com/open-telemetry/semantic-conventions/blob/main/docs/exceptions/exceptions-spans.md

I would say that when possible exception should be always recorded as events. Do we really need the option to enable it? I would consider adding possibility to opt-out. To met the spec, it should be enabled by default.

@IliaBrahinets, please do not change the code based on this comment. We need to find agreement here, it should probably impact more packages than only this one.

Comment on lines +25 to +30

// https://github.com/open-telemetry/semantic-conventions/blob/main/docs/exceptions/exceptions-spans.md
internal const string AttributeExceptionEventName = "exception";
internal const string AttributeExceptionType = "exception.type";
internal const string AttributeExceptionMessage = "exception.message";
internal const string AttributeExceptionStacktrace = "exception.stacktrace";
Copy link
Contributor

Choose a reason for hiding this comment

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

All this const are used only in tests file. I am not sure if it worth to put it into production code.

Copy link
Member Author

Choose a reason for hiding this comment

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

Then existing AttributeActivityIdentifier const should be also taken into account. I think it is simpler to manage all semantic convetions from one place within a library (including tests). Libraries which use Shared/SemanticConventions.cs include many unused consts. BTW probably it is worth to migrate OpenTelemetry.Instrumentation.GrpcCore to Shared/SemanticConventions.cs. though it lacks "otel.status_code" and "otel.status_description" attributes.

Copy link
Contributor

Choose a reason for hiding this comment

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

Any references to otel.status_code and otel.status_descrription should be removed from instrumentation libraries.
It should be responsibility of exporter to map it correctly. If these are still used in production code, it is just leftover from open-telemetry/opentelemetry-dotnet#2569

Copy link
Member Author

Choose a reason for hiding this comment

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

Turns out that otel.status_code and otel.status_descrription are used in tests only. As the result of the discussion:

  • otel.status_code and otel.status_description should be replaced by Activity.Status and Activity.StatusDescription in tests
  • Use Shared/SemanticConventions.cs in OpenTelemetry.Instrumentation.GrpcCore

I would like to submit another PR for the suggested changes, @Kielek what do you think ?

Copy link
Contributor

Choose a reason for hiding this comment

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

PRs are more than welcomed :)

src/OpenTelemetry.Instrumentation.GrpcCore/CHANGELOG.md Outdated Show resolved Hide resolved
@cijothomas
Copy link
Member

@cijothomas, based on https://github.com/open-telemetry/semantic-conventions/blob/main/docs/exceptions/exceptions-spans.md

I would say that when possible exception should be always recorded as events. Do we really need the option to enable it? I would consider adding possibility to opt-out. To met the spec, it should be enabled by default.

@IliaBrahinets, please do not change the code based on this comment. We need to find agreement here, it should probably impact more packages than only this one.

I think it should be off by default, and controlled via an option.

  1. Exceptions are expensive (string allocations, and the cost of obtaining stack etc.).
  2. Exceptions could contain sensitive/pii things. (in the message usually, that is included when ToString() is invoked)
  3. It is possible that the exception is already reported using other mechanism (like ILogger), so this could be just undesired duplicate information.
  4. All existing instrumentation in the main repo/this repo offer this option already and they are all opt-in.
  5. We have seen folks asking for on/off flag for ActivityEvent in general before. One example is here.

Copy link
Contributor

@Kielek Kielek left a comment

Choose a reason for hiding this comment

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

LGTM.

@IliaBrahinets, please resolve conflicts. It is related to moving publicAPI file to the parent folder. Ref: #1711

@pcwiese, it will be great if you can review

@IliaBrahinets
Copy link
Member Author

LGTM.

@IliaBrahinets, please resolve conflicts. It is related to moving publicAPI file to the parent folder. Ref: #1711

@pcwiese, it will be great if you can review

The conflicts have been resolved.

@cijothomas cijothomas merged commit 30f5fd1 into open-telemetry:main May 17, 2024
39 checks passed
@IliaBrahinets IliaBrahinets deleted the record-exceptions-option branch May 17, 2024 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:instrumentation.grpccore Things related to OpenTelemetry.Instrumentation.GrpcCore
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants