//
// Copyright (C) 2018 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// @generated by protoc-gen-es v2.2.2 with parameter "target=ts"
// @generated from file protos/perfetto/common/trace_stats.proto (package perfetto.protos, syntax proto2)
/* eslint-disable */

import type { GenEnum, GenFile, GenMessage } from "@bufbuild/protobuf/codegenv1";
import { enumDesc, fileDesc, messageDesc } from "@bufbuild/protobuf/codegenv1";
import type { Message } from "@bufbuild/protobuf";

/**
 * Describes the file protos/perfetto/common/trace_stats.proto.
 */
export const file_protos_perfetto_common_trace_stats: GenFile = /*@__PURE__*/
  fileDesc("Cihwcm90b3MvcGVyZmV0dG8vY29tbW9uL3RyYWNlX3N0YXRzLnByb3RvEg9wZXJmZXR0by5wcm90b3MikQwKClRyYWNlU3RhdHMSPQoMYnVmZmVyX3N0YXRzGAEgAygLMicucGVyZmV0dG8ucHJvdG9zLlRyYWNlU3RhdHMuQnVmZmVyU3RhdHMSIwobY2h1bmtfcGF5bG9hZF9oaXN0b2dyYW1fZGVmGBEgAygDEj0KDHdyaXRlcl9zdGF0cxgSIAMoCzInLnBlcmZldHRvLnByb3Rvcy5UcmFjZVN0YXRzLldyaXRlclN0YXRzEhsKE3Byb2R1Y2Vyc19jb25uZWN0ZWQYAiABKA0SFgoOcHJvZHVjZXJzX3NlZW4YAyABKAQSHwoXZGF0YV9zb3VyY2VzX3JlZ2lzdGVyZWQYBCABKA0SGQoRZGF0YV9zb3VyY2VzX3NlZW4YBSABKAQSGAoQdHJhY2luZ19zZXNzaW9ucxgGIAEoDRIVCg10b3RhbF9idWZmZXJzGAcgASgNEhgKEGNodW5rc19kaXNjYXJkZWQYCCABKA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V3JpdGVyU3RhdHMSEwoLc2VxdWVuY2VfaWQYASABKAQSDgoGYnVmZmVyGAQgASgNEioKHmNodW5rX3BheWxvYWRfaGlzdG9ncmFtX2NvdW50cxgCIAMoBEICEAESJwobY2h1bmtfcGF5bG9hZF9oaXN0b2dyYW1fc3VtGAMgAygDQgIQARqaAQoLRmlsdGVyU3RhdHMSFQoNaW5wdXRfcGFja2V0cxgBIAEoBBITCgtpbnB1dF9ieXRlcxgCIAEoBBIUCgxvdXRwdXRfYnl0ZXMYAyABKAQSDgoGZXJyb3JzGAQgASgEEhUKDXRpbWVfdGFrZW5fbnMYBSABKAQSIgoaYnl0ZXNfZGlzY2FyZGVkX3Blcl9idWZmZXIYFCADKAQiYwoRRmluYWxGbHVzaE91dGNvbWUSGwoXRklOQUxfRkxVU0hfVU5TUEVDSUZJRUQQABIZChVGSU5BTF9GTFVTSF9TVUNDRUVERUQQARIWChJGSU5BTF9GTFVTSF9GQUlMRUQQAg");

/**
 * Statistics for the internals of the tracing service.
 *
 * Next id: 19.
 *
 * @generated from message perfetto.protos.TraceStats
 */
