Skip to content

Commit

Permalink
Merge pull request #23 from bugsnag/PLAT-13246-transport
Browse files Browse the repository at this point in the history
Add Transport option in configuration
  • Loading branch information
DariaKunoichi authored Nov 29, 2024
2 parents 05a718a + 966b5db commit 17807ba
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions bugsnag_performance.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"log"
"net/http"
"os"
"sync"

Expand All @@ -26,6 +27,7 @@ func init() {
ReleaseStage: "production",
Logger: log.New(os.Stdout, "[BugsnagPerformance] ", log.LstdFlags),
MainContext: context.TODO(),
Transport: http.DefaultTransport,
}
}

Expand Down
9 changes: 9 additions & 0 deletions configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"log"
"net/http"
"os"
"strings"

Expand Down Expand Up @@ -53,6 +54,11 @@ type Configuration struct {
// if Distributed Tracing is used.
ServiceName string

// The http Transport to use, defaults to the default http Transport. This
// can be configured if you are in an environment
// that has stringent conditions on making http requests.
Transport http.RoundTripper

// Logger to use for debug messages
Logger *log.Logger
}
Expand Down Expand Up @@ -85,6 +91,9 @@ func (config *Configuration) update(other *Configuration) *Configuration {
if other.ServiceName != "" {
config.ServiceName = other.ServiceName
}
if other.Transport != nil {
config.Transport = other.Transport
}
if other.Logger != nil {
config.Logger = other.Logger
}
Expand Down
3 changes: 2 additions & 1 deletion delivery.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ type delivery struct {

func (d *delivery) sendPayload(headers map[string]string, payload []byte) (*http.Response, error) {
client := http.Client{
Timeout: 10 * time.Second,
Timeout: 10 * time.Second,
Transport: Config.Transport,
}

body := bytes.NewBuffer(payload)
Expand Down

0 comments on commit 17807ba

Please sign in to comment.