| // Copyright 2019 The Fuchsia Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| library fuchsia.diagnostics.stream; |
| using fuchsia.diagnostics; |
| using zx; |
| |
| /// Maximum number of arguments that can be encoded per record, as specified by the tracing format: |
| /// |
| /// https://fuchsia.dev/fuchsia-src/development/tracing/trace-format#arguments |
| const MAX_ARGS uint32 = 15; |
| |
| /// A small(ish) limit on the length of argument names is used because argument names are expected |
| /// to be used repeatedly, many times. |
| const MAX_ARG_NAME_LENGTH uint32 = 256; |
| |
| /// The maximum string length which we can encode into the tracing format. |
| const MAX_TEXT_ARG_LENGTH uint32 = 32768; |
| |
| /// A record in the diagnostic stream. |
| @max_handles("0") |
| type Record = struct { |
| /// The monotonic time at which the record was generated. |
| timestamp zx.time; |
| /// Severity of the record. |
| severity fuchsia.diagnostics.Severity; |
| /// The key-value pairs which make up this record. |
| arguments vector<Argument>:MAX_ARGS; |
| }; |
| |
| /// A named key-value pair in the diagnostic record. |
| @max_handles("0") |
| type Argument = struct { |
| /// The name of the argument. |
| name string:MAX_ARG_NAME_LENGTH; |
| /// The value of the argument. |
| value Value; |
| }; |
| |
| /// An argument value which can be one of several types. |
| @max_handles("0") |
| type Value = flexible union { |
| /// A signed integral argument. |
| 1: signed_int int64; |
| /// An unsigned integral argument. |
| 2: unsigned_int uint64; |
| /// A double-precision floating-point argument. |
| 3: floating float64; |
| /// A UTF8 text argument. |
| 4: text string:MAX_TEXT_ARG_LENGTH; |
| /// A boolean argument. |
| 5: boolean bool; |
| }; |