gvisor.dev/gvisor@v0.0.0-20240520182842-f9d4d51c7e0f/pkg/metric/metric.proto (about)

     1  // Copyright 2018 The gVisor 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  
    15  syntax = "proto3";
    16  
    17  package gvisor;
    18  
    19  import "google/protobuf/timestamp.proto";
    20  
    21  // MetricMetadata contains all of the metadata describing a single metric.
    22  message MetricMetadata {
    23    // name is the unique name of the metric, usually in a "directory" format
    24    // (e.g., /foo/count).
    25    string name = 1;
    26  
    27    // prometheus_name is the unique name of the metric in Prometheus format
    28    // (e.g. foo_count).
    29    string prometheus_name = 9;
    30  
    31    // description is a human-readable description of the metric.
    32    string description = 2;
    33  
    34    // cumulative indicates that this metric is never decremented.
    35    // Only applies for uint64-type metrics.
    36    bool cumulative = 3;
    37  
    38    // sync indicates that values from the final metric event should be
    39    // synchronized to the backing monitoring system at exit.
    40    //
    41    // If sync is false, values are only sent to the monitoring system
    42    // periodically. There is no guarantee that values will ever be received by
    43    // the monitoring system.
    44    bool sync = 4;
    45  
    46    enum Type {
    47      TYPE_UINT64 = 0;
    48      TYPE_DISTRIBUTION = 1;
    49    }
    50  
    51    // type is the type of the metric value.
    52    Type type = 5;
    53  
    54    enum Units {
    55      UNITS_NONE = 0;
    56      UNITS_NANOSECONDS = 1;
    57    }
    58  
    59    // units is the units of the metric value.
    60    Units units = 6;
    61  
    62    message Field {
    63      string field_name = 1;
    64      repeated string allowed_values = 2;
    65    }
    66  
    67    // fields contains the metric fields for this metric.
    68    repeated Field fields = 7;
    69  
    70    // For distribution-typed metrics, this list contains the lower bound of all
    71    // buckets (other than the underflow bucket, which has no lower bound).
    72    // A distribution with n finite buckets should have n+1 values here.
    73    // The (n+1)-th value is the upper bound of the n-th bucket, and the lower
    74    // bound of the "overflow" bucket (which has no upper bound).
    75    repeated int64 distribution_bucket_lower_bounds = 8;
    76  }
    77  
    78  // MetricRegistration contains the metadata for all metrics that will be in
    79  // future MetricUpdates.
    80  message MetricRegistration {
    81    repeated MetricMetadata metrics = 1;
    82    repeated string stages = 2;
    83  }
    84  
    85  // Samples contains the number of samples in each bucket of a distribution.
    86  message Samples {
    87    // new_samples contains the number of *new* samples in each bucket of a
    88    // distribution metric. "New" means the number of new samples added since the
    89    // last MetricValue update for this metric and combination of fields.
    90    // Given a distribution metrics with `num_finite_buckets` finite buckets,
    91    // this means:
    92    //   - num_samples[0] is the number of new samples in the "underflow" bucket,
    93    //     i.e. samples which are smaller than the lower bound of the
    94    //     distribution's first (0-th) finite bucket.
    95    //   - num_samples[i] is the number of new samples in the distribution's
    96    //     0-based (i-1)-th finite bucket.
    97    //   - num_samples[num_finite_buckets+1] is the number of new samples in the
    98    //     distribution's last bucket, which is infinite (i.e. it has a lower
    99    //     bound but no upper bound).
   100    repeated uint64 new_samples = 1;
   101  }
   102  
   103  // MetricValue the value of a metric at a single point in time.
   104  message MetricValue {
   105    // name is the unique name of the metric, as in MetricMetadata.
   106    string name = 1;
   107  
   108    // value is the value of the metric at a single point in time. The field set
   109    // depends on the type of the metric.
   110    oneof value {
   111      uint64 uint64_value = 2;
   112      Samples distribution_value = 3;
   113    }
   114  
   115    repeated string field_values = 4;
   116  }
   117  
   118  // StageTiming represents a new stage that's been reached by the Sentry.
   119  message StageTiming {
   120    string stage = 1;
   121    google.protobuf.Timestamp started = 2;
   122    google.protobuf.Timestamp ended = 3;
   123  }
   124  
   125  // MetricUpdate contains new values for multiple distinct metrics.
   126  //
   127  // Metrics whose values have not changed are not included.
   128  message MetricUpdate {
   129    repeated MetricValue metrics = 1;
   130    // Timing information of initialization stages reached since last update.
   131    // The first MetricUpdate will include multiple entries, since metric
   132    // initialization happens relatively late in the Sentry startup process.
   133    repeated StageTiming stage_timing = 2;
   134  }