Skip to content

add a LogErrToSpan #159

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

Merged
merged 1 commit into from
Aug 24, 2020
Merged

add a LogErrToSpan #159

merged 1 commit into from
Aug 24, 2020

Conversation

rybit
Copy link
Member

@rybit rybit commented Aug 20, 2020

This method is used in a few services and it is pretty useful. I think that it makes sense to import here. Also, anything to make opentracing more usable I'm all for

@rybit rybit marked this pull request as ready for review August 20, 2020 23:09
@rybit rybit requested review from a team, mheffner and phenixrizen August 20, 2020 23:09
@rybit rybit force-pushed the add-useful-tracing-func branch from 8279d9c to 8b6baf2 Compare August 20, 2020 23:10
@emilyzhang emilyzhang added the type: feature code contributing to the implementation of a feature and/or user facing functionality label Aug 20, 2020
}

span.LogFields(otlog.String("event", "error"), otlog.Error(err))
if sterr, ok := err.(stackTracer); ok {
Copy link
Contributor

@emilyzhang emilyzhang Aug 20, 2020

Choose a reason for hiding this comment

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

out of curiosity what is happening here? O: it looks like you're checking to see whether you can create a new instance of the stacktracer interface from the error? (i've just never seen this err.(stackTracer) notation before)

Copy link
Member Author

Choose a reason for hiding this comment

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

The general format is that you can do:

actualVersion, ifItMatches := someinterface.(whatYouWant)

This is using go's type inference to figure out if the error (which is an interface) passed in has that method.

Copy link
Contributor

@mheffner mheffner left a comment

Choose a reason for hiding this comment

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

💯

@rybit rybit merged commit bd71136 into master Aug 24, 2020
@rybit rybit deleted the add-useful-tracing-func branch August 24, 2020 19:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature code contributing to the implementation of a feature and/or user facing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants