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

contrib/google.golang.org/grpc: Fix adding errors to spans and traces #396

Merged
merged 1 commit into from
Feb 19, 2019
Merged

contrib/google.golang.org/grpc: Fix adding errors to spans and traces #396

merged 1 commit into from
Feb 19, 2019

Conversation

mrVanboy
Copy link
Contributor

  • Put finishWithError calls inside closure functions because the deferred
    function's arguments are evaluated when the defer statement is
    evaluated. More at https://golang.org/doc/effective_go.html#defer
    Before this commit, finishWithError deferred with nil error (initial value)
    and any other changes of the initial value were not added to span. This bug
    affects only grpc streaming.
  • Clean tagCode in case of disregarded error.
  • Add tests for checking if span contains error.

Copy link
Contributor

@gbbr gbbr left a comment

Choose a reason for hiding this comment

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

Great! Thanks a lot for this. Left one comment.

}
sid := span.SpanID()
Copy link
Contributor

Choose a reason for hiding this comment

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

Forgotten? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thx, forgotten from debugging :)

@@ -335,6 +339,50 @@ func TestPreservesMetadata(t *testing.T) {
"existing metadata should be preserved")
}

func TestStreamSendsErrorCode(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 great! Thanks for adding a test.

- Put finishWithError calls inside clojure functions because the deferred
function's arguments are evaluated when the defer statement is
evaluated. More at https://golang.org/doc/effective_go.html#defer
Before this commit, `finishWithError` deferred with nil error and
any other changes of the initial value were not added to span. This bug
affects only grpc streaming.
- Clean tagCode in case that error was disregarded.
- Add tests for checking if span contains error.
Copy link
Contributor

@gbbr gbbr left a comment

Choose a reason for hiding this comment

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

Thanks!

@mrVanboy
Copy link
Contributor Author

Updated and ready for review again.

@gbbr gbbr added this to the 1.10.0 milestone Feb 19, 2019
@gbbr gbbr added bug unintended behavior that has to be fixed apm:ecosystem contrib/* related feature requests or bugs labels Feb 19, 2019
@gbbr gbbr merged commit 94a3c9f into DataDog:v1 Feb 19, 2019
mingrammer pushed a commit to mingrammer/dd-trace-go that referenced this pull request Dec 22, 2020
…DataDog#396)

- Put finishWithError calls inside clojure functions because the deferred
function's arguments are evaluated when the defer statement is
evaluated. More at https://golang.org/doc/effective_go.html#defer
Before this commit, `finishWithError` deferred with nil error and
any other changes of the initial value were not added to span. This bug
affects only grpc streaming.
- Clean tagCode in case that error was disregarded.
- Add tests for checking if span contains error.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
apm:ecosystem contrib/* related feature requests or bugs bug unintended behavior that has to be fixed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants