Skip to content
This repository was archived by the owner on Dec 30, 2024. It is now read-only.

Commit 02582d2

Browse files
authored
Merge pull request #11 from Constructor-io/pe-657/http-cli-max-err-depth-cfg
feat: http client & max error depth configs
2 parents 1fa3486 + 57dfb95 commit 02582d2

File tree

3 files changed

+35
-19
lines changed

3 files changed

+35
-19
lines changed

go.mod

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ go 1.20
44

55
require (
66
github.com/buger/jsonparser v1.1.1
7-
github.com/getsentry/sentry-go v0.21.0
8-
github.com/rs/zerolog v1.29.1
7+
github.com/getsentry/sentry-go v0.24.1
8+
github.com/rs/zerolog v1.31.0
99
github.com/stretchr/testify v1.8.4
1010
)
1111

1212
require (
1313
github.com/davecgh/go-spew v1.1.1 // indirect
1414
github.com/mattn/go-colorable v0.1.13 // indirect
15-
github.com/mattn/go-isatty v0.0.17 // indirect
15+
github.com/mattn/go-isatty v0.0.19 // indirect
1616
github.com/pmezard/go-difflib v1.0.0 // indirect
17-
golang.org/x/sys v0.6.0 // indirect
18-
golang.org/x/text v0.8.0 // indirect
17+
golang.org/x/sys v0.12.0 // indirect
18+
golang.org/x/text v0.13.0 // indirect
1919
gopkg.in/yaml.v3 v3.0.1 // indirect
2020
)

go.sum

+11-14
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,32 @@ github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx2
33
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
44
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
55
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
6-
github.com/getsentry/sentry-go v0.21.0 h1:c9l5F1nPF30JIppulk4veau90PK6Smu3abgVtVQWon4=
7-
github.com/getsentry/sentry-go v0.21.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY=
6+
github.com/getsentry/sentry-go v0.24.1 h1:W6/0GyTy8J6ge6lVCc94WB6Gx2ZuLrgopnn9w8Hiwuk=
7+
github.com/getsentry/sentry-go v0.24.1/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY=
88
github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA=
99
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
1010
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
11-
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
1211
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
1312
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
14-
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
1513
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
16-
github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=
17-
github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
14+
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
15+
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
1816
github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4=
1917
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
2018
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
2119
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
2220
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
23-
github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
24-
github.com/rs/zerolog v1.29.1 h1:cO+d60CHkknCbvzEWxP0S9K6KqyTjrCNUy1LdQLCGPc=
25-
github.com/rs/zerolog v1.29.1/go.mod h1:Le6ESbR7hc+DP6Lt1THiV8CQSdkkNrd3R0XbEgp3ZBU=
21+
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
22+
github.com/rs/zerolog v1.31.0 h1:FcTR3NnLWW+NnTwwhFWiJSZr4ECLpqCm6QsEnyvbV4A=
23+
github.com/rs/zerolog v1.31.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
2624
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
2725
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
28-
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
29-
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
3026
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
31-
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
3227
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
33-
golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68=
34-
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
28+
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
29+
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
30+
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
31+
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
3532
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
3633
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
3734
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=

writer.go

+19
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package zlogsentry
33
import (
44
"crypto/x509"
55
"io"
6+
"net/http"
67
"time"
78
"unsafe"
89

@@ -187,9 +188,11 @@ type config struct {
187188
debug bool
188189
tracing bool
189190
debugWriter io.Writer
191+
httpClient *http.Client
190192
httpProxy string
191193
httpsProxy string
192194
caCerts *x509.CertPool
195+
maxErrorDepth int
193196
flushTimeout time.Duration
194197
beforeSend sentry.EventProcessor
195198
tracesSampleRate float64
@@ -274,6 +277,13 @@ func WithDebugWriter(w io.Writer) WriterOption {
274277
})
275278
}
276279

280+
// WithHttpClient sets custom http client.
281+
func WithHttpClient(httpClient *http.Client) WriterOption {
282+
return optionFunc(func(cfg *config) {
283+
cfg.httpClient = httpClient
284+
})
285+
}
286+
277287
// WithHttpProxy enables sentry client tracing.
278288
func WithHttpProxy(proxy string) WriterOption {
279289
return optionFunc(func(cfg *config) {
@@ -295,6 +305,13 @@ func WithCaCerts(caCerts *x509.CertPool) WriterOption {
295305
})
296306
}
297307

308+
// WithMaxErrorDepth sets the max depth of error chain.
309+
func WithMaxErrorDepth(maxErrorDepth int) WriterOption {
310+
return optionFunc(func(cfg *config) {
311+
cfg.maxErrorDepth = maxErrorDepth
312+
})
313+
}
314+
298315
// New creates writer with provided DSN and options.
299316
func New(dsn string, opts ...WriterOption) (*Writer, error) {
300317
cfg := newDefaultConfig()
@@ -312,9 +329,11 @@ func New(dsn string, opts ...WriterOption) (*Writer, error) {
312329
Debug: cfg.debug,
313330
EnableTracing: cfg.tracing,
314331
DebugWriter: cfg.debugWriter,
332+
HTTPClient: cfg.httpClient,
315333
HTTPProxy: cfg.httpProxy,
316334
HTTPSProxy: cfg.httpsProxy,
317335
CaCerts: cfg.caCerts,
336+
MaxErrorDepth: cfg.maxErrorDepth,
318337
BeforeSend: cfg.beforeSend,
319338
TracesSampleRate: cfg.tracesSampleRate,
320339
})

0 commit comments

Comments
 (0)