-
Notifications
You must be signed in to change notification settings - Fork 223
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
feat: Add Transactions to sentry-go #235
Conversation
1d9eeea
to
fbdbc36
Compare
2c8d11e
to
30a42c7
Compare
Seems CI is broken due to go-errors/errors#27 |
71e1e58
to
7c7ab9a
Compare
- fix: Change how DSN API URL is formatted - test: Don't calculate DSN every loop in transport test - test: Compare envelope payload using cpm.Diff
7c7ab9a
to
518cc19
Compare
@rhcarvalho This is ready for another pass. Summary of changes since last review:
The changes were again tested with the collector and found to be working 👍 |
0c673e5
to
1477a70
Compare
- Move new types down - Sort +- logically Span fields - set `omitempty` for `Span.Status`
To keep code related to DSN manipulation consistently together.
The object is to document better what is being done there and why, and to avoid repeating tricks to work around differences between error events and transactions. Also fixed tests that were broken by my previous commits directly on GitHub (change of order in struct fields change serialized JSON). Also removed optional newline at the end of the envelope -- less bytes is better? A typical request payload does not require the extra new line, and the net/http library handles HTTP protocol under the hood (e.g. setting Content-Length header).
With the line in, the comment does not show up in godoc output.
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.
@AbhiPrasad I think we're almost done. Please have a review yourself too. I have one comment that could be addressed in a follow up.
body := getRequestBodyFromEvent(event) | ||
if body == nil { | ||
request, err := getRequestFromEvent(event, t.dsn) | ||
if err != nil { | ||
return | ||
} | ||
|
||
request, _ := http.NewRequest( | ||
http.MethodPost, | ||
t.dsn.StoreAPIURL().String(), | ||
bytes.NewBuffer(body), | ||
) |
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.
There are two builtin transport implementations, we need this to be applied to HTTPSyncTransport too, so it becomes an alternative to send transactions/envelopes too.
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.
Will address this in next PR
* feat: Add Transaction and Span structs * ref: Update functions to work with transaction events * ref: Update DSN to work with envelope endpoint * test: Add golden test to snapshot test important interfaces * ref: Update transport to use envelopes endpoint Co-authored-by: Rodolfo Carvalho <[email protected]>
Motivation
This PR aims to add the concept of a transaction to
sentry-go
. This is important for us so that we can leverage thesentry-go
transport in theotel-collector
. This also setups the interfaces so that we can possibly add AM support tosentry-go
in the future.Implementation
We add a struct
type Span
to represent a Sentry span. We also edit theEvent
struct to add three new fields,StartTimestamp
,Spans
, andType
. By settingType == "transaction"
, users will send transaction events.The transport code was also changed to account for this. If a
type == "transaction"
is detected, it will use the envelopes endpoint instead.Testing
A few unit tests have been added to test the new functions added. This functionality was also demoed with the collector, and was found to be fully functional with no regressions found.