MSP-8974 up deps
This commit is contained in:
1 parent
0abaaf740f
commit
a0aafd93b9
602 files changed
+47724
-13295
No files matched your search
+3
@@ -15,6 +15,9 @@ targets:
|
||||
- name: github
|
||||
tagPrefix: otel/otlp/v
|
||||
tagOnly: true
|
||||
- name: github
|
||||
tagPrefix: cron/v
|
||||
tagOnly: true
|
||||
- name: github
|
||||
tagPrefix: echo/v
|
||||
tagOnly: true
|
||||
|
||||
+35
@@ -1,5 +1,40 @@
|
||||
# Changelog
|
||||
|
||||
## 0.50.0
|
||||
|
||||
### Breaking Changes 🛠
|
||||
|
||||
- adds NoopClient implementation. The SDK now returns a non-nil noop client and handles the previous nil checks with checking for a disabled client. Code paths that were using nil checks now need to check for `client.IsEnabled`. by @giortzisg in [#1365](https://github.com/getsentry/sentry-go/pull/1365)
|
||||
|
||||
### New Features ✨
|
||||
|
||||
#### Crons
|
||||
|
||||
- Add `sentry.WithMonitor` and `Hub.WithMonitor` to wrap a job in cron check-ins and create or update the monitor from code. by @wedamija in [#1443](https://github.com/getsentry/sentry-go/pull/1443)
|
||||
- Add `sentrycron.AddFunc` to report robfig/cron jobs to Sentry Crons, using the job's spec as the monitor schedule. by @wedamija in [#1443](https://github.com/getsentry/sentry-go/pull/1443)
|
||||
- Docs: https://github.com/getsentry/sentry-docs/pull/19778 by @wedamija in [#1443](https://github.com/getsentry/sentry-go/pull/1443)
|
||||
|
||||
### Bug Fixes 🐛
|
||||
|
||||
- (dsn) Build envelope URL without re-parsing by @giortzisg in [#1436](https://github.com/getsentry/sentry-go/pull/1436)
|
||||
- (httpclient) Decouple span creation from trace propagation by @giortzisg in [#1421](https://github.com/getsentry/sentry-go/pull/1421)
|
||||
- (slog) Stop replaceAttrs from mutating the handler's grouped attrs by @breken-ai in [#1439](https://github.com/getsentry/sentry-go/pull/1439)
|
||||
- (zerolog) Unescape JSON string values before sending to Sentry by @breken-ai in [#1440](https://github.com/getsentry/sentry-go/pull/1440)
|
||||
- Guard concurrent flushes by @giortzisg in [#1449](https://github.com/getsentry/sentry-go/pull/1449)
|
||||
- Keep http.Hijacker when wrapping a response writer by @knQzx in [#1387](https://github.com/getsentry/sentry-go/pull/1387)
|
||||
|
||||
### Internal Changes 🔧
|
||||
|
||||
#### Deps
|
||||
|
||||
- Bump getsentry/craft from 2.30.1 to 2.31.2 by @dependabot in [#1441](https://github.com/getsentry/sentry-go/pull/1441)
|
||||
- Bump getsentry/github-workflows/validate-pr from 4013fc6e1aeb1be1f9d3b4d232624f0ec1afa613 to 36c729264d2edc29ebae61950c50e1e9f043ad7e by @dependabot in [#1442](https://github.com/getsentry/sentry-go/pull/1442)
|
||||
- Bump go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp from 1.43.0 to 1.45.0 in /otel/otlp by @dependabot in [#1430](https://github.com/getsentry/sentry-go/pull/1430)
|
||||
- Bump go.opentelemetry.io/otel/sdk from 1.44.0 to 1.45.0 by @dependabot in [#1431](https://github.com/getsentry/sentry-go/pull/1431)
|
||||
- Bump google.golang.org/grpc from 1.83.1 to 1.83.2 by @dependabot in [#1422](https://github.com/getsentry/sentry-go/pull/1422)
|
||||
- Bump getsentry/craft from 2.27.2 to 2.30.1 by @dependabot in [#1411](https://github.com/getsentry/sentry-go/pull/1411)
|
||||
- Bump google.golang.org/grpc from 1.82.1 to 1.83.1 by @dependabot in [#1413](https://github.com/getsentry/sentry-go/pull/1413)
|
||||
|
||||
## 0.49.0
|
||||
|
||||
### Breaking Changes 🛠
|
||||
|
||||
+6
-4
@@ -305,6 +305,8 @@ func (t Type) String() string {
|
||||
return "invalid"
|
||||
}
|
||||
|
||||
const arrayType = "array"
|
||||
|
||||
// mapTypesToStr is a map from attribute.Type to the primitive types the server understands.
|
||||
// https://develop.sentry.dev/sdk/foundations/data-model/attributes/#primitive-types
|
||||
var mapTypesToStr = map[Type]string{
|
||||
@@ -313,9 +315,9 @@ var mapTypesToStr = map[Type]string{
|
||||
INT64: "integer",
|
||||
FLOAT64: "double",
|
||||
STRING: "string",
|
||||
BOOLSLICE: "array",
|
||||
INT64SLICE: "array",
|
||||
FLOAT64SLICE: "array",
|
||||
STRINGSLICE: "array",
|
||||
BOOLSLICE: arrayType,
|
||||
INT64SLICE: arrayType,
|
||||
FLOAT64SLICE: arrayType,
|
||||
STRINGSLICE: arrayType,
|
||||
UINT64: "integer", // wire format: same "integer" type
|
||||
}
|
||||
+85
-9
@@ -133,8 +133,8 @@ type ClientOptions struct {
|
||||
// The DSN to use. If the DSN is not set, the client is effectively
|
||||
// disabled.
|
||||
Dsn string
|
||||
// In debug mode, the debug information is printed to stdout to help you
|
||||
// understand what sentry is doing.
|
||||
// In debug mode, diagnostic information is written to DebugWriter, which
|
||||
// defaults to stderr.
|
||||
Debug bool
|
||||
// Configures whether SDK should generate and attach stacktraces to pure
|
||||
// capture message calls.
|
||||
@@ -298,6 +298,7 @@ type ClientOptions struct {
|
||||
// instances. It must be created with NewClient.
|
||||
type Client struct {
|
||||
mu sync.RWMutex
|
||||
disabled bool
|
||||
options ClientOptions
|
||||
dsn *protocol.Dsn
|
||||
eventProcessors []EventProcessor
|
||||
@@ -450,6 +451,45 @@ func NewClient(options ClientOptions) (*Client, error) {
|
||||
return &client, nil
|
||||
}
|
||||
|
||||
var noopClient = &Client{
|
||||
disabled: true,
|
||||
options: ClientOptions{
|
||||
DisableTelemetryBuffer: true,
|
||||
MaxErrorDepth: maxErrorDepth,
|
||||
MaxSpans: defaultMaxSpans,
|
||||
TraceIgnoreStatusCodes: [][]int{{404}},
|
||||
},
|
||||
sdkIdentifier: sdkIdentifier,
|
||||
sdkVersion: SDKVersion,
|
||||
Transport: new(noopTransport),
|
||||
reportRecorder: report.NoopRecorder(),
|
||||
reportProvider: report.NoopProvider(),
|
||||
}
|
||||
|
||||
// NewNoopClient returns the shared client that safely discards telemetry.
|
||||
// Its mutating methods have no effect.
|
||||
func NewNoopClient() *Client {
|
||||
return noopClient
|
||||
}
|
||||
|
||||
// IsEnabled reports whether the client processes captured telemetry.
|
||||
//
|
||||
// It returns false for a nil receiver and for clients returned by
|
||||
// NewNoopClient. A client can be enabled while using a transport that discards
|
||||
// telemetry, such as a client configured with an empty DSN.
|
||||
func (client *Client) IsEnabled() bool {
|
||||
return client != nil && !client.disabled
|
||||
}
|
||||
|
||||
// normalizeClient returns client, or the shared no-op client when client is
|
||||
// nil.
|
||||
func normalizeClient(client *Client) *Client {
|
||||
if client == nil {
|
||||
return noopClient
|
||||
}
|
||||
return client
|
||||
}
|
||||
|
||||
func (client *Client) setupTransport() {
|
||||
opts := client.options
|
||||
transport := opts.Transport
|
||||
@@ -555,6 +595,9 @@ func (client *Client) setupIntegrations() {
|
||||
// client is shared among multiple hubs, one per goroutine, such that adding an
|
||||
// event processor to the client affects all hubs that share the client.
|
||||
func (client *Client) AddEventProcessor(processor EventProcessor) {
|
||||
if !client.IsEnabled() {
|
||||
return
|
||||
}
|
||||
client.eventProcessors = append(client.eventProcessors, processor)
|
||||
}
|
||||
|
||||
@@ -563,6 +606,9 @@ func (client *Client) AddEventProcessor(processor EventProcessor) {
|
||||
//
|
||||
// This is intended for integrations such as OpenTelemetry.
|
||||
func (client *Client) SetExternalContextTraceResolver(resolver func(ctx context.Context) (TraceID, SpanID, bool)) {
|
||||
if !client.IsEnabled() {
|
||||
return
|
||||
}
|
||||
client.mu.Lock()
|
||||
defer client.mu.Unlock()
|
||||
|
||||
@@ -596,7 +642,7 @@ func (client *Client) Options() ClientOptions {
|
||||
// GetDataCollection returns a copy of the resolved data collection
|
||||
// configuration used by the client.
|
||||
func (client *Client) GetDataCollection() DataCollection {
|
||||
if client == nil || client.options.DataCollection == nil {
|
||||
if !client.IsEnabled() || client.options.DataCollection == nil {
|
||||
return DataCollection{}
|
||||
}
|
||||
return *cloneDataCollection(client.options.DataCollection)
|
||||
@@ -604,22 +650,32 @@ func (client *Client) GetDataCollection() DataCollection {
|
||||
|
||||
// CaptureMessage captures an arbitrary message.
|
||||
func (client *Client) CaptureMessage(message string, hint *EventHint, scope EventModifier) *EventID {
|
||||
if !client.IsEnabled() {
|
||||
return nil
|
||||
}
|
||||
event := client.EventFromMessage(message, LevelInfo)
|
||||
return client.CaptureEvent(event, hint, scope)
|
||||
}
|
||||
|
||||
// CaptureException captures an error.
|
||||
func (client *Client) CaptureException(exception error, hint *EventHint, scope EventModifier) *EventID {
|
||||
if !client.IsEnabled() {
|
||||
return nil
|
||||
}
|
||||
event := client.EventFromException(exception, LevelError)
|
||||
return client.CaptureEvent(event, hint, scope)
|
||||
}
|
||||
|
||||
// CaptureCheckIn captures a check in.
|
||||
func (client *Client) CaptureCheckIn(checkIn *CheckIn, monitorConfig *MonitorConfig, scope EventModifier) *EventID {
|
||||
if !client.IsEnabled() {
|
||||
return nil
|
||||
}
|
||||
event := client.EventFromCheckIn(checkIn, monitorConfig)
|
||||
if event != nil && event.CheckIn != nil {
|
||||
client.CaptureEvent(event, nil, scope)
|
||||
return &event.CheckIn.ID
|
||||
if client.CaptureEvent(event, nil, scope) != nil {
|
||||
return &event.CheckIn.ID
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -630,6 +686,9 @@ func (client *Client) CaptureCheckIn(checkIn *CheckIn, monitorConfig *MonitorCon
|
||||
// the utility methods like CaptureException. The return value is the
|
||||
// event ID. In case Sentry is disabled or event was dropped, the return value will be nil.
|
||||
func (client *Client) CaptureEvent(event *Event, hint *EventHint, scope EventModifier) *EventID {
|
||||
if !client.IsEnabled() {
|
||||
return nil
|
||||
}
|
||||
return client.processEvent(event, hint, scope)
|
||||
}
|
||||
|
||||
@@ -727,6 +786,9 @@ func (client *Client) RecoverWithContext(
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
if !client.IsEnabled() {
|
||||
return nil
|
||||
}
|
||||
|
||||
if ctx != nil {
|
||||
if hint == nil {
|
||||
@@ -751,7 +813,8 @@ func (client *Client) RecoverWithContext(
|
||||
|
||||
// Flush waits until the underlying Transport sends any buffered events to the
|
||||
// Sentry server, blocking for at most the given timeout. It returns false if
|
||||
// the timeout was reached. In that case, some events may not have been sent.
|
||||
// the client is disabled or the timeout was reached. In the latter case, some
|
||||
// events may not have been sent.
|
||||
//
|
||||
// Flush should be called before terminating the program to avoid
|
||||
// unintentionally dropping events.
|
||||
@@ -761,6 +824,9 @@ func (client *Client) RecoverWithContext(
|
||||
// the network synchronously, configure it to use the HTTPSyncTransport in the
|
||||
// call to Init.
|
||||
func (client *Client) Flush(timeout time.Duration) bool {
|
||||
if !client.IsEnabled() {
|
||||
return false
|
||||
}
|
||||
if client.batchLogger != nil || client.batchMeter != nil || client.telemetryProcessor != nil {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
||||
defer cancel()
|
||||
@@ -770,9 +836,10 @@ func (client *Client) Flush(timeout time.Duration) bool {
|
||||
}
|
||||
|
||||
// FlushWithContext waits until the underlying Transport sends any buffered events
|
||||
// to the Sentry server, blocking for at most the duration specified by the context.
|
||||
// It returns false if the context is canceled before the events are sent. In such a case,
|
||||
// some events may not be delivered.
|
||||
// to the Sentry server, blocking for at most the duration specified by the
|
||||
// context. It returns false if the client is disabled or the context is
|
||||
// canceled before the events are sent. In the latter case, some events may not
|
||||
// be delivered.
|
||||
//
|
||||
// FlushWithContext should be called before terminating the program to ensure no
|
||||
// events are unintentionally dropped.
|
||||
@@ -782,6 +849,9 @@ func (client *Client) Flush(timeout time.Duration) bool {
|
||||
// configure the SDK to use HTTPSyncTransport during initialization with Init.
|
||||
|
||||
func (client *Client) FlushWithContext(ctx context.Context) bool {
|
||||
if !client.IsEnabled() {
|
||||
return false
|
||||
}
|
||||
if client.batchLogger != nil {
|
||||
client.batchLogger.Flush(ctx.Done())
|
||||
}
|
||||
@@ -799,6 +869,9 @@ func (client *Client) FlushWithContext(ctx context.Context) bool {
|
||||
// Close should be called after Flush and before terminating the program
|
||||
// otherwise some events may be lost.
|
||||
func (client *Client) Close() {
|
||||
if !client.IsEnabled() {
|
||||
return
|
||||
}
|
||||
if client.telemetryProcessor != nil {
|
||||
client.telemetryProcessor.Close(5 * time.Second)
|
||||
}
|
||||
@@ -875,6 +948,9 @@ func (client *Client) EventFromCheckIn(checkIn *CheckIn, monitorConfig *MonitorC
|
||||
}
|
||||
|
||||
func (client *Client) SetSDKIdentifier(identifier string) {
|
||||
if !client.IsEnabled() {
|
||||
return
|
||||
}
|
||||
client.mu.Lock()
|
||||
defer client.mu.Unlock()
|
||||
|
||||
|
||||
+4
-4
@@ -43,7 +43,7 @@ func DynamicSamplingContextFromTransaction(span *Span) DynamicSamplingContext {
|
||||
scope := hub.Scope()
|
||||
client := hub.Client()
|
||||
|
||||
if client == nil || scope == nil {
|
||||
if !client.IsEnabled() || scope == nil {
|
||||
return DynamicSamplingContext{
|
||||
Entries: map[string]string{},
|
||||
Frozen: false,
|
||||
@@ -53,7 +53,7 @@ func DynamicSamplingContextFromTransaction(span *Span) DynamicSamplingContext {
|
||||
entries := make(map[string]string)
|
||||
|
||||
if traceID := span.TraceID.String(); traceID != "" {
|
||||
entries["trace_id"] = traceID
|
||||
entries[traceIDContextKey] = traceID
|
||||
}
|
||||
if sampleRate := span.sampleRate; sampleRate != 0 {
|
||||
entries["sample_rate"] = strconv.FormatFloat(sampleRate, 'f', -1, 64)
|
||||
@@ -122,7 +122,7 @@ func (d DynamicSamplingContext) String() string {
|
||||
func DynamicSamplingContextFromScope(scope *Scope, client *Client) DynamicSamplingContext {
|
||||
entries := map[string]string{}
|
||||
|
||||
if client == nil || scope == nil {
|
||||
if !client.IsEnabled() || scope == nil {
|
||||
return DynamicSamplingContext{
|
||||
Entries: entries,
|
||||
Frozen: false,
|
||||
@@ -132,7 +132,7 @@ func DynamicSamplingContextFromScope(scope *Scope, client *Client) DynamicSampli
|
||||
propagationContext := scope.propagationContext
|
||||
|
||||
if traceID := propagationContext.TraceID.String(); traceID != "" {
|
||||
entries["trace_id"] = traceID
|
||||
entries[traceIDContextKey] = traceID
|
||||
}
|
||||
if sampleRate := client.options.TracesSampleRate; sampleRate != 0 {
|
||||
entries["sample_rate"] = strconv.FormatFloat(sampleRate, 'f', -1, 64)
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ type visited struct {
|
||||
|
||||
func (v *visited) seenError(err error) bool {
|
||||
t := reflect.ValueOf(err)
|
||||
if t.Kind() == reflect.Ptr && !t.IsNil() {
|
||||
if t.Kind() == reflect.Pointer && !t.IsNil() {
|
||||
ptr := t.Pointer()
|
||||
if _, ok := v.ptrs[ptr]; ok {
|
||||
return true
|
||||
|
||||
+1
@@ -2,6 +2,7 @@ go 1.25.0
|
||||
|
||||
use (
|
||||
.
|
||||
./cron
|
||||
./crosstest
|
||||
./echo
|
||||
./fasthttp
|
||||
|
||||
+18
@@ -1,5 +1,7 @@
|
||||
cel.dev/expr v0.25.1 h1:1KrZg61W6TWSxuNZ37Xy49ps13NUovb66QLprthtwi4=
|
||||
cel.dev/expr v0.25.1/go.mod h1:hrXvqGP6G6gyx8UAHSHJ5RGk//1Oj5nXQ2NI02Nrsg4=
|
||||
cel.dev/expr v0.25.2/go.mod h1:hrXvqGP6G6gyx8UAHSHJ5RGk//1Oj5nXQ2NI02Nrsg4=
|
||||
cloud.google.com/go/auth v0.18.2/go.mod h1:xD+oY7gcahcu7G2SG2DsBerfFxgPAJz17zz2joOFF3M=
|
||||
cloud.google.com/go/compute/metadata v0.3.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k=
|
||||
cloud.google.com/go/compute/metadata v0.9.0 h1:pDUj4QMoPejqq20dK0Pg2N4yG9zIkYGdBtwLoEkH9Zs=
|
||||
cloud.google.com/go/compute/metadata v0.9.0/go.mod h1:E0bWwX5wTnLPedCKqk3pJmVgCBSM6qQI1yTBdEb3C10=
|
||||
@@ -14,6 +16,7 @@ git.sr.ht/~sbinet/gg v0.6.0/go.mod h1:uucygbfC9wVPQIfrmwM2et0imr8L7KQWywX0xpFMm9
|
||||
github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.31.0 h1:DHa2U07rk8syqvCge0QIGMCE1WxGj9njT44GH7zNJLQ=
|
||||
github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.31.0/go.mod h1:P4WPRUkOhJC13W//jWpyfJNDAIpvRbAUIYLX/4jtlE0=
|
||||
github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.32.0/go.mod h1:RD2SsorTmYhF6HkTmDw7KmPYQk8OBYwTkuasChwv7R4=
|
||||
github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.33.0/go.mod h1:pJTkW8hEUIIi3Pf65lPZOnn4Y81yCllX6IWk2jNXdkM=
|
||||
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
|
||||
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
|
||||
github.com/PuerkitoBio/goquery v1.8.1 h1:uQxhNlArOIdbrH1tr0UXwdVFgDcZDrZVdcpygAcwmWM=
|
||||
@@ -60,6 +63,7 @@ github.com/envoyproxy/go-control-plane/ratelimit v0.1.0/go.mod h1:Wk+tMFAFbCXaJP
|
||||
github.com/envoyproxy/protoc-gen-validate v1.3.0 h1:TvGH1wof4H33rezVKWSpqKz5NXWg5VPuZ0uONDT6eb4=
|
||||
github.com/envoyproxy/protoc-gen-validate v1.3.0/go.mod h1:HvYl7zwPa5mffgyeTUHA9zHIH36nmrm7oCbo4YKoSWA=
|
||||
github.com/envoyproxy/protoc-gen-validate v1.3.3/go.mod h1:TsndJ/ngyIdQRhMcVVGDDHINPLWB7C82oDArY51KfB0=
|
||||
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
|
||||
github.com/go-jose/go-jose/v4 v4.1.3 h1:CVLmWDhDVRa6Mi/IgCgaopNosCaHz7zrMeF9MlZRkrs=
|
||||
github.com/go-jose/go-jose/v4 v4.1.3/go.mod h1:x4oUasVrzR7071A4TnHLGSPpNOm2a21K9Kf04k1rs08=
|
||||
github.com/go-jose/go-jose/v4 v4.1.4/go.mod h1:x4oUasVrzR7071A4TnHLGSPpNOm2a21K9Kf04k1rs08=
|
||||
@@ -85,6 +89,9 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
|
||||
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw=
|
||||
github.com/google/s2a-go v0.1.9/go.mod h1:YA0Ei2ZQL3acow2O62kdp9UlnvMmU7kA6Eutn0dXayM=
|
||||
github.com/googleapis/enterprise-certificate-proxy v0.3.11/go.mod h1:RFV7MUdlb7AgEq2v7FmMCfeSMCllAzWxFgRdusoGks8=
|
||||
github.com/googleapis/gax-go/v2 v2.17.0/go.mod h1:mzaqghpQp4JDh3HvADwrat+6M3MOIDp5YKHhb9PAgDY=
|
||||
github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyCS8BvQ=
|
||||
github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4=
|
||||
github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI=
|
||||
@@ -138,6 +145,7 @@ github.com/spf13/afero v1.10.0 h1:EaGW2JJh15aKOejeuJ+wpFSHnbd7GE6Wvp3TsNhb6LY=
|
||||
github.com/spf13/afero v1.10.0/go.mod h1:UBogFpq8E9Hx+xc5CNTTEpTnuHVmXDwZcZcE1eb/UhQ=
|
||||
github.com/spiffe/go-spiffe/v2 v2.6.0 h1:l+DolpxNWYgruGQVV0xsfeya3CsC7m8iBzDnMpsbLuo=
|
||||
github.com/spiffe/go-spiffe/v2 v2.6.0/go.mod h1:gm2SeUoMZEtpnzPNs2Csc0D/gX33k1xIx7lEzqblHEs=
|
||||
github.com/spiffe/go-spiffe/v2 v2.7.0/go.mod h1:47Q0Q9/AqGha8QLHp+kxpH4Wca7X7EnOtlIJy3mxZ3U=
|
||||
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
|
||||
github.com/tailscale/depaware v0.0.0-20210622194025-720c4b409502 h1:34icjjmqJ2HPjrSuJYEkdZ+0ItmGQAQ75cRHIiftIyE=
|
||||
github.com/tdewolff/argp v0.0.0-20240126212256-acdb2fb50090 h1:ok0U1tNDp9ICD93bMrZuFtHLwDoW+5nfSfF8e/x36Y0=
|
||||
@@ -161,9 +169,13 @@ go.etcd.io/bbolt v1.3.7/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw=
|
||||
go.opentelemetry.io/contrib/detectors/gcp v1.39.0 h1:kWRNZMsfBHZ+uHjiH4y7Etn2FK26LAGkNFw7RHv1DhE=
|
||||
go.opentelemetry.io/contrib/detectors/gcp v1.39.0/go.mod h1:t/OGqzHBa5v6RHZwrDBJ2OirWc+4q/w2fTbLZwAKjTk=
|
||||
go.opentelemetry.io/contrib/detectors/gcp v1.43.0/go.mod h1:RyaZMFY7yi1kAs45S6mbFGz8O8rqB0dTY14uzvG4LCs=
|
||||
go.opentelemetry.io/contrib/detectors/gcp v1.44.0/go.mod h1:tNAsgd8avTGke1+MndXlU5Cru4PQ9Ai/cCNWQv/ZJ/s=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.61.0/go.mod h1:UHB22Z8QsdRDrnAtX4PntOl36ajSxcdUMt1sF7Y6E7Q=
|
||||
go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
|
||||
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
|
||||
golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
|
||||
golang.org/x/crypto v0.55.0 h1:+KWHjbgOaAQ66dh/YlkZKHlz9ZUlq61AFirAR9ntP8M=
|
||||
golang.org/x/crypto v0.55.0/go.mod h1:uq0V9dE/fzQuJtbnL+2EhWOE63vo164FY8xqEnV9xis=
|
||||
golang.org/x/image v0.25.0 h1:Y6uW6rH1y5y/LK1J8BPWZtr6yZ7hrsy6hFrXjgsc2fQ=
|
||||
golang.org/x/image v0.25.0/go.mod h1:tCAmOEGthTtkalusGp1g3xa2gke8J6c2N565dTyl9Rs=
|
||||
golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
|
||||
@@ -172,10 +184,12 @@ golang.org/x/mod v0.33.0/go.mod h1:swjeQEj+6r7fODbD2cqrnje9PnziFuw4bmLbBZFrQ5w=
|
||||
golang.org/x/mod v0.35.0 h1:Ww1D637e6Pg+Zb2KrWfHQUnH2dQRLBQyAtpr/haaJeM=
|
||||
golang.org/x/mod v0.35.0/go.mod h1:+GwiRhIInF8wPm+4AoT6L0FA1QWAad3OMdTRx4tFYlU=
|
||||
golang.org/x/mod v0.37.0/go.mod h1:m8S8VeM9r4dzDwjrKO0a1sZP3YjeMamRRlD+fmR2Q/0=
|
||||
golang.org/x/mod v0.38.0/go.mod h1:V6Xz0pq8TQ3dGqVQ1FVHuelZpAL0uNhSkk9ogYP3c40=
|
||||
golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU=
|
||||
golang.org/x/net v0.49.0/go.mod h1:/ysNB2EvaqvesRkuLAyjI1ycPZlQHM3q01F02UY/MV8=
|
||||
golang.org/x/net v0.51.0/go.mod h1:aamm+2QF5ogm02fjy5Bb7CQ0WMt1/WVM7FtyaTLlA9Y=
|
||||
golang.org/x/net v0.53.0/go.mod h1:JvMuJH7rrdiCfbeHoo3fCQU24Lf5JJwT9W3sJFulfgs=
|
||||
golang.org/x/net v0.57.0/go.mod h1:KpXc8iv+r3XplLAG/f7Jsf9RPszJzdR0f58q9vGOuEU=
|
||||
golang.org/x/oauth2 v0.34.0/go.mod h1:lzm5WQJQwKZ3nwavOZ3IS5Aulzxi68dUSgRHujetwEA=
|
||||
golang.org/x/oauth2 v0.35.0 h1:Mv2mzuHuZuY2+bkyWXIHMfhNdJAdwW3FuWeCPYN5GVQ=
|
||||
golang.org/x/oauth2 v0.35.0/go.mod h1:lzm5WQJQwKZ3nwavOZ3IS5Aulzxi68dUSgRHujetwEA=
|
||||
@@ -184,6 +198,7 @@ golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
|
||||
golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4=
|
||||
golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
|
||||
golang.org/x/sync v0.21.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
|
||||
golang.org/x/sync v0.22.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
|
||||
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
@@ -199,6 +214,7 @@ golang.org/x/term v0.41.0/go.mod h1:3pfBgksrReYfZ5lvYM0kSO0LIkAl4Yl2bXOkKP7Ec2A=
|
||||
golang.org/x/term v0.43.0 h1:S4RLU2sB31O/NCl+zFN9Aru9A/Cq2aqKpTZJ6B+DwT4=
|
||||
golang.org/x/term v0.43.0/go.mod h1:lrhlHNdQJHO+1qVYiHfFKVuVioJIheAc3fBSMFYEIsk=
|
||||
golang.org/x/term v0.44.0/go.mod h1:7ze4MdzUzLXpSAoFP1H0bOI9aXDqveSvatT5vKcFh2Y=
|
||||
golang.org/x/term v0.45.0/go.mod h1:9aqxs0blBcrm/n0L9QW0aRVD+ktan8ssZromtqJC43w=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
|
||||
golang.org/x/text v0.33.0/go.mod h1:LuMebE6+rBincTi9+xWTY8TztLzKHc/9C1uBCG27+q8=
|
||||
@@ -212,11 +228,13 @@ golang.org/x/tools v0.43.0/go.mod h1:uHkMso649BX2cZK6+RpuIPXS3ho2hZo4FVwfoy1vIk0
|
||||
golang.org/x/tools v0.44.0 h1:UP4ajHPIcuMjT1GqzDWRlalUEoY+uzoZKnhOjbIPD2c=
|
||||
golang.org/x/tools v0.44.0/go.mod h1:KA0AfVErSdxRZIsOVipbv3rQhVXTnlU6UhKxHd1seDI=
|
||||
golang.org/x/tools v0.47.0/go.mod h1:dFHnyTvFWY212G+h7ZY4Vsp/K3U4/7W9TyVaAul8uCA=
|
||||
golang.org/x/tools v0.48.0/go.mod h1:08xX0orndb/F7jJxGDicx061tyd5pcMto75YMAXr6lk=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
|
||||
gonum.org/v1/plot v0.15.2 h1:Tlfh/jBk2tqjLZ4/P8ZIwGrLEWQSPDLRm/SNWKNXiGI=
|
||||
gonum.org/v1/plot v0.15.2/go.mod h1:DX+x+DWso3LTha+AdkJEv5Txvi+Tql3KAGkehP0/Ubg=
|
||||
gonum.org/v1/tools v0.0.0-20200318103217-c168b003ce8c h1:cJWOvXtcaFSGXz2F4z2AMM0VV7edDDGrxb5GLQH7ayQ=
|
||||
gonum.org/v1/tools v0.0.0-20200318103217-c168b003ce8c/go.mod h1:fy6Otjqbk477ELp8IXTpw1cObQtLbRCBVonY+bTTfcM=
|
||||
google.golang.org/genproto v0.0.0-20260128011058-8636f8732409 h1:VQZ/yAbAtjkHgH80teYd2em3xtIkkHd7ZhqfH2N9CsM=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20260120221211-b8f7ae30c516/go.mod h1:p3MLuOwURrGBRoEyFHBT3GjUwaCQVKeNqqWxlcISGdw=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260120221211-b8f7ae30c516/go.mod h1:j9x/tPzZkyxcgEFkiKEEGxfvyumM01BEtsW8xzOahRQ=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260401001100-f93e5f3e9f0f/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8=
|
||||
|
||||
+52
-36
@@ -20,7 +20,7 @@ const (
|
||||
RequestContextKey = contextKey(2)
|
||||
)
|
||||
|
||||
// currentHub is the initial Hub with no Client bound and an empty Scope.
|
||||
// currentHub is the initial Hub with a no-op Client and an empty Scope.
|
||||
var currentHub = NewHub(nil, NewScope())
|
||||
|
||||
// Hub is the central object that manages scopes and clients.
|
||||
@@ -58,7 +58,7 @@ func (l *layer) Client() *Client {
|
||||
func (l *layer) SetClient(c *Client) {
|
||||
l.mu.Lock()
|
||||
defer l.mu.Unlock()
|
||||
l.client = c
|
||||
l.client = normalizeClient(c)
|
||||
}
|
||||
|
||||
type stack []*layer
|
||||
@@ -67,7 +67,7 @@ type stack []*layer
|
||||
func NewHub(client *Client, scope *Scope) *Hub {
|
||||
hub := Hub{
|
||||
stack: &stack{{
|
||||
client: client,
|
||||
client: normalizeClient(client),
|
||||
scope: scope,
|
||||
}},
|
||||
}
|
||||
@@ -218,12 +218,12 @@ func (hub *Hub) CaptureEvent(event *Event) *EventID {
|
||||
// CaptureEventWithHint is like CaptureEvent but additionally accepts an EventHint.
|
||||
func (hub *Hub) CaptureEventWithHint(event *Event, hint *EventHint) *EventID {
|
||||
client, scope := hub.Client(), hub.Scope()
|
||||
if client == nil || scope == nil {
|
||||
if scope == nil {
|
||||
return nil
|
||||
}
|
||||
eventID := client.CaptureEvent(event, hint, scope)
|
||||
|
||||
if event.Type != transactionType && eventID != nil {
|
||||
if event != nil && event.Type != transactionType && eventID != nil {
|
||||
hub.mu.Lock()
|
||||
hub.lastEventID = *eventID
|
||||
hub.mu.Unlock()
|
||||
@@ -236,7 +236,7 @@ func (hub *Hub) CaptureEventWithHint(event *Event, hint *EventHint) *EventID {
|
||||
// Returns EventID if successfully, or nil if there's no Scope or Client available.
|
||||
func (hub *Hub) CaptureMessage(message string) *EventID {
|
||||
client, scope := hub.Client(), hub.Scope()
|
||||
if client == nil || scope == nil {
|
||||
if scope == nil {
|
||||
return nil
|
||||
}
|
||||
eventID := client.CaptureMessage(message, nil, scope)
|
||||
@@ -254,7 +254,7 @@ func (hub *Hub) CaptureMessage(message string) *EventID {
|
||||
// Returns EventID if successfully, or nil if there's no Scope or Client available.
|
||||
func (hub *Hub) CaptureException(exception error) *EventID {
|
||||
client, scope := hub.Client(), hub.Scope()
|
||||
if client == nil || scope == nil {
|
||||
if scope == nil {
|
||||
return nil
|
||||
}
|
||||
eventID := client.CaptureException(exception, &EventHint{OriginalException: exception}, scope)
|
||||
@@ -272,13 +272,46 @@ func (hub *Hub) CaptureException(exception error) *EventID {
|
||||
// Returns CheckInID if the check-in was captured successfully, or nil otherwise.
|
||||
func (hub *Hub) CaptureCheckIn(checkIn *CheckIn, monitorConfig *MonitorConfig) *EventID {
|
||||
client, scope := hub.Client(), hub.Scope()
|
||||
if client == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return client.CaptureCheckIn(checkIn, monitorConfig, scope)
|
||||
}
|
||||
|
||||
// WithMonitor runs fn and reports its outcome as check-ins for the cron
|
||||
// monitor identified by monitorSlug.
|
||||
//
|
||||
// An in_progress check-in carrying monitorConfig is sent before fn runs. When
|
||||
// monitorConfig is not nil, Sentry creates the monitor if it does not exist,
|
||||
// or updates its configuration. After fn returns, an ok check-in is sent if
|
||||
// it returned nil, or an error check-in otherwise, along with the measured
|
||||
// duration. If fn panics, an error check-in is sent and the panic continues.
|
||||
//
|
||||
// The error returned by fn is returned unchanged.
|
||||
func (hub *Hub) WithMonitor(monitorSlug string, monitorConfig *MonitorConfig, fn func() error) error {
|
||||
checkInID := hub.CaptureCheckIn(&CheckIn{
|
||||
MonitorSlug: monitorSlug,
|
||||
Status: CheckInStatusInProgress,
|
||||
}, monitorConfig)
|
||||
start := time.Now()
|
||||
|
||||
status := CheckInStatusError
|
||||
defer func() {
|
||||
checkIn := &CheckIn{
|
||||
MonitorSlug: monitorSlug,
|
||||
Status: status,
|
||||
Duration: time.Since(start),
|
||||
}
|
||||
if checkInID != nil {
|
||||
checkIn.ID = *checkInID
|
||||
}
|
||||
hub.CaptureCheckIn(checkIn, nil)
|
||||
}()
|
||||
|
||||
err := fn()
|
||||
if err == nil {
|
||||
status = CheckInStatusOK
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// AddBreadcrumb records a new breadcrumb.
|
||||
//
|
||||
// The total number of breadcrumbs that can be recorded are limited by the
|
||||
@@ -286,12 +319,6 @@ func (hub *Hub) CaptureCheckIn(checkIn *CheckIn, monitorConfig *MonitorConfig) *
|
||||
func (hub *Hub) AddBreadcrumb(breadcrumb *Breadcrumb, hint *BreadcrumbHint) {
|
||||
client := hub.Client()
|
||||
|
||||
// If there's no client, just store it on the scope straight away
|
||||
if client == nil {
|
||||
hub.Scope().AddBreadcrumb(breadcrumb, defaultMaxBreadcrumbs)
|
||||
return
|
||||
}
|
||||
|
||||
limit := client.options.MaxBreadcrumbs
|
||||
switch {
|
||||
case limit < 0:
|
||||
@@ -321,7 +348,7 @@ func (hub *Hub) Recover(err interface{}) *EventID {
|
||||
err = recover()
|
||||
}
|
||||
client, scope := hub.Client(), hub.Scope()
|
||||
if client == nil || scope == nil {
|
||||
if scope == nil {
|
||||
return nil
|
||||
}
|
||||
return client.Recover(err, &EventHint{RecoveredException: err}, scope)
|
||||
@@ -335,7 +362,7 @@ func (hub *Hub) RecoverWithContext(ctx context.Context, err interface{}) *EventI
|
||||
err = recover()
|
||||
}
|
||||
client, scope := hub.Client(), hub.Scope()
|
||||
if client == nil || scope == nil {
|
||||
if scope == nil {
|
||||
return nil
|
||||
}
|
||||
return client.RecoverWithContext(ctx, err, &EventHint{RecoveredException: err}, scope)
|
||||
@@ -353,19 +380,14 @@ func (hub *Hub) RecoverWithContext(ctx context.Context, err interface{}) *EventI
|
||||
// the network synchronously, configure it to use the HTTPSyncTransport in the
|
||||
// call to Init.
|
||||
func (hub *Hub) Flush(timeout time.Duration) bool {
|
||||
client := hub.Client()
|
||||
|
||||
if client == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
return client.Flush(timeout)
|
||||
return hub.Client().Flush(timeout)
|
||||
}
|
||||
|
||||
// FlushWithContext waits until the underlying Transport sends any buffered events
|
||||
// to the Sentry server, blocking for at most the duration specified by the context.
|
||||
// It returns false if the context is canceled before the events are sent. In such a case,
|
||||
// some events may not be delivered.
|
||||
// to the Sentry server, blocking for at most the duration specified by the
|
||||
// context. It returns false if capture is disabled or the context is canceled
|
||||
// before the events are sent. In the latter case, some events may not be
|
||||
// delivered.
|
||||
//
|
||||
// FlushWithContext should be called before terminating the program to ensure no
|
||||
// events are unintentionally dropped.
|
||||
@@ -375,13 +397,7 @@ func (hub *Hub) Flush(timeout time.Duration) bool {
|
||||
// configure the SDK to use HTTPSyncTransport during initialization with Init.
|
||||
|
||||
func (hub *Hub) FlushWithContext(ctx context.Context) bool {
|
||||
client := hub.Client()
|
||||
|
||||
if client == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
return client.FlushWithContext(ctx)
|
||||
return hub.Client().FlushWithContext(ctx)
|
||||
}
|
||||
|
||||
// GetTraceparent returns the current Sentry traceparent string, to be used as a HTTP header value
|
||||
|
||||
+36
@@ -48,6 +48,12 @@ func NewWrapResponseWriter(w http.ResponseWriter, protoMajor int) WrapResponseWr
|
||||
if fl && hj && rf {
|
||||
return &httpFancyWriter{bw}
|
||||
}
|
||||
if fl && hj {
|
||||
return &flushHijackWriter{bw}
|
||||
}
|
||||
if hj {
|
||||
return &hijackWriter{bw}
|
||||
}
|
||||
}
|
||||
if fl {
|
||||
return &flushWriter{bw}
|
||||
@@ -143,6 +149,36 @@ func (f *flushWriter) Flush() {
|
||||
|
||||
var _ http.Flusher = &flushWriter{}
|
||||
|
||||
// flushHijackWriter is a HTTP writer that additionally satisfies http.Flusher
|
||||
// and http.Hijacker, for writers that do not implement io.ReaderFrom.
|
||||
type flushHijackWriter struct {
|
||||
basicWriter
|
||||
}
|
||||
|
||||
func (f *flushHijackWriter) Flush() {
|
||||
f.wroteHeader = true
|
||||
f.ResponseWriter.(http.Flusher).Flush()
|
||||
}
|
||||
|
||||
func (f *flushHijackWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) {
|
||||
return f.ResponseWriter.(http.Hijacker).Hijack()
|
||||
}
|
||||
|
||||
var _ http.Flusher = &flushHijackWriter{}
|
||||
var _ http.Hijacker = &flushHijackWriter{}
|
||||
|
||||
// hijackWriter is a HTTP writer that additionally satisfies http.Hijacker, for
|
||||
// writers that implement neither http.Flusher nor io.ReaderFrom.
|
||||
type hijackWriter struct {
|
||||
basicWriter
|
||||
}
|
||||
|
||||
func (f *hijackWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) {
|
||||
return f.ResponseWriter.(http.Hijacker).Hijack()
|
||||
}
|
||||
|
||||
var _ http.Hijacker = &hijackWriter{}
|
||||
|
||||
// httpFancyWriter is a HTTP writer that additionally satisfies
|
||||
// http.Flusher, http.Hijacker, and io.ReaderFrom. It exists for the common case
|
||||
// of wrapping the http.ResponseWriter that package http gives you, in order to
|
||||
|
||||
+12
-8
@@ -3,6 +3,7 @@ package protocol
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -210,17 +211,20 @@ func (dsn *Dsn) SetOrgID(orgID uint64) {
|
||||
// GetAPIURL returns the URL of the envelope endpoint of the project
|
||||
// associated with the DSN.
|
||||
func (dsn Dsn) GetAPIURL() *url.URL {
|
||||
var rawURL string
|
||||
rawURL += fmt.Sprintf("%s://%s", dsn.scheme, dsn.host)
|
||||
host := dsn.host
|
||||
port := ""
|
||||
if dsn.port != dsn.scheme.defaultPort() {
|
||||
rawURL += fmt.Sprintf(":%d", dsn.port)
|
||||
port = strconv.Itoa(dsn.port)
|
||||
}
|
||||
if dsn.path != "" {
|
||||
rawURL += dsn.path
|
||||
// JoinHostPort correctly adds brackets for IPv6 hosts. However with an
|
||||
// empty port it leaves a trailing ":", which we trim to omit the default port.
|
||||
host = net.JoinHostPort(host, port)
|
||||
host = strings.TrimSuffix(host, ":")
|
||||
return &url.URL{
|
||||
Scheme: string(dsn.scheme),
|
||||
Host: host,
|
||||
Path: dsn.path + "/api/" + dsn.projectID + "/envelope/",
|
||||
}
|
||||
rawURL += fmt.Sprintf("/api/%s/%s/", dsn.projectID, "envelope")
|
||||
parsedURL, _ := url.Parse(rawURL)
|
||||
return parsedURL
|
||||
}
|
||||
|
||||
// RequestHeaders returns all the necessary headers that have to be used in the transport when sending events
|
||||
|
||||
+26
-2
@@ -26,6 +26,9 @@ type Scheduler struct {
|
||||
cancel context.CancelFunc
|
||||
processingWg sync.WaitGroup
|
||||
|
||||
// processing serializes buffer-to-transport handoffs and allows cancelable waits.
|
||||
processing chan struct{}
|
||||
|
||||
mu sync.Mutex
|
||||
cond *sync.Cond
|
||||
startOnce sync.Once
|
||||
@@ -79,6 +82,7 @@ func NewScheduler(
|
||||
currentCycle: currentCycle,
|
||||
ctx: ctx,
|
||||
cancel: cancel,
|
||||
processing: make(chan struct{}, 1),
|
||||
}
|
||||
s.cond = sync.NewCond(&s.mu)
|
||||
|
||||
@@ -145,7 +149,9 @@ func (s *Scheduler) Flush(timeout time.Duration) bool {
|
||||
}
|
||||
|
||||
func (s *Scheduler) FlushWithContext(ctx context.Context) bool {
|
||||
s.flushBuffers()
|
||||
if !s.flushBuffers(ctx) {
|
||||
return false
|
||||
}
|
||||
return s.transport.FlushWithContext(ctx)
|
||||
}
|
||||
|
||||
@@ -193,6 +199,13 @@ func (s *Scheduler) hasWork() bool {
|
||||
}
|
||||
|
||||
func (s *Scheduler) processNextBatch() {
|
||||
select {
|
||||
case s.processing <- struct{}{}:
|
||||
defer func() { <-s.processing }()
|
||||
case <-s.ctx.Done():
|
||||
return
|
||||
}
|
||||
|
||||
if len(s.currentCycle) == 0 {
|
||||
return
|
||||
}
|
||||
@@ -290,12 +303,23 @@ func (s *Scheduler) sendItem(item protocol.EnvelopeConvertible) {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Scheduler) flushBuffers() {
|
||||
func (s *Scheduler) flushBuffers(ctx context.Context) bool {
|
||||
select {
|
||||
case s.processing <- struct{}{}:
|
||||
defer func() { <-s.processing }()
|
||||
case <-ctx.Done():
|
||||
return false
|
||||
}
|
||||
|
||||
for category, buffer := range s.buffers {
|
||||
if ctx.Err() != nil {
|
||||
return false
|
||||
}
|
||||
if !buffer.IsEmpty() {
|
||||
s.processItems(buffer, category, true)
|
||||
}
|
||||
}
|
||||
return ctx.Err() == nil
|
||||
}
|
||||
|
||||
func (s *Scheduler) isRateLimited(category ratelimit.Category) bool {
|
||||
|
||||
+2
-2
@@ -60,7 +60,7 @@ func NewLogger(ctx context.Context) Logger { // nolint: dupl
|
||||
}
|
||||
|
||||
client := hub.Client()
|
||||
if client != nil {
|
||||
if client.IsEnabled() {
|
||||
// Build default attrs
|
||||
serverAddr := client.options.ServerName
|
||||
if serverAddr == "" {
|
||||
@@ -111,7 +111,7 @@ func (l *sentryLogger) log(ctx context.Context, level LogLevel, severity int, me
|
||||
hub = l.hub
|
||||
}
|
||||
client := hub.Client()
|
||||
if client == nil {
|
||||
if !client.IsEnabled() {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -55,7 +55,7 @@ func NewMeter(ctx context.Context) Meter {
|
||||
hub = CurrentHub()
|
||||
}
|
||||
client := hub.Client()
|
||||
if client != nil {
|
||||
if client.IsEnabled() {
|
||||
// build default attrs
|
||||
serverAddr := client.options.ServerName
|
||||
if serverAddr == "" {
|
||||
@@ -110,7 +110,7 @@ func (m *sentryMeter) emit(ctx context.Context, metricType MetricType, name stri
|
||||
}
|
||||
|
||||
client := hub.Client()
|
||||
if client == nil {
|
||||
if !client.IsEnabled() {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
+7
-2
@@ -4,6 +4,11 @@ import (
|
||||
"crypto/rand"
|
||||
)
|
||||
|
||||
const (
|
||||
traceIDContextKey = "trace_id"
|
||||
spanIDContextKey = "span_id"
|
||||
)
|
||||
|
||||
type PropagationContext struct {
|
||||
TraceID TraceID `json:"trace_id"`
|
||||
SpanID SpanID `json:"span_id"`
|
||||
@@ -13,8 +18,8 @@ type PropagationContext struct {
|
||||
|
||||
func (p PropagationContext) Map() map[string]interface{} {
|
||||
m := map[string]interface{}{
|
||||
"trace_id": p.TraceID,
|
||||
"span_id": p.SpanID,
|
||||
traceIDContextKey: p.TraceID,
|
||||
spanIDContextKey: p.SpanID,
|
||||
}
|
||||
|
||||
if p.ParentSpanID != zeroSpanID {
|
||||
|
||||
+33
-13
@@ -30,7 +30,15 @@ import (
|
||||
// an event for reporting, the current client adds information from the current
|
||||
// scope into the event.
|
||||
type Scope struct {
|
||||
mu sync.RWMutex
|
||||
mu sync.RWMutex
|
||||
// eventProcessors are retained by Clear and inherited by Clone.
|
||||
eventProcessors []EventProcessor
|
||||
|
||||
// scopeData keeps track of all scope specific data
|
||||
scopeData
|
||||
}
|
||||
|
||||
type scopeData struct {
|
||||
attributes map[string]attribute.Value
|
||||
breadcrumbs []*Breadcrumb
|
||||
attachments []*Attachment
|
||||
@@ -49,7 +57,6 @@ type Scope struct {
|
||||
// size.
|
||||
Overflow() bool
|
||||
}
|
||||
eventProcessors []EventProcessor
|
||||
|
||||
propagationContext PropagationContext
|
||||
span *Span
|
||||
@@ -57,14 +64,18 @@ type Scope struct {
|
||||
|
||||
// NewScope creates a new Scope.
|
||||
func NewScope() *Scope {
|
||||
return &Scope{
|
||||
return &Scope{scopeData: newScopeData(NewPropagationContext())}
|
||||
}
|
||||
|
||||
func newScopeData(propagationContext PropagationContext) scopeData {
|
||||
return scopeData{
|
||||
attributes: make(map[string]attribute.Value),
|
||||
breadcrumbs: make([]*Breadcrumb, 0),
|
||||
attachments: make([]*Attachment, 0),
|
||||
tags: make(map[string]string),
|
||||
contexts: make(map[string]Context),
|
||||
fingerprint: make([]string, 0),
|
||||
propagationContext: NewPropagationContext(),
|
||||
propagationContext: propagationContext,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -282,6 +293,7 @@ func (scope *Scope) Clone() *Scope {
|
||||
|
||||
clone := NewScope()
|
||||
clone.user = scope.user
|
||||
clone.user.Data = maps.Clone(scope.user.Data)
|
||||
clone.breadcrumbs = make([]*Breadcrumb, len(scope.breadcrumbs))
|
||||
copy(clone.breadcrumbs, scope.breadcrumbs)
|
||||
clone.attachments = make([]*Attachment, len(scope.attachments))
|
||||
@@ -300,9 +312,16 @@ func (scope *Scope) Clone() *Scope {
|
||||
return clone
|
||||
}
|
||||
|
||||
// Clear removes the data from the current scope. Not safe for concurrent use.
|
||||
// Clear removes enrichment data while preserving event processors and trace
|
||||
// correlation. It is safe for concurrent use.
|
||||
func (scope *Scope) Clear() {
|
||||
*scope = *NewScope()
|
||||
scope.mu.Lock()
|
||||
defer scope.mu.Unlock()
|
||||
|
||||
propagationContext := scope.propagationContext
|
||||
span := scope.span
|
||||
scope.scopeData = newScopeData(propagationContext)
|
||||
scope.span = span
|
||||
}
|
||||
|
||||
// AddEventProcessor adds an event processor to the current scope.
|
||||
@@ -375,7 +394,7 @@ func (scope *Scope) ApplyToEvent(event *Event, hint *EventHint, client *Client)
|
||||
event.Contexts["trace"] = scope.propagationContext.Map()
|
||||
|
||||
dsc := scope.propagationContext.DynamicSamplingContext
|
||||
if !dsc.HasEntries() && client != nil {
|
||||
if !dsc.HasEntries() && client.IsEnabled() {
|
||||
dsc = DynamicSamplingContextFromScope(scope, client)
|
||||
}
|
||||
event.sdkMetaData.dsc = dsc
|
||||
@@ -383,7 +402,7 @@ func (scope *Scope) ApplyToEvent(event *Event, hint *EventHint, client *Client)
|
||||
|
||||
// If an external trace resolver is registered (e.g. OTel), override
|
||||
// trace/span IDs from the hint context or the scope's request context.
|
||||
if client != nil {
|
||||
if client.IsEnabled() {
|
||||
var ctx context.Context
|
||||
if hint != nil {
|
||||
ctx = hint.Context
|
||||
@@ -393,13 +412,14 @@ func (scope *Scope) ApplyToEvent(event *Event, hint *EventHint, client *Client)
|
||||
}
|
||||
if traceID, spanID, ok := client.externalTraceContextFromContext(ctx); event.Type != transactionType && ok {
|
||||
traceCtx := event.Contexts["trace"]
|
||||
traceCtx["trace_id"] = traceID.String()
|
||||
traceCtx["span_id"] = spanID.String()
|
||||
traceCtx[traceIDContextKey] = traceID.String()
|
||||
traceCtx[spanIDContextKey] = spanID.String()
|
||||
}
|
||||
}
|
||||
|
||||
if event.User.IsEmpty() {
|
||||
event.User = scope.user
|
||||
event.User.Data = maps.Clone(scope.user.Data)
|
||||
}
|
||||
|
||||
if len(event.Fingerprint) == 0 {
|
||||
@@ -434,7 +454,7 @@ func (scope *Scope) ApplyToEvent(event *Event, hint *EventHint, client *Client)
|
||||
event = processor(event, hint)
|
||||
if event == nil {
|
||||
debuglog.Printf("Event dropped by one of the Scope EventProcessors: %s\n", id)
|
||||
if client != nil {
|
||||
if client.IsEnabled() {
|
||||
client.reportRecorder.RecordOne(report.ReasonEventProcessor, category)
|
||||
if category == ratelimit.CategoryTransaction {
|
||||
client.reportRecorder.Record(report.ReasonEventProcessor, ratelimit.CategorySpan, int64(spanCountBefore))
|
||||
@@ -443,7 +463,7 @@ func (scope *Scope) ApplyToEvent(event *Event, hint *EventHint, client *Client)
|
||||
return nil
|
||||
}
|
||||
if droppedSpans := spanCountBefore - event.GetSpanCount(); droppedSpans > 0 {
|
||||
if client != nil {
|
||||
if client.IsEnabled() {
|
||||
client.reportRecorder.Record(report.ReasonEventProcessor, ratelimit.CategorySpan, int64(droppedSpans))
|
||||
}
|
||||
}
|
||||
@@ -524,7 +544,7 @@ func resolveTrace(scope *Scope, client *Client, ctxs ...context.Context) (traceI
|
||||
if ctx == nil {
|
||||
continue
|
||||
}
|
||||
if client != nil {
|
||||
if client.IsEnabled() {
|
||||
if traceID, spanID, ok := client.externalTraceContextFromContext(ctx); ok {
|
||||
return traceID, spanID
|
||||
}
|
||||
|
||||
+25
-4
@@ -6,7 +6,7 @@ import (
|
||||
)
|
||||
|
||||
// The version of the SDK.
|
||||
const SDKVersion = "0.49.0"
|
||||
const SDKVersion = "0.50.0"
|
||||
|
||||
// apiVersion is the minimum version of the Sentry API compatible with the
|
||||
// sentry-go SDK.
|
||||
@@ -54,6 +54,26 @@ func CaptureCheckIn(checkIn *CheckIn, monitorConfig *MonitorConfig) *EventID {
|
||||
return hub.CaptureCheckIn(checkIn, monitorConfig)
|
||||
}
|
||||
|
||||
// WithMonitor runs fn and reports its outcome as check-ins for the cron
|
||||
// monitor identified by monitorSlug, creating or updating the monitor with
|
||||
// monitorConfig when it is not nil. It is a shorthand for
|
||||
// CurrentHub().WithMonitor.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// err := sentry.WithMonitor("nightly-cleanup", &sentry.MonitorConfig{
|
||||
// Schedule: sentry.CrontabSchedule("0 3 * * *"),
|
||||
// CheckInMargin: 5,
|
||||
// MaxRuntime: 30,
|
||||
// Timezone: "UTC",
|
||||
// }, func() error {
|
||||
// return cleanup()
|
||||
// })
|
||||
func WithMonitor(monitorSlug string, monitorConfig *MonitorConfig, fn func() error) error {
|
||||
hub := CurrentHub()
|
||||
return hub.WithMonitor(monitorSlug, monitorConfig, fn)
|
||||
}
|
||||
|
||||
// CaptureEvent captures an event on the currently active client if any.
|
||||
//
|
||||
// The event must already be assembled. Typically code would instead use
|
||||
@@ -129,9 +149,10 @@ func Flush(timeout time.Duration) bool {
|
||||
}
|
||||
|
||||
// FlushWithContext waits until the underlying Transport sends any buffered events
|
||||
// to the Sentry server, blocking for at most the duration specified by the context.
|
||||
// It returns false if the context is canceled before the events are sent. In such a case,
|
||||
// some events may not be delivered.
|
||||
// to the Sentry server, blocking for at most the duration specified by the
|
||||
// context. It returns false if capture is disabled or the context is canceled
|
||||
// before the events are sent. In the latter case, some events may not be
|
||||
// delivered.
|
||||
//
|
||||
// FlushWithContext should be called before terminating the program to ensure no
|
||||
// events are unintentionally dropped.
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ type spanRecorder struct {
|
||||
// span tree.
|
||||
func (r *spanRecorder) record(s *Span) {
|
||||
maxSpans := defaultMaxSpans
|
||||
if client := CurrentHub().Client(); client != nil {
|
||||
if client := CurrentHub().Client(); client.IsEnabled() {
|
||||
maxSpans = client.options.MaxSpans
|
||||
}
|
||||
r.mu.Lock()
|
||||
|
||||
+4
-4
@@ -551,7 +551,7 @@ func (s *Span) updateFromBaggage(header []byte) {
|
||||
|
||||
func (s *Span) clientOptions() *ClientOptions {
|
||||
client := hubFromContext(s.ctx).Client()
|
||||
if client != nil {
|
||||
if client.IsEnabled() {
|
||||
return &client.options
|
||||
}
|
||||
return &ClientOptions{}
|
||||
@@ -933,8 +933,8 @@ type TraceContext struct {
|
||||
|
||||
func (tc TraceContext) Map() map[string]interface{} {
|
||||
m := map[string]interface{}{
|
||||
"trace_id": tc.TraceID,
|
||||
"span_id": tc.SpanID,
|
||||
traceIDContextKey: tc.TraceID,
|
||||
spanIDContextKey: tc.SpanID,
|
||||
}
|
||||
|
||||
if tc.ParentSpanID != [8]byte{} {
|
||||
@@ -1202,7 +1202,7 @@ func HTTPtoSpanStatus(code int) SpanStatus {
|
||||
}
|
||||
|
||||
func shouldContinueTrace(client *Client, dsc DynamicSamplingContext) bool {
|
||||
if client == nil {
|
||||
if !client.IsEnabled() {
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user