Skip to content
File

Blob: src/workerd/io/trace.capnp

1.7 KB
1# Copyright (c) 2017-2022 Cloudflare, Inc.
2# Licensed under the Apache 2.0 license found in the LICENSE file or at:
3# https://opensource.org/licenses/Apache-2.0
4 
5@0xc40f73be329a38d9;
6 
7using Cxx = import "/capnp/c++.capnp";
8$Cxx.namespace("workerd::rpc");
9 
10# This file contains trace helper structures. The Trace struct is deliberately not defined here –
11# many files just need to have the span/tag definitions available. Since Trace contains interfaces,
12# it also causes a large amount of code to be generated in the .capnp.h file, which affects header
13# parsing overhead/compile times for every file that depends on the capnp file defining Trace.
14 
15# The value of a span tag.
16struct TagValue {
17 union {
18 string @0 :Text;
19 bool @1 :Bool;
20 int64 @2 :Int64;
21 float64 @3 :Float64;
22 }
23}
24 
25# A key/value span tag for tracing.
26struct Tag {
27 key @0 :Text;
28 value @1 :TagValue;
29}
30 
31struct UserSpanData {
32 # Representation of a completed user span
33 operationName @0 :Text;
34 
35 startTimeNs @1 :Int64;
36 endTimeNs @2 :Int64;
37 # Nanoseconds since Unix epoch
38 
39 tags @3 :List(Tag);
40 
41 spanId @4 :UInt64;
42 parentSpanId @5 :UInt64;
43}
44 
45struct SpanOpenData {
46 # Representation of a SpanOpen event, created when a user span is opened.
47 operationName @0 :Text;
48 
49 startTimeNs @1 :Int64;
50 # Nanoseconds since Unix epoch
51 
52 spanId @2 :UInt64;
53 parentSpanId @3 :UInt64;
54}
55 
56struct SpanEndData {
57 # Representation of an event that indicates completion of a user span. This information is
58 # provided to the streaming tail worker in the Attributes and SpanClose events.
59 
60 endTimeNs @0 :Int64;
61 # Nanoseconds since Unix epoch
62 
63 # List of span attributes
64 tags @1 :List(Tag);
65 spanId @2 :UInt64;
66}