Skip to content

Commit 1a12113

Browse files
committed
add Span
1 parent c7cf965 commit 1a12113

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

span.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package progrock
2+
3+
import (
4+
"context"
5+
6+
"github.com/opencontainers/go-digest"
7+
)
8+
9+
// Span ties together lower-level Progrock APIs to provide a higher-level
10+
// OpenTelemetry-style API, using a Vertex like a span.
11+
func Span(ctx context.Context, id, name string, opts ...VertexOpt) (context.Context, *VertexRecorder) {
12+
rec := FromContext(ctx)
13+
vtx := rec.Vertex(digest.Digest(id), name, opts...)
14+
rec = rec.WithParent(vtx.Vertex.Id)
15+
ctx = ToContext(ctx, rec)
16+
return ctx, vtx
17+
}

0 commit comments

Comments
 (0)