-
Notifications
You must be signed in to change notification settings - Fork 241
feat: add new envelope transport #1094
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
base: feat/transport-buffers
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## feat/transport-buffers #1094 +/- ##
==========================================================
- Coverage 86.98% 86.64% -0.35%
==========================================================
Files 57 60 +3
Lines 6356 6894 +538
==========================================================
+ Hits 5529 5973 +444
- Misses 675 739 +64
- Partials 152 182 +30 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
return &tls.Config{ | ||
RootCAs: options.CaCerts, | ||
} |
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.
MinVersion
is missing from this TLS configuration. By default, as of Go 1.22, TLS 1.2 is currently used as the minimum. General purpose web applications should default to TLS 1.3 with all other protocols disabled. Only where it is known that a web server must support legacy clients with unsupported an insecure browsers (such as Internet Explorer 10), it may be necessary to enable TLS 1.0 to provide support. Add `MinVersion: tls.VersionTLS13' to the TLS configuration to bump the minimum version to TLS 1.3.
🧼 Fixed in commit 871ade0 🧼
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.
can we address this?
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.
Since go uses tls1.2 we should be good to this as the min version. We already inherit the min version of the runtime anyways.
3ce9dee
to
4228142
Compare
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.
ideally we'd also abstract the older event types as envelope items, but I'll leave it upto you if you want to do that now or separately later
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.
Left some mostly minor comments, looks good overall. Haven't looked at the tests yet.
func (t *AsyncTransport) SendEvent(event protocol.EnvelopeConvertible) { | ||
envelope, err := event.ToEnvelope(t.dsn) | ||
if err != nil { | ||
debuglog.Printf("Failed to convert to envelope: %v", err) |
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.
debuglog.Printf("Failed to convert to envelope: %v", err) | |
debuglog.Printf("Failed to convert to envelope: %s", err.Error()) |
using %v
is heavier performance-wise than %s
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.
for errors I think this doesn't really apply, both just call err.Error()
IIRC.
} | ||
|
||
if err := t.SendEnvelope(envelope); err != nil { | ||
debuglog.Printf("Error sending the envelope: %v", err) |
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.
debuglog.Printf("Error sending the envelope: %v", err) | |
debuglog.Printf("Error sending the envelope: %s", err.Error()) |
same goes with this
// Parse | ||
parsedURL, err := url.Parse(rawURL) | ||
if err != nil { | ||
return nil, &DsnParseError{fmt.Sprintf("invalid url: %v", err)} |
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.
Why don't we do something like this?
return nil, &DsnParseError{fmt.Sprintf("invalid url: %v", err)} | |
return nil, &DsnParseError{fmt.Errorf("invalid url: %w", err)} |
That way, we can trace what the actual inner error is.
This would modify DsnParseError
to:
type DsnParseError struct {
Message error
}
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.
I don't really want to break the signature for message, since it doesn't really give that much value.
// PublicKey | ||
publicKey := parsedURL.User.Username() | ||
if publicKey == "" { | ||
return nil, &DsnParseError{"empty username"} |
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.
username
is confusing, users only understand "public key" and "project id"
return nil, &DsnParseError{"empty username"} | |
return nil, &DsnParseError{"empty public key"} |
if dsn.secretKey != "" { | ||
url += fmt.Sprintf(":%s", dsn.secretKey) | ||
} | ||
url += fmt.Sprintf("@%s", dsn.host) |
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.
Annoying request, but: What about self-hosted users that uses private IPv6 address on their DSN? 😀
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.
Why is this problematic for IPv6?
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.
For IPv6, you would need to enclose it within []
brackets. Or maybe just create a test case for this one.
Description
Create the new transport that accepts envelopes and not events. For now only the implementation for the new transport is added, without deprecating the old one. The PR also includes some misc changes:
Issues
Note
Introduce envelope-first Sync/Async HTTP transports, centralize DSN and envelope types under internal/protocol, and adapt SDK to use them with minimal API surface changes.
internal/http
transports:AsyncTransport
andSyncTransport
that sendprotocol.Envelope
s, with queueing, flush/close, rate limiting, proxy/TLS config, headers, and keep-alive handling.internal/protocol
:Dsn
,Envelope
(+ items, header),SdkInfo
, and interfaces (EnvelopeConvertible
,TelemetryTransport
).Dsn
andDsnParseError
in top-levelsentry
;NewDsn
delegates to protocol;RequestHeaders()
uses SDK version; minor typo fix in comment.Event.ToEnvelope
/ToEnvelopeWithTime
; include DSC trace info and attachments; fallback JSON marshal path preserved.DynamicSamplingContext
andtransport.go
to use DSN getters (GetPublicKey
, etc.) and scheme constants from protocol inNewRequest
.Written by Cursor Bugbot for commit 1ed184b. This will update automatically on new commits. Configure here.