Skip to content

Commit

Permalink
avoided potential panic due to divide by 0 (#5412)
Browse files Browse the repository at this point in the history
Signed-off-by: Aditi Ahuja <ahuja.aditi@gmail.com>
  • Loading branch information
metonymic-smokey committed Jun 9, 2022
1 parent 54a0deb commit 296c4ab
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/tracing/google_cloud/google_cloud.go
Expand Up @@ -52,9 +52,11 @@ func newTracerProvider(ctx context.Context, logger log.Logger, processor tracesd
level.Warn(logger).Log("msg", "detecting resources for tracing provider failed", "err", err)
}

fraction := 1 / float64(sampleFactor)
var fraction float64
if sampleFactor == 0 {
fraction = 0
} else {
fraction = 1 / float64(sampleFactor)
}

tp := tracesdk.NewTracerProvider(
Expand Down

0 comments on commit 296c4ab

Please sign in to comment.