github.com/v2fly/tools@v0.100.0/internal/event/export/ocagent/wire/trace.go (about)

     1  // Copyright 2019 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package wire
     6  
     7  type ExportTraceServiceRequest struct {
     8  	Node     *Node     `json:"node,omitempty"`
     9  	Spans    []*Span   `json:"spans,omitempty"`
    10  	Resource *Resource `json:"resource,omitempty"`
    11  }
    12  
    13  type Span struct {
    14  	TraceID                 []byte             `json:"trace_id,omitempty"`
    15  	SpanID                  []byte             `json:"span_id,omitempty"`
    16  	TraceState              *TraceState        `json:"tracestate,omitempty"`
    17  	ParentSpanID            []byte             `json:"parent_span_id,omitempty"`
    18  	Name                    *TruncatableString `json:"name,omitempty"`
    19  	Kind                    SpanKind           `json:"kind,omitempty"`
    20  	StartTime               Timestamp          `json:"start_time,omitempty"`
    21  	EndTime                 Timestamp          `json:"end_time,omitempty"`
    22  	Attributes              *Attributes        `json:"attributes,omitempty"`
    23  	StackTrace              *StackTrace        `json:"stack_trace,omitempty"`
    24  	TimeEvents              *TimeEvents        `json:"time_events,omitempty"`
    25  	Links                   *Links             `json:"links,omitempty"`
    26  	Status                  *Status            `json:"status,omitempty"`
    27  	Resource                *Resource          `json:"resource,omitempty"`
    28  	SameProcessAsParentSpan bool               `json:"same_process_as_parent_span,omitempty"`
    29  	ChildSpanCount          bool               `json:"child_span_count,omitempty"`
    30  }
    31  
    32  type TraceState struct {
    33  	Entries []*TraceStateEntry `json:"entries,omitempty"`
    34  }
    35  
    36  type TraceStateEntry struct {
    37  	Key   string `json:"key,omitempty"`
    38  	Value string `json:"value,omitempty"`
    39  }
    40  
    41  type SpanKind int32
    42  
    43  const (
    44  	UnspecifiedSpanKind SpanKind = 0
    45  	ServerSpanKind      SpanKind = 1
    46  	ClientSpanKind      SpanKind = 2
    47  )
    48  
    49  type TimeEvents struct {
    50  	TimeEvent                 []TimeEvent `json:"timeEvent,omitempty"`
    51  	DroppedAnnotationsCount   int32       `json:"dropped_annotations_count,omitempty"`
    52  	DroppedMessageEventsCount int32       `json:"dropped_message_events_count,omitempty"`
    53  }
    54  
    55  type TimeEvent struct {
    56  	Time         Timestamp     `json:"time,omitempty"`
    57  	MessageEvent *MessageEvent `json:"messageEvent,omitempty"`
    58  	Annotation   *Annotation   `json:"annotation,omitempty"`
    59  }
    60  
    61  type Annotation struct {
    62  	Description *TruncatableString `json:"description,omitempty"`
    63  	Attributes  *Attributes        `json:"attributes,omitempty"`
    64  }
    65  
    66  type MessageEvent struct {
    67  	Type             MessageEventType `json:"type,omitempty"`
    68  	ID               uint64           `json:"id,omitempty"`
    69  	UncompressedSize uint64           `json:"uncompressed_size,omitempty"`
    70  	CompressedSize   uint64           `json:"compressed_size,omitempty"`
    71  }
    72  
    73  type MessageEventType int32
    74  
    75  const (
    76  	UnspecifiedMessageEvent MessageEventType = iota
    77  	SentMessageEvent
    78  	ReceivedMessageEvent
    79  )
    80  
    81  type TimeEventValue interface {
    82  	labelTimeEventValue()
    83  }
    84  
    85  func (Annotation) labelTimeEventValue()   {}
    86  func (MessageEvent) labelTimeEventValue() {}
    87  
    88  type Links struct {
    89  	Link              []*Link `json:"link,omitempty"`
    90  	DroppedLinksCount int32   `json:"dropped_links_count,omitempty"`
    91  }
    92  
    93  type Link struct {
    94  	TraceID    []byte      `json:"trace_id,omitempty"`
    95  	SpanID     []byte      `json:"span_id,omitempty"`
    96  	Type       LinkType    `json:"type,omitempty"`
    97  	Attributes *Attributes `json:"attributes,omitempty"`
    98  	TraceState *TraceState `json:"tracestate,omitempty"`
    99  }
   100  
   101  type LinkType int32
   102  
   103  const (
   104  	UnspecifiedLinkType LinkType = 0
   105  	ChildLinkType       LinkType = 1
   106  	ParentLinkType      LinkType = 2
   107  )
   108  
   109  type Status struct {
   110  	Code    int32  `json:"code,omitempty"`
   111  	Message string `json:"message,omitempty"`
   112  }