Skip to content

Commit

Permalink
Update _examples
Browse files Browse the repository at this point in the history
  • Loading branch information
cleptric committed Mar 21, 2023
1 parent 265459b commit cb8009a
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions _examples/http/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,24 +70,11 @@ func run() error {
TracesSampleRate: 1.0,
// ... or a TracesSampler
TracesSampler: sentry.TracesSampler(func(ctx sentry.SamplingContext) float64 {
// As an example, this custom sampler does not send some
// transactions to Sentry based on their name.
hub := sentry.GetHubFromContext(ctx.Span.Context())
name := hub.Scope().Transaction()
if name == "GET /favicon.ico" {
// Don't sample health checks.
if ctx.Span.Name == "GET /health" {
return 0.0
}
if strings.HasPrefix(name, "HEAD") {
return 0.0
}
// As an example, sample some transactions with a uniform rate.
if strings.HasPrefix(name, "POST") {
return 0.2
}
// Sample all other transactions for testing. On
// production, use TracesSampleRate with a rate adequate
// for your traffic, or use the SamplingContext to
// customize sampling per-transaction.

return 1.0
}),
})
Expand Down

0 comments on commit cb8009a

Please sign in to comment.