-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
feat: tracing add custom report err func #3370
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
base: main
Are you sure you want to change the base?
Conversation
middleware/tracing/tracing.go
Outdated
| type Option func(*options) | ||
|
|
||
| // ReportErrHandle report err func handler | ||
| type ReportErrHandle func(ctx context.Context, span trace.Span, err error) |
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.
ReportErrHandle -> ReportErrorHandle
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.
已修改
shenqidebaozi
left a comment
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.
LGTM
Pull request was converted to draft
aed7a79
|
@lawlielt I think |
| } | ||
|
|
||
| // WithReportErrorHandle with custom report err func | ||
| func WithReportErrorHandle(f ReportErrorHandle) Option { |
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.
WithErrorHandler
| type Option func(*options) | ||
|
|
||
| // ReportErrorHandle report err func handler | ||
| type ReportErrorHandle func(ctx context.Context, span trace.Span, err error) |
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.
ErrorHandler
Description (what this PR does / why we need it):
By default, when an error occurs, the following action is taken:
The exception.type in RecordError is the type of the error, which doesn't contain much information. To collect more details, we can customize the action and add new attributes.
Here is an example of how to customize error handling and collect more information:
By doing this, we can collect and record more detailed error information, which helps in better monitoring and debugging of the application.
Which issue(s) this PR fixes (resolves / be part of):
Other special notes for the reviewers:
the default grpc error code in opentelmetry library is
rpc.grpc.status_codenotrpc.status_code, we can use the custom method to compatible that