chore: optimize code (#1818)

Signed-off-by: chenquan <chenquan.dev@gmail.com>
This commit is contained in:
chen quan
2022-04-23 09:02:04 -05:00
committed by GitHub
parent 095b603788
commit 22b157bb6c
3 changed files with 14 additions and 17 deletions

View File

@@ -16,7 +16,11 @@ import (
tracesdk "go.opentelemetry.io/otel/trace"
)
const defaultSlowThreshold = time.Millisecond * 500
const (
defaultSlowThreshold = time.Millisecond * 500
// spanName is the span name of the mongo calls.
spanName = "mongo"
)
// ErrNotFound is an alias of mongo.ErrNoDocuments
var ErrNotFound = mongo.ErrNoDocuments
@@ -482,5 +486,5 @@ func acceptable(err error) bool {
func startSpan(ctx context.Context) (context.Context, tracesdk.Span) {
tracer := otel.GetTracerProvider().Tracer(trace.TraceName)
return tracer.Start(ctx, "mongo")
return tracer.Start(ctx, spanName)
}