export type TraceStats = Message<"perfetto.protos.TraceStats"> & {
  /**
   * Stats for the TraceBuffer(s) of the current trace session.
   *
   * @generated from field: repeated perfetto.protos.TraceStats.BufferStats buffer_stats = 1;
   */
  bufferStats: TraceStats_BufferStats[];

  /**
   * The thresholds of each the `writer_stats` histogram buckets. This is
   * emitted only once as all WriterStats share the same bucket layout.
   * This field has the same cardinality of the
   * `writer_stats.chunk_payload_histogram_{counts,sum}` - 1.
   * (The -1 is because the last overflow bucket is not reported in the _def).
   * An array of values [10, 100, 1000] in the _def array means that there are
   * four buckets (3 + the implicit overflow bucket):
   * [0]: x <= 10; [1]: 100 < x <= 1000; [2]: 1000 < x <= 1000; [3]: x > 1000.
   *
   * @generated from field: repeated int64 chunk_payload_histogram_def = 17;
   */
  chunkPayloadHistogramDef: bigint[];

  /**
   * @generated from field: repeated perfetto.protos.TraceStats.WriterStats writer_stats = 18;
   */
  writerStats: TraceStats_WriterStats[];

  /**
   * Num. producers connected (whether they are involved in the current tracing
   * session or not).
   *
   * @generated from field: optional uint32 producers_connected = 2;
   */
  producersConnected: number;

  /**
   * Num. producers ever seen for all trace sessions since startup (it's a good
   * proxy for inferring num. producers crashed / killed).
   *
   * @generated from field: optional uint64 producers_seen = 3;
   */
  producersSeen: bigint;

  /**
   * Num. data sources registered for all trace sessions.
   *
   * @generated from field: optional uint32 data_sources_registered = 4;
   */
  dataSourcesRegistered: number;

  /**
   * Num. data sources ever seen for all trace sessions since startup.
   *
   * @generated from field: optional uint64 data_sources_seen = 5;
   */
  dataSourcesSeen: bigint;

  /**
   * Num. concurrently active tracing sessions.
   *
   * @generated from field: optional uint32 tracing_sessions = 6;
   */
  tracingSessions: number;

  /**
   * Num. buffers for all tracing session (not just the current one). This will
   * be >= buffer_stats.size(), because the latter is only about the current
   * session.
   *
   * @generated from field: optional uint32 total_buffers = 7;
   */
  totalBuffers: number;

  /**
   * Num. chunks that were discarded by the service before attempting to commit
   * them to a buffer, e.g. because the producer specified an invalid buffer ID.
   *
   * @generated from field: optional uint64 chunks_discarded = 8;
   */
  chunksDiscarded: bigint;

  /**
   * Num. patches that were discarded by the service before attempting to apply
   * them to a buffer, e.g. because the producer specified an invalid buffer ID.
   *
   * @generated from field: optional uint64 patches_discarded = 9;
   */
  patchesDiscarded: bigint;

  /**
   * Packets that failed validation of the TrustedPacket. If this is > 0, there
   * is a bug in the producer.
   *
   * @generated from field: optional uint64 invalid_packets = 10;
   */
  invalidPackets: bigint;

  /**
   * @generated from field: optional perfetto.protos.TraceStats.FilterStats filter_stats = 11;
   */
  filterStats?: TraceStats_FilterStats;

  /**
   * Count of Flush() requests (either from the Consumer, or self-induced
   * periodic flushes). The final Flush() is also included in the count.
   *
   * @generated from field: optional uint64 flushes_requested = 12;
   */
  flushesRequested: bigint;

  /**
   * The count of the Flush() requests that were completed successfully.
   * In a well behaving trace this should always be == `flush_requests`.
   *
   * @generated from field: optional uint64 flushes_succeeded = 13;
   */
  flushesSucceeded: bigint;

  /**
   * The count of the Flush() requests that failed (in most timed out).
   * In a well behaving trace this should always be == 0.
   *
   * @generated from field: optional uint64 flushes_failed = 14;
   */
  flushesFailed: bigint;

  /**
   * @generated from field: optional perfetto.protos.TraceStats.FinalFlushOutcome final_flush_outcome = 15;
   */
  finalFlushOutcome: TraceStats_FinalFlushOutcome;
};

/**
 * Describes the message perfetto.protos.TraceStats.
 * Use `create(TraceStatsSchema)` to create a new message.
 */
export const TraceStatsSchema: GenMessage<TraceStats> = /*@__PURE__*/
  messageDesc(file_protos_perfetto_common_trace_stats, 0);

/**
 * From TraceBuffer::Stats.
 *
 * Next id: 21.
 *
 * @generated from message perfetto.protos.TraceStats.BufferStats
 */
