Transports

Transports let you change the way in which events are delivered to Sentry.

The Sentry Go SDK itself, provides two built-in transports. HTTPTransport, which is non-blocking and is used by default. And HTTPSyncTransport which is blocking. Each transport, provide slightly different configuration options.

To configure transport, provide an instance of sentry.Transport interface to ClientOptions

Copied
package main

import (
	"time"

	"github.com/getsentry/sentry-go"
)

func main() {
	sentrySyncTransport := sentry.NewHTTPSyncTransport()
	sentrySyncTransport.Timeout = time.Second * 3

	sentry.Init(sentry.ClientOptions{
		Dsn: "https://examplePublicKey@o0.ingest.sentry.io/0",
		Transport: sentrySyncTransport,
	})
}

Each transport, provide it's own factory function. NewHTTPTransport and NewHTTPSyncTransport respectively.

Copied
// HTTPTransport is a default implementation of `Transport` interface used by `Client`.
type HTTPTransport struct {
	// Size of the transport buffer. Defaults to 30.
	BufferSize int
	// HTTP Client request timeout. Defaults to 30 seconds.
	Timeout time.Duration
}

Copied
// HTTPSyncTransport is an implementation of `Transport` interface which blocks after each captured event.
type HTTPSyncTransport struct {
	// HTTP Client request timeout. Defaults to 30 seconds.
	Timeout time.Duration
}
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").