-
Notifications
You must be signed in to change notification settings - Fork 671
/
tx.go
50 lines (36 loc) · 1.08 KB
/
tx.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
44
45
46
47
48
49
50
// Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package tracedvm
import (
"context"
"go.opentelemetry.io/otel/attribute"
oteltrace "go.opentelemetry.io/otel/trace"
"github.com/ava-labs/avalanchego/snow/consensus/snowstorm"
"github.com/ava-labs/avalanchego/trace"
)
var _ snowstorm.Tx = (*tracedTx)(nil)
type tracedTx struct {
snowstorm.Tx
tracer trace.Tracer
}
func (t *tracedTx) Verify(ctx context.Context) error {
ctx, span := t.tracer.Start(ctx, "tracedTx.Verify", oteltrace.WithAttributes(
attribute.Stringer("txID", t.ID()),
))
defer span.End()
return t.Tx.Verify(ctx)
}
func (t *tracedTx) Accept(ctx context.Context) error {
ctx, span := t.tracer.Start(ctx, "tracedTx.Accept", oteltrace.WithAttributes(
attribute.Stringer("txID", t.ID()),
))
defer span.End()
return t.Tx.Accept(ctx)
}
func (t *tracedTx) Reject(ctx context.Context) error {
ctx, span := t.tracer.Start(ctx, "tracedTx.Reject", oteltrace.WithAttributes(
attribute.Stringer("txID", t.ID()),
))
defer span.End()
return t.Tx.Reject(ctx)
}