Skip to content

Conversation

giortzisg
Copy link
Contributor

@giortzisg giortzisg commented Sep 24, 2025

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:

  • creating an envelope convertible interface, to accept a generic type of events/logs/transactions, etc..
  • moving the dsn internally under the protocol folder and re exporting everything on the top level to avoid cyclic imports when using the new transport.

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.

  • Transport (new):
    • Add internal/http transports: AsyncTransport and SyncTransport that send protocol.Envelopes, with queueing, flush/close, rate limiting, proxy/TLS config, headers, and keep-alive handling.
  • Protocol (new):
    • Add internal/protocol: Dsn, Envelope (+ items, header), SdkInfo, and interfaces (EnvelopeConvertible, TelemetryTransport).
    • Provide DSN parsing, request headers, API URL, JSON marshal/unmarshal.
  • SDK integration/refactor:
    • Wrap and re-export Dsn and DsnParseError in top-level sentry; NewDsn delegates to protocol; RequestHeaders() uses SDK version; minor typo fix in comment.
    • Add Event.ToEnvelope/ToEnvelopeWithTime; include DSC trace info and attachments; fallback JSON marshal path preserved.
    • Update DynamicSamplingContext and transport.go to use DSN getters (GetPublicKey, etc.) and scheme constants from protocol in NewRequest.
  • Tests:
    • Add comprehensive tests for protocol DSN/envelope, new transports (queueing, flush, rate limits, errors, keep-alive, proxies/TLS, concurrency, goroutine leaks), and wrapper behavior; expand request and event tests.

Written by Cursor Bugbot for commit 1ed184b. This will update automatically on new commits. Configure here.

Copy link

linear bot commented Sep 24, 2025

Copy link

codecov bot commented Sep 24, 2025

Codecov Report

❌ Patch coverage is 85.26149% with 93 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.70%. Comparing base (b07461a) to head (1ed184b).

Files with missing lines Patch % Lines
internal/http/transport.go 86.68% 33 Missing and 12 partials ⚠️
internal/protocol/envelope.go 63.73% 22 Missing and 11 partials ⚠️
interfaces.go 82.75% 7 Missing and 3 partials ⚠️
internal/protocol/dsn.go 97.69% 2 Missing and 1 partial ⚠️
transport.go 71.42% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1094      +/-   ##
==========================================
- Coverage   86.97%   86.70%   -0.28%     
==========================================
  Files          55       59       +4     
  Lines        6025     6519     +494     
==========================================
+ Hits         5240     5652     +412     
- Misses        641      699      +58     
- Partials      144      168      +24     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment on lines +85 to +87
return &tls.Config{
RootCAs: options.CaCerts,
}

Choose a reason for hiding this comment

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

Semgrep identified an issue in your code:
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.

To resolve this comment:

✨ Commit Assistant Fix Suggestion
  1. Add a MinVersion: tls.VersionTLS13, field to the tls.Config struct in the getTLSConfig function. The config object should look like: &tls.Config{RootCAs: options.CaCerts, MinVersion: tls.VersionTLS13}.
  2. Ensure you have import "crypto/tls" at the top of your file if it is not already present.

By setting MinVersion to tls.VersionTLS13, the server will not accept connections using older and less secure TLS protocols.

💬 Ignore this finding

Reply with Semgrep commands to ignore this finding.

  • /fp <comment> for false positive
  • /ar <comment> for acceptable risk
  • /other <comment> for all other reasons

Alternatively, triage in Semgrep AppSec Platform to ignore the finding created by missing-ssl-minversion.

You can view more details about this finding in the Semgrep AppSec Platform.

@giortzisg giortzisg force-pushed the feat/transport-envelope branch from 3ce9dee to 4228142 Compare September 29, 2025 14:02
@giortzisg giortzisg marked this pull request as ready for review September 29, 2025 14:27
cursor[bot]

This comment was marked as outdated.

Copy link
Member

@sl0thentr0py sl0thentr0py left a 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

}
// Dsn is used as the remote address source to client transport.
type Dsn struct {
protocol.Dsn
Copy link
Member

Choose a reason for hiding this comment

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

not familiar with go, why embed instead of alias?


envelope := protocol.NewEnvelope(header)

eventBody, err := json.Marshal(e)
Copy link
Member

Choose a reason for hiding this comment

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

this is fine for now, but eventually, each envelope item type should know how to serialize itself instead of this hacky logic

sentry-go/interfaces.go

Lines 558 to 574 in 1ed184b

func (e *Event) MarshalJSON() ([]byte, error) {
// We want to omit time.Time zero values, otherwise the server will try to
// interpret dates too far in the past. However, encoding/json doesn't
// support the "omitempty" option for struct types. See
// https://golang.org/issues/11939.
//
// We overcome the limitation and achieve what we want by shadowing fields
// and a few type tricks.
if e.Type == transactionType {
return e.transactionMarshalJSON()
}
if e.Type == checkInType {
return e.checkInMarshalJSON()
}
return e.defaultMarshalJSON()
}

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.

Create new transport that accepts envelopes
2 participants