-
Notifications
You must be signed in to change notification settings - Fork 662
/
traced_engine.go
42 lines (32 loc) · 997 Bytes
/
traced_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
// Copyright (C) 2019-2022, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package avalanche
import (
"context"
"go.opentelemetry.io/otel/attribute"
oteltrace "go.opentelemetry.io/otel/trace"
"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/snow/consensus/avalanche"
"github.com/ava-labs/avalanchego/snow/engine/common"
"github.com/ava-labs/avalanchego/trace"
)
var _ Engine = (*tracedEngine)(nil)
type tracedEngine struct {
common.Engine
engine Engine
tracer trace.Tracer
}
func TraceEngine(engine Engine, tracer trace.Tracer) Engine {
return &tracedEngine{
Engine: common.TraceEngine(engine, tracer),
engine: engine,
tracer: tracer,
}
}
func (e *tracedEngine) GetVtx(ctx context.Context, vtxID ids.ID) (avalanche.Vertex, error) {
ctx, span := e.tracer.Start(ctx, "tracedEngine.GetVtx", oteltrace.WithAttributes(
attribute.Stringer("vtxID", vtxID),
))
defer span.End()
return e.engine.GetVtx(ctx, vtxID)
}