opentelemetry_trace.proto 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. // Copyright 2019, OpenTelemetry Authors
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. syntax = "proto3";
  15. package opentelemetry.proto.trace.v1;
  16. import "opentelemetry_common.proto";
  17. import "opentelemetry_resource.proto";
  18. // A collection of InstrumentationLibrarySpans from a Resource.
  19. // TracesData represents the traces data that can be stored in a persistent storage,
  20. // OR can be embedded by other protocols that transfer OTLP traces data but do
  21. // not implement the OTLP protocol.
  22. //
  23. // The main difference between this message and collector protocol is that
  24. // in this message there will not be any "control" or "metadata" specific to
  25. // OTLP protocol.
  26. //
  27. // When new fields are added into this message, the OTLP request MUST be updated
  28. // as well.
  29. message TracesData {
  30. // An array of ResourceSpans.
  31. // For data coming from a single resource this array will typically contain
  32. // one element. Intermediary nodes that receive data from multiple origins
  33. // typically batch the data before forwarding further and in that case this
  34. // array will contain multiple elements.
  35. repeated ResourceSpans resource_spans = 1;
  36. }
  37. // A collection of ScopeSpans from a Resource.
  38. message ResourceSpans {
  39. // The resource for the spans in this message.
  40. // If this field is not set then no resource info is known.
  41. opentelemetry.proto.resource.v1.Resource resource = 1;
  42. // A list of InstrumentationLibrarySpans that originate from a resource.
  43. repeated InstrumentationLibrarySpans instrumentation_library_spans = 2;
  44. // This schema_url applies to the data in the "resource" field. It does not apply
  45. // to the data in the "instrumentation_library_spans" field which have their own
  46. // schema_url field.
  47. string schema_url = 3;
  48. }
  49. // A collection of Spans produced by an InstrumentationLibrary.
  50. message InstrumentationLibrarySpans {
  51. // The instrumentation library information for the spans in this message.
  52. // Semantically when InstrumentationLibrary isn't set, it is equivalent with
  53. // an empty instrumentation library name (unknown).
  54. opentelemetry.proto.common.v1.InstrumentationLibrary instrumentation_library = 1;
  55. // A list of Spans that originate from an instrumentation library.
  56. repeated Span spans = 2;
  57. // This schema_url applies to all spans and span events in the "spans" field.
  58. string schema_url = 3;
  59. }
  60. // Span represents a single operation within a trace. Spans can be
  61. // nested to form a trace tree. Spans may also be linked to other spans
  62. // from the same or different trace and form graphs. Often, a trace
  63. // contains a root span that describes the end-to-end latency, and one
  64. // or more subspans for its sub-operations. A trace can also contain
  65. // multiple root spans, or none at all. Spans do not need to be
  66. // contiguous - there may be gaps or overlaps between spans in a trace.
  67. //
  68. // The next available field id is 17.
  69. message Span {
  70. // A unique identifier for a trace. All spans from the same trace share
  71. // the same `trace_id`. The ID is a 16-byte array. An ID with all zeroes
  72. // is considered invalid.
  73. //
  74. // This field is semantically required. Receiver should generate new
  75. // random trace_id if empty or invalid trace_id was received.
  76. //
  77. // This field is required.
  78. bytes trace_id = 1;
  79. // A unique identifier for a span within a trace, assigned when the span
  80. // is created. The ID is an 8-byte array. An ID with all zeroes is considered
  81. // invalid.
  82. //
  83. // This field is semantically required. Receiver should generate new
  84. // random span_id if empty or invalid span_id was received.
  85. //
  86. // This field is required.
  87. bytes span_id = 2;
  88. // trace_state conveys information about request position in multiple distributed tracing graphs.
  89. // It is a trace_state in w3c-trace-context format: https://www.w3.org/TR/trace-context/#tracestate-header
  90. // See also https://github.com/w3c/distributed-tracing for more details about this field.
  91. string trace_state = 3;
  92. // The `span_id` of this span's parent span. If this is a root span, then this
  93. // field must be empty. The ID is an 8-byte array.
  94. bytes parent_span_id = 4;
  95. // A description of the span's operation.
  96. //
  97. // For example, the name can be a qualified method name or a file name
  98. // and a line number where the operation is called. A best practice is to use
  99. // the same display name at the same call point in an application.
  100. // This makes it easier to correlate spans in different traces.
  101. //
  102. // This field is semantically required to be set to non-empty string.
  103. // When null or empty string received - receiver may use string "name"
  104. // as a replacement. There might be smarted algorithms implemented by
  105. // receiver to fix the empty span name.
  106. //
  107. // This field is required.
  108. string name = 5;
  109. // SpanKind is the type of span. Can be used to specify additional relationships between spans
  110. // in addition to a parent/child relationship.
  111. enum SpanKind {
  112. // Unspecified. Do NOT use as default.
  113. // Implementations MAY assume SpanKind to be INTERNAL when receiving UNSPECIFIED.
  114. SPAN_KIND_UNSPECIFIED = 0;
  115. // Indicates that the span represents an internal operation within an application,
  116. // as opposed to an operation happening at the boundaries. Default value.
  117. SPAN_KIND_INTERNAL = 1;
  118. // Indicates that the span covers server-side handling of an RPC or other
  119. // remote network request.
  120. SPAN_KIND_SERVER = 2;
  121. // Indicates that the span describes a request to some remote service.
  122. SPAN_KIND_CLIENT = 3;
  123. // Indicates that the span describes a producer sending a message to a broker.
  124. // Unlike CLIENT and SERVER, there is often no direct critical path latency relationship
  125. // between producer and consumer spans. A PRODUCER span ends when the message was accepted
  126. // by the broker while the logical processing of the message might span a much longer time.
  127. SPAN_KIND_PRODUCER = 4;
  128. // Indicates that the span describes consumer receiving a message from a broker.
  129. // Like the PRODUCER kind, there is often no direct critical path latency relationship
  130. // between producer and consumer spans.
  131. SPAN_KIND_CONSUMER = 5;
  132. }
  133. // Distinguishes between spans generated in a particular context. For example,
  134. // two spans with the same name may be distinguished using `CLIENT` (caller)
  135. // and `SERVER` (callee) to identify queueing latency associated with the span.
  136. SpanKind kind = 6;
  137. // start_time_unix_nano is the start time of the span. On the client side, this is the time
  138. // kept by the local machine where the span execution starts. On the server side, this
  139. // is the time when the server's application handler starts running.
  140. // Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970.
  141. //
  142. // This field is semantically required and it is expected that end_time >= start_time.
  143. fixed64 start_time_unix_nano = 7;
  144. // end_time_unix_nano is the end time of the span. On the client side, this is the time
  145. // kept by the local machine where the span execution ends. On the server side, this
  146. // is the time when the server application handler stops running.
  147. // Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970.
  148. //
  149. // This field is semantically required and it is expected that end_time >= start_time.
  150. fixed64 end_time_unix_nano = 8;
  151. // attributes is a collection of key/value pairs. The value can be a string,
  152. // an integer, a double or the Boolean values `true` or `false`. Note, global attributes
  153. // like server name can be set using the resource API. Examples of attributes:
  154. //
  155. // "/http/user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36"
  156. // "/http/server_latency": 300
  157. // "abc.com/myattribute": true
  158. // "abc.com/score": 10.239
  159. repeated opentelemetry.proto.common.v1.KeyValue attributes = 9;
  160. // dropped_attributes_count is the number of attributes that were discarded. Attributes
  161. // can be discarded because their keys are too long or because there are too many
  162. // attributes. If this value is 0, then no attributes were dropped.
  163. uint32 dropped_attributes_count = 10;
  164. // Event is a time-stamped annotation of the span, consisting of user-supplied
  165. // text description and key-value pairs.
  166. message Event {
  167. // time_unix_nano is the time the event occurred.
  168. fixed64 time_unix_nano = 1;
  169. // name of the event.
  170. // This field is semantically required to be set to non-empty string.
  171. string name = 2;
  172. // attributes is a collection of attribute key/value pairs on the event.
  173. repeated opentelemetry.proto.common.v1.KeyValue attributes = 3;
  174. // dropped_attributes_count is the number of dropped attributes. If the value is 0,
  175. // then no attributes were dropped.
  176. uint32 dropped_attributes_count = 4;
  177. }
  178. // events is a collection of Event items.
  179. repeated Event events = 11;
  180. // dropped_events_count is the number of dropped events. If the value is 0, then no
  181. // events were dropped.
  182. uint32 dropped_events_count = 12;
  183. // A pointer from the current span to another span in the same trace or in a
  184. // different trace. For example, this can be used in batching operations,
  185. // where a single batch handler processes multiple requests from different
  186. // traces or when the handler receives a request from a different project.
  187. message Link {
  188. // A unique identifier of a trace that this linked span is part of. The ID is a
  189. // 16-byte array.
  190. bytes trace_id = 1;
  191. // A unique identifier for the linked span. The ID is an 8-byte array.
  192. bytes span_id = 2;
  193. // The trace_state associated with the link.
  194. string trace_state = 3;
  195. // attributes is a collection of attribute key/value pairs on the link.
  196. repeated opentelemetry.proto.common.v1.KeyValue attributes = 4;
  197. // dropped_attributes_count is the number of dropped attributes. If the value is 0,
  198. // then no attributes were dropped.
  199. uint32 dropped_attributes_count = 5;
  200. }
  201. // links is a collection of Links, which are references from this span to a span
  202. // in the same or different trace.
  203. repeated Link links = 13;
  204. // dropped_links_count is the number of dropped links after the maximum size was
  205. // enforced. If this value is 0, then no links were dropped.
  206. uint32 dropped_links_count = 14;
  207. // An optional final status for this span. Semantically when Status isn't set, it means
  208. // span's status code is unset, i.e. assume STATUS_CODE_UNSET (code = 0).
  209. Status status = 15;
  210. }
  211. // The Status type defines a logical error model that is suitable for different
  212. // programming environments, including REST APIs and RPC APIs.
  213. message Status {
  214. // IMPORTANT: Backward compatibility notes:
  215. // The deprecated status code. This is an optional field.
  216. // DeprecatedStatusCode deprecated_code = 1 [deprecated=true];
  217. // A developer-facing human readable error message.
  218. string message = 2;
  219. // For the semantics of status codes see
  220. // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/api.md#set-status
  221. enum StatusCode {
  222. // The default status.
  223. STATUS_CODE_UNSET = 0;
  224. // The Span has been validated by an Application developers or Operator to have
  225. // completed successfully.
  226. STATUS_CODE_OK = 1;
  227. // The Span contains an error.
  228. STATUS_CODE_ERROR = 2;
  229. };
  230. // The status code.
  231. StatusCode code = 3;
  232. }