export type TraceStats_BufferStats = Message<"perfetto.protos.TraceStats.BufferStats"> & {
  /**
   * Size of the circular buffer in bytes.
   *
   * @generated from field: optional uint64 buffer_size = 12;
   */
  bufferSize: bigint;

  /**
   * Num. bytes written into the circular buffer, including chunk headers.
   *
   * @generated from field: optional uint64 bytes_written = 1;
   */
  bytesWritten: bigint;

  /**
   * Num. bytes overwritten before they have been read (i.e. loss of data).
   *
   * @generated from field: optional uint64 bytes_overwritten = 13;
   */
  bytesOverwritten: bigint;

  /**
   * Total size of chunks that were fully read from the circular buffer by the
   * consumer. This may not be equal to |bytes_written| either in the middle
   * of tracing, or if |chunks_overwritten| is non-zero. Note that this is the
   * size of the chunks read from the buffer, including chunk headers, which
   * will be different from the total size of packets returned to the
   * consumer.
   *
   * The current utilization of the trace buffer (mid-tracing) can be obtained
   * by subtracting |bytes_read| and |bytes_overwritten| from |bytes_written|,
   * adding the difference of |padding_bytes_written| and
   * |padding_bytes_cleared|, and comparing this sum to the |buffer_size|.
   * Note that this represents the total size of buffered data in the buffer,
   * yet this data may be spread non-contiguously through the buffer and may
   * be overridden before the utilization reaches 100%.
   *
   * @generated from field: optional uint64 bytes_read = 14;
   */
  bytesRead: bigint;

  /**
   * Num. bytes that were allocated as padding between chunks in the circular
   * buffer.
   *
   * @generated from field: optional uint64 padding_bytes_written = 15;
   */
  paddingBytesWritten: bigint;

  /**
   * Num. of padding bytes that were removed from the circular buffer when
   * they were overwritten.
   *
   * The difference between |padding_bytes_written| and
   * |padding_bytes_cleared| denotes the total size of padding currently
   * present in the buffer.
   *
   * @generated from field: optional uint64 padding_bytes_cleared = 16;
   */
  paddingBytesCleared: bigint;

  /**
   * Num. chunks (!= packets) written into the buffer.
   *
   * @generated from field: optional uint64 chunks_written = 2;
   */
  chunksWritten: bigint;

  /**
   * Num. chunks (!= packets) rewritten into the buffer. This means we rewrote
   * the same chunk with additional packets appended to the end.
   *
   * @generated from field: optional uint64 chunks_rewritten = 10;
   */
  chunksRewritten: bigint;

  /**
   * Num. chunks overwritten before they have been read (i.e. loss of data).
   *
   * @generated from field: optional uint64 chunks_overwritten = 3;
   */
  chunksOverwritten: bigint;

  /**
   * Num. chunks discarded (i.e. loss of data). Can be > 0 only when a buffer
   * is configured with FillPolicy == DISCARD.
   *
   * @generated from field: optional uint64 chunks_discarded = 18;
   */
  chunksDiscarded: bigint;

  /**
   * Num. chunks (!= packets) that were fully read from the circular buffer by
   * the consumer. This may not be equal to |chunks_written| either in the
   * middle of tracing, or if |chunks_overwritten| is non-zero.
   *
   * @generated from field: optional uint64 chunks_read = 17;
   */
  chunksRead: bigint;

  /**
   * Num. chunks that were committed out of order.
   *
   * @generated from field: optional uint64 chunks_committed_out_of_order = 11;
   */
  chunksCommittedOutOfOrder: bigint;

  /**
   * Num. times the ring buffer wrapped around.
   *
   * @generated from field: optional uint64 write_wrap_count = 4;
   */
  writeWrapCount: bigint;

  /**
   * Num. out-of-band (OOB) patches that succeeded.
   *
   * @generated from field: optional uint64 patches_succeeded = 5;
   */
  patchesSucceeded: bigint;

  /**
   * Num. OOB patches that failed (e.g., the chunk to patch was gone).
   *
   * @generated from field: optional uint64 patches_failed = 6;
   */
  patchesFailed: bigint;

  /**
   * Num. readaheads (for large multi-chunk packet reads) that ended up in a
   * successful packet read.
   *
   * @generated from field: optional uint64 readaheads_succeeded = 7;
   */
  readaheadsSucceeded: bigint;

  /**
   * Num. readaheads aborted because of missing chunks in the sequence stream.
   * Note that a small number > 0 is totally expected: occasionally, when
   * issuing a read, the very last packet in a sequence might be incomplete
   * (because the producer is still writing it while we read). The read will
   * stop at that point, for that sequence, increasing this counter.
   *
   * @generated from field: optional uint64 readaheads_failed = 8;
   */
  readaheadsFailed: bigint;

  /**
   * Num. of violations of the SharedMemoryABI found while writing or reading
   * the buffer. This is an indication of either a bug in the producer(s) or
   * malicious producer(s).
   *
   * @generated from field: optional uint64 abi_violations = 9;
   */
  abiViolations: bigint;

  /**
   * Num. of times the service detected packet loss on a trace writer
   * sequence. This is usually caused by exhaustion of available chunks in the
   * writer process's SMB. Note that this relies on the client's TraceWriter
   * indicating this loss to the service -- packets lost for other reasons are
   * not reflected in this stat.
   *
   * @generated from field: optional uint64 trace_writer_packet_loss = 19;
   */
  traceWriterPacketLoss: bigint;
};

/**
 * Describes the message perfetto.protos.TraceStats.BufferStats.
 * Use `create(TraceStats_BufferStatsSchema)` to create a new message.
 */
