OTLP-Traces v1.0
The schema of an OTLP/JSON document of traces - opentelemetry.proto.trace.v1.TracesData in the
JSON Protobuf Encoding of the OpenTelemetry
Protocol. TraceCollection validates a document against it before reading it, and
Trace.WriteOTLPJSONFile() writes documents it accepts.
It states what the encoding requires: lowerCamelCase field names, trace and span identifiers as 32 and 16
hexadecimal digits in either case and never all zeros, an empty parentSpanId for a root span, enumeration values
as integers, 64-bit integers as decimal strings or numbers, attribute keys that aren’t empty, and an AnyValue
naming at most one value. Fields with unknown names are allowed, because an OTLP/JSON receiver ignores them.
What a schema can’t state is checked by the reader: two spans or two attributes with the same key, an end before the
start, a timestamp a datetime can’t hold, and spans referencing each other in a cycle.
Download
OTLP-Traces-v1.0.schema.json (9.2 kiB)
Validate a document
check-jsonschema --schemafile OTLP-Traces-v1.0.schema.json Pipeline.otlp.json
See also
- Overview
→ Reading and writing traces as OTLP/JSON.
Source
1{
2 "$schema": "https://json-schema.org/draft/2020-12/schema",
3 "$id": "https://pyTooling.GitHub.io/pyTooling/Schemas/OTLP-Traces-v1.0.schema.json",
4 "title": "OTLP/JSON traces",
5 "description": "An OTLP/JSON document of traces: 'opentelemetry.proto.trace.v1.TracesData' in the JSON Protobuf Encoding of the OpenTelemetry Protocol (lowerCamelCase field names, hex-encoded trace and span identifiers, integer enumeration values, 64-bit integers as decimal strings or numbers). Fields with unknown names are allowed, because an OTLP/JSON receiver must ignore them.",
6 "type": "object",
7 "properties": {
8 "resourceSpans": {
9 "description": "The spans, grouped by the resource that produced them.",
10 "type": "array",
11 "items": {
12 "$ref": "#/$defs/ResourceSpans"
13 }
14 }
15 },
16 "$defs": {
17 "ResourceSpans": {
18 "description": "'ResourceSpans': the spans produced by one resource.",
19 "type": "object",
20 "properties": {
21 "resource": {
22 "$ref": "#/$defs/Resource"
23 },
24 "scopeSpans": {
25 "description": "The spans, grouped by instrumentation scope.",
26 "type": "array",
27 "items": {
28 "$ref": "#/$defs/ScopeSpans"
29 }
30 },
31 "schemaUrl": {
32 "type": "string"
33 }
34 }
35 },
36 "Resource": {
37 "description": "'opentelemetry.proto.resource.v1.Resource': the entity that produced the spans.",
38 "type": "object",
39 "properties": {
40 "attributes": {
41 "description": "Attributes, with unique keys.",
42 "type": "array",
43 "items": {
44 "$ref": "#/$defs/KeyValue"
45 }
46 },
47 "droppedAttributesCount": {
48 "$ref": "#/$defs/UInt32"
49 }
50 }
51 },
52 "ScopeSpans": {
53 "description": "'ScopeSpans': the spans produced by one instrumentation scope.",
54 "type": "object",
55 "properties": {
56 "scope": {
57 "$ref": "#/$defs/InstrumentationScope"
58 },
59 "spans": {
60 "description": "The spans, flattened; the hierarchy is carried by 'parentSpanId'.",
61 "type": "array",
62 "items": {
63 "$ref": "#/$defs/Span"
64 }
65 },
66 "schemaUrl": {
67 "type": "string"
68 }
69 }
70 },
71 "InstrumentationScope": {
72 "description": "'opentelemetry.proto.common.v1.InstrumentationScope': the library that produced the spans.",
73 "type": "object",
74 "properties": {
75 "name": {
76 "type": "string"
77 },
78 "version": {
79 "type": "string"
80 },
81 "attributes": {
82 "description": "Attributes, with unique keys.",
83 "type": "array",
84 "items": {
85 "$ref": "#/$defs/KeyValue"
86 }
87 },
88 "droppedAttributesCount": {
89 "$ref": "#/$defs/UInt32"
90 }
91 }
92 },
93 "Span": {
94 "description": "'Span': one timespan of a trace.",
95 "type": "object",
96 "required": [
97 "traceId",
98 "spanId"
99 ],
100 "properties": {
101 "traceId": {
102 "$ref": "#/$defs/TraceID"
103 },
104 "spanId": {
105 "$ref": "#/$defs/SpanID"
106 },
107 "traceState": {
108 "type": "string"
109 },
110 "parentSpanId": {
111 "$ref": "#/$defs/ParentSpanID"
112 },
113 "flags": {
114 "$ref": "#/$defs/UInt32"
115 },
116 "name": {
117 "type": "string"
118 },
119 "kind": {
120 "$ref": "#/$defs/Enumeration"
121 },
122 "startTimeUnixNano": {
123 "$ref": "#/$defs/UInt64"
124 },
125 "endTimeUnixNano": {
126 "$ref": "#/$defs/UInt64"
127 },
128 "attributes": {
129 "description": "Attributes, with unique keys.",
130 "type": "array",
131 "items": {
132 "$ref": "#/$defs/KeyValue"
133 }
134 },
135 "droppedAttributesCount": {
136 "$ref": "#/$defs/UInt32"
137 },
138 "events": {
139 "type": "array",
140 "items": {
141 "$ref": "#/$defs/Event"
142 }
143 },
144 "droppedEventsCount": {
145 "$ref": "#/$defs/UInt32"
146 },
147 "links": {
148 "type": "array",
149 "items": {
150 "$ref": "#/$defs/Link"
151 }
152 },
153 "droppedLinksCount": {
154 "$ref": "#/$defs/UInt32"
155 },
156 "status": {
157 "$ref": "#/$defs/Status"
158 }
159 }
160 },
161 "Event": {
162 "description": "'Span.Event': a named point in time within a span.",
163 "type": "object",
164 "properties": {
165 "timeUnixNano": {
166 "$ref": "#/$defs/UInt64"
167 },
168 "name": {
169 "type": "string"
170 },
171 "attributes": {
172 "description": "Attributes, with unique keys.",
173 "type": "array",
174 "items": {
175 "$ref": "#/$defs/KeyValue"
176 }
177 },
178 "droppedAttributesCount": {
179 "$ref": "#/$defs/UInt32"
180 }
181 }
182 },
183 "Link": {
184 "description": "'Span.Link': a reference to a span of the same or another trace.",
185 "type": "object",
186 "required": [
187 "traceId",
188 "spanId"
189 ],
190 "properties": {
191 "traceId": {
192 "$ref": "#/$defs/TraceID"
193 },
194 "spanId": {
195 "$ref": "#/$defs/SpanID"
196 },
197 "traceState": {
198 "type": "string"
199 },
200 "attributes": {
201 "description": "Attributes, with unique keys.",
202 "type": "array",
203 "items": {
204 "$ref": "#/$defs/KeyValue"
205 }
206 },
207 "droppedAttributesCount": {
208 "$ref": "#/$defs/UInt32"
209 },
210 "flags": {
211 "$ref": "#/$defs/UInt32"
212 }
213 }
214 },
215 "Status": {
216 "description": "'Status': whether a span completed successfully.",
217 "type": "object",
218 "properties": {
219 "message": {
220 "type": "string"
221 },
222 "code": {
223 "$ref": "#/$defs/Enumeration"
224 }
225 }
226 },
227 "KeyValue": {
228 "description": "'opentelemetry.proto.common.v1.KeyValue': one attribute. An attribute key is a non-empty string.",
229 "type": "object",
230 "required": [
231 "key"
232 ],
233 "properties": {
234 "key": {
235 "type": "string",
236 "minLength": 1
237 },
238 "value": {
239 "$ref": "#/$defs/AnyValue"
240 }
241 }
242 },
243 "AnyValue": {
244 "description": "'opentelemetry.proto.common.v1.AnyValue': a value, named by its one key, or none ('empty').",
245 "type": "object",
246 "properties": {
247 "stringValue": {
248 "type": "string"
249 },
250 "boolValue": {
251 "type": "boolean"
252 },
253 "intValue": {
254 "$ref": "#/$defs/Int64"
255 },
256 "doubleValue": {
257 "$ref": "#/$defs/Double"
258 },
259 "arrayValue": {
260 "$ref": "#/$defs/ArrayValue"
261 },
262 "kvlistValue": {
263 "$ref": "#/$defs/KeyValueList"
264 },
265 "bytesValue": {
266 "$ref": "#/$defs/Bytes"
267 }
268 },
269 "oneOf": [
270 {
271 "required": [
272 "stringValue"
273 ]
274 },
275 {
276 "required": [
277 "boolValue"
278 ]
279 },
280 {
281 "required": [
282 "intValue"
283 ]
284 },
285 {
286 "required": [
287 "doubleValue"
288 ]
289 },
290 {
291 "required": [
292 "arrayValue"
293 ]
294 },
295 {
296 "required": [
297 "kvlistValue"
298 ]
299 },
300 {
301 "required": [
302 "bytesValue"
303 ]
304 },
305 {
306 "not": {
307 "anyOf": [
308 {
309 "required": [
310 "stringValue"
311 ]
312 },
313 {
314 "required": [
315 "boolValue"
316 ]
317 },
318 {
319 "required": [
320 "intValue"
321 ]
322 },
323 {
324 "required": [
325 "doubleValue"
326 ]
327 },
328 {
329 "required": [
330 "arrayValue"
331 ]
332 },
333 {
334 "required": [
335 "kvlistValue"
336 ]
337 },
338 {
339 "required": [
340 "bytesValue"
341 ]
342 }
343 ]
344 }
345 }
346 ]
347 },
348 "ArrayValue": {
349 "description": "'opentelemetry.proto.common.v1.ArrayValue': a list of values.",
350 "type": "object",
351 "properties": {
352 "values": {
353 "type": "array",
354 "items": {
355 "$ref": "#/$defs/AnyValue"
356 }
357 }
358 }
359 },
360 "KeyValueList": {
361 "description": "'opentelemetry.proto.common.v1.KeyValueList': a mapping of values, with unique keys.",
362 "type": "object",
363 "properties": {
364 "values": {
365 "type": "array",
366 "items": {
367 "$ref": "#/$defs/KeyValue"
368 }
369 }
370 }
371 },
372 "TraceID": {
373 "description": "A trace identifier: 16 bytes as 32 hexadecimal digits (case-insensitive), not all zero.",
374 "type": "string",
375 "pattern": "^(?!0{32}$)[0-9a-fA-F]{32}$"
376 },
377 "SpanID": {
378 "description": "A span identifier: 8 bytes as 16 hexadecimal digits (case-insensitive), not all zero.",
379 "type": "string",
380 "pattern": "^(?!0{16}$)[0-9a-fA-F]{16}$"
381 },
382 "ParentSpanID": {
383 "description": "The parent's span identifier, or empty for a root span.",
384 "type": "string",
385 "pattern": "^$|^(?!0{16}$)[0-9a-fA-F]{16}$"
386 },
387 "UInt64": {
388 "description": "An unsigned 64-bit integer ('uint64', 'fixed64'): a decimal string, or a number.",
389 "type": [
390 "string",
391 "integer"
392 ],
393 "pattern": "^[0-9]+$",
394 "minimum": 0
395 },
396 "Int64": {
397 "description": "A signed 64-bit integer ('int64'): a decimal string, or a number.",
398 "type": [
399 "string",
400 "integer"
401 ],
402 "pattern": "^-?[0-9]+$"
403 },
404 "UInt32": {
405 "description": "An unsigned 32-bit integer ('uint32', 'fixed32'): a number, or a decimal string.",
406 "type": [
407 "string",
408 "integer"
409 ],
410 "pattern": "^[0-9]+$",
411 "minimum": 0,
412 "maximum": 4294967295
413 },
414 "Double": {
415 "description": "A double: a number, a decimal string, or one of 'NaN', 'Infinity' and '-Infinity'.",
416 "anyOf": [
417 {
418 "type": "number"
419 },
420 {
421 "type": "string",
422 "pattern": "^(NaN|-?Infinity|-?(0|[1-9][0-9]*)(\\.[0-9]+)?([eE][+-]?[0-9]+)?)$"
423 }
424 ]
425 },
426 "Bytes": {
427 "description": "A byte string, base64-encoded with the standard or the URL-safe alphabet, padded or not.",
428 "type": "string",
429 "pattern": "^[A-Za-z0-9+/_-]*={0,2}$"
430 },
431 "Enumeration": {
432 "description": "An enumeration value ('SpanKind', 'StatusCode'), encoded as its integer.",
433 "type": "integer",
434 "minimum": 0
435 }
436 }
437}