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

Fix span tagging for application error in GO YARPC/gRPC #2287

Open
wants to merge 9 commits into
base: dev
Choose a base branch
from

Conversation

kexiongliu123
Copy link

Fix span tagging for application error in GO YARPC/gRPC

  • In https://github.com/yarpc/yarpc-go/pull/2282/files we captured invokeErr
  • In addition to the invokeErr, in this PR we also emit application errors to span tags
  • The error message is intentionally omitted to prevent exposing personally identifiable information (PII) in tracing systems.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

api/transport/propagation.go Outdated Show resolved Hide resolved
api/transport/propagation.go Outdated Show resolved Hide resolved
api/transport/propagation.go Show resolved Hide resolved
api/transport/propagation.go Show resolved Hide resolved
internal/observability/call.go Outdated Show resolved Hide resolved
internal/observability/call.go Outdated Show resolved Hide resolved
internal/observability/call.go Outdated Show resolved Hide resolved
@@ -496,6 +499,17 @@ func (c call) logStreamEvent(err error, success bool, succMsg, errMsg string, ex
ce.Write(fields...)
}

// emitSpanErrorTag sets the error information as tags on the current span
func (c call) emitSpanErrorTag(res callResult) {
if span := opentracing.SpanFromContext(c.ctx); span != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

My concern of using obs middleware is that the required inbound/ outbound spans are not available in go context when you are trying to obtain spans here.

Could you double check?

Copy link
Author

Choose a reason for hiding this comment

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

After reviewing the code more thoroughly, I believe you're right. It doesn’t seem straightforward to pass the original spans here. Do you have any suggestions on how we might approach this?

@@ -23,6 +23,7 @@ package observability
import (
"context"
"fmt"
"github.com/opentracing/opentracing-go"
Copy link
Collaborator

Choose a reason for hiding this comment

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

All such imports should be sorted, thx.

// The error message is intentionally omitted to prevent exposing
// personally identifiable information (PII) in tracing systems.
// Returns the given error
func UpdateSpanWithApplicationErr(span opentracing.Span, err error, errCode yarpcerrors.Code) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please return err from this func.

// emitSpanApplicationErrTag sets the application error information as tags on the current span
func (c call) emitSpanApplicationErrTag(res callResult) {
// Check if application error is applicable first
if !res.isApplicationError {
Copy link
Collaborator

Choose a reason for hiding this comment

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

My question was left unanswered: seems like span will have tags already (from this changes: https://github.com/yarpc/yarpc-go/pull/2282/files#diff-2c03b550b54bc0459d694d1aa8ae408c392280ff11932ff44e0be1654eeb6a4eR233).

So do we need this func at all?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

5 participants