export const TraceStats_BufferStatsSchema: GenMessage<TraceStats_BufferStats> = /*@__PURE__*/
  messageDesc(file_protos_perfetto_common_trace_stats, 0, 0);

/**
 * Per TraceWriter stat. Each {producer, trace writer} tuple is publicly
 * visible as a unique sequence ID in the trace.
 *
 * @generated from message perfetto.protos.TraceStats.WriterStats
 */
export type TraceStats_WriterStats = Message<"perfetto.protos.TraceStats.WriterStats"> & {
  /**
   * This matches the TracePacket.trusted_packet_sequence_id and is used to
   * correlate the stats with the actual packet types.
   *
   * @generated from field: optional uint64 sequence_id = 1;
   */
  sequenceId: bigint;

  /**
   * The buffer index (0..N, as defined in the TraceConfig).
   *
   * @generated from field: optional uint32 buffer = 4;
   */
  buffer: number;

  /**
   * These two arrays have the same cardinality and match the cardinality of
   * chunk_payload_histogram_def + 1 (for the overflow bucket, see below).
   * `sum` contains the SUM(entries) and `counts` contains the COUNT(entries)
   * for each bucket.
   *
   * @generated from field: repeated uint64 chunk_payload_histogram_counts = 2 [packed = true];
   */
  chunkPayloadHistogramCounts: bigint[];

  /**
   * @generated from field: repeated int64 chunk_payload_histogram_sum = 3 [packed = true];
   */
  chunkPayloadHistogramSum: bigint[];
};

/**
 * Describes the message perfetto.protos.TraceStats.WriterStats.
 * Use `create(TraceStats_WriterStatsSchema)` to create a new message.
 */
export const TraceStats_WriterStatsSchema: GenMessage<TraceStats_WriterStats> = /*@__PURE__*/
  messageDesc(file_protos_perfetto_common_trace_stats, 0, 1);

/**
 * This is set only when the TraceConfig specifies a TraceFilter.
 *
 * @generated from message perfetto.protos.TraceStats.FilterStats
 */
export type TraceStats_FilterStats = Message<"perfetto.protos.TraceStats.FilterStats"> & {
  /**
   * @generated from field: optional uint64 input_packets = 1;
   */
  inputPackets: bigint;

  /**
   * @generated from field: optional uint64 input_bytes = 2;
   */
  inputBytes: bigint;

  /**
   * @generated from field: optional uint64 output_bytes = 3;
   */
  outputBytes: bigint;

  /**
   * @generated from field: optional uint64 errors = 4;
   */
  errors: bigint;

  /**
   * @generated from field: optional uint64 time_taken_ns = 5;
   */
  timeTakenNs: bigint;

  /**
   * The number of bytes discarded by the filter (i.e. output - input).
   * The array has one entry for each buffer defined in the config (unless no
   * packets for that buffer were seen and hence filtered).
   * Note: the SUM(bytes_discarded_per_buffer) will be <= but not == the total
   * (output_bytes - input_bytes) because the filter might also discard
   * server-generated synthetic packets, that have no buffer index.
   *
   * @generated from field: repeated uint64 bytes_discarded_per_buffer = 20;
   */
  bytesDiscardedPerBuffer: bigint[];
};

/**
 * Describes the message perfetto.protos.TraceStats.FilterStats.
 * Use `create(TraceStats_FilterStatsSchema)` to create a new message.
 */
export const TraceStats_FilterStatsSchema: GenMessage<TraceStats_FilterStats> = /*@__PURE__*/
  messageDesc(file_protos_perfetto_common_trace_stats, 0, 2);

/**
 * @generated from enum perfetto.protos.TraceStats.FinalFlushOutcome
 */
export enum TraceStats_FinalFlushOutcome {
  /**
   * @generated from enum value: FINAL_FLUSH_UNSPECIFIED = 0;
   */
  FINAL_FLUSH_UNSPECIFIED = 0,

  /**
   * @generated from enum value: FINAL_FLUSH_SUCCEEDED = 1;
   */
  FINAL_FLUSH_SUCCEEDED = 1,

  /**
   * @generated from enum value: FINAL_FLUSH_FAILED = 2;
   */
  FINAL_FLUSH_FAILED = 2,
}

/**
 * Describes the enum perfetto.protos.TraceStats.FinalFlushOutcome.
 */
export const TraceStats_FinalFlushOutcomeSchema: GenEnum<TraceStats_FinalFlushOutcome> = /*@__PURE__*/
  enumDesc(file_protos_perfetto_common_trace_stats, 0, 0);

