-
Notifications
You must be signed in to change notification settings - Fork 662
/
traced_bootstrapable_engine.go
43 lines (32 loc) · 1.21 KB
/
traced_bootstrapable_engine.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Copyright (C) 2019-2022, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package common
import (
"context"
"go.opentelemetry.io/otel/attribute"
oteltrace "go.opentelemetry.io/otel/trace"
"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/trace"
)
var _ BootstrapableEngine = (*tracedBootstrapableEngine)(nil)
type tracedBootstrapableEngine struct {
Engine
bootstrapableEngine BootstrapableEngine
tracer trace.Tracer
}
func TraceBootstrapableEngine(bootstrapableEngine BootstrapableEngine, tracer trace.Tracer) BootstrapableEngine {
return &tracedBootstrapableEngine{
Engine: TraceEngine(bootstrapableEngine, tracer),
bootstrapableEngine: bootstrapableEngine,
}
}
func (e *tracedBootstrapableEngine) ForceAccepted(ctx context.Context, acceptedContainerIDs []ids.ID) error {
ctx, span := e.tracer.Start(ctx, "tracedBootstrapableEngine.ForceAccepted", oteltrace.WithAttributes(
attribute.Int("numAcceptedContainerIDs", len(acceptedContainerIDs)),
))
defer span.End()
return e.bootstrapableEngine.ForceAccepted(ctx, acceptedContainerIDs)
}
func (e *tracedBootstrapableEngine) Clear() error {
return e.bootstrapableEngine.Clear()
}