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

Propagate error to observability service #715

Merged
merged 2 commits into from
Sep 1, 2021

Conversation

joaopgrassi
Copy link
Contributor

Call defer in the appropriate location, so the observability service callback is invoked with the error object populated. This allows to record the error into the span, or set the span as failed.

Fixes #713

Co-authored-by: Armin Ruech <armin.ruech@dynatrace.com>
Signed-off-by: Joao Grassi <joao.grassi@dynatrace.com>
observability/opencensus/v2/client/client_test.go Outdated Show resolved Hide resolved
@@ -186,7 +184,7 @@ func (c *ceClient) Request(ctx context.Context, e event.Event) (*event.Event, pr
} else {
resp = rs
}

defer cb(err, resp)
Copy link
Member

Choose a reason for hiding this comment

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

this change should not do anything as err and resp are defined here: https://github.com/cloudevents/sdk-go/pull/715/files#diff-bfa445e7f19a76da55d2f4a1f51a4dd9cb7e2bf54efd28fd96428078c1453732R139-R140 and are never recreated in the function

Copy link
Member

Choose a reason for hiding this comment

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

I was wrong. It seems to matter for error type. which is annoying...


resp, result = r.fn.invoke(ctx, e)
defer cb(result)
Copy link
Member

Choose a reason for hiding this comment

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

same here, can you confirm the new test fails when the defer order is changed to the original?

@n3wscott
Copy link
Member

You are correct. https://play.golang.org/p/PyVqhb3LVKM

Interesting! I expected the interface pointers to not be reassigned, but clearly there is a go-ism I don't understand on that one.

Could you please resort the imports, and then LGTM

Thanks for the PR and the issue.

Signed-off-by: Joao Grassi <joao.grassi@dynatrace.com>
@joaopgrassi
Copy link
Contributor Author

@n3wscott not sure why the integration tests failed, they also failed once in our fork and re-triggering it worked. I guess it's some network issue? Since it seems it was waiting for 12min..

@n3wscott
Copy link
Member

n3wscott commented Sep 1, 2021

LGTM

Thanks a ton for the fix @joaopgrassi !!

@n3wscott n3wscott merged commit e1371d2 into cloudevents:main Sep 1, 2021
@joaopgrassi joaopgrassi deleted the obs-empty-errors branch September 2, 2021 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Observability service getting empty errors in the callback function
2 participants