mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-13 17:14:05 -08:00
Add metrics.proto to other protobuf code (#8996)
We cannot just use prometheus/client_model directly because we want to stay consistent with the use of gogo-protobuf. So this converts metrics.proto to proto3 and edits it lightly so that it fits into the framework how prometheus/prometheus handles protobuf. Note that metrics.proto couldn't be merged into the prompb package because prompb already has an Exemplar type, which is different from the Exemplar type in metrics.proto. The directory structure seems to play a role in the protobuf world, so I better kept it. Signed-off-by: beorn7 <beorn@grafana.com>
This commit is contained in:
parent
3707619900
commit
df3b674f01
3810
prompb/io/prometheus/client/metrics.pb.go
Normal file
3810
prompb/io/prometheus/client/metrics.pb.go
Normal file
File diff suppressed because it is too large
Load diff
116
prompb/io/prometheus/client/metrics.proto
Normal file
116
prompb/io/prometheus/client/metrics.proto
Normal file
|
@ -0,0 +1,116 @@
|
||||||
|
// Copyright 2013 Prometheus Team
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
// This is copied and lightly edited from
|
||||||
|
// github.com/prometheus/client_model/io/prometheus/client/metrics.proto
|
||||||
|
// and finally converted to proto3 syntax to make it usable for the
|
||||||
|
// gogo-protobuf approach taken within prometheus/prometheus.
|
||||||
|
|
||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
package io.prometheus.client;
|
||||||
|
option go_package = "io_prometheus_client";
|
||||||
|
|
||||||
|
import "google/protobuf/timestamp.proto";
|
||||||
|
|
||||||
|
message LabelPair {
|
||||||
|
string name = 1;
|
||||||
|
string value = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum MetricType {
|
||||||
|
COUNTER = 0;
|
||||||
|
GAUGE = 1;
|
||||||
|
SUMMARY = 2;
|
||||||
|
UNTYPED = 3;
|
||||||
|
HISTOGRAM = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
message Gauge {
|
||||||
|
double value = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message Counter {
|
||||||
|
double value = 1;
|
||||||
|
Exemplar exemplar = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message Quantile {
|
||||||
|
double quantile = 1;
|
||||||
|
double value = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message Summary {
|
||||||
|
uint64 sample_count = 1;
|
||||||
|
double sample_sum = 2;
|
||||||
|
repeated Quantile quantile = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message Untyped {
|
||||||
|
double value = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message Histogram {
|
||||||
|
uint64 sample_count = 1;
|
||||||
|
double sample_sum = 2;
|
||||||
|
repeated Bucket bucket = 3; // Ordered in increasing order of upper_bound, +Inf bucket is optional.
|
||||||
|
// Sparse bucket (sb) stuff:
|
||||||
|
// The sb_schema defines the bucket schema. Currently, valid numbers are -4 <= n <= 8.
|
||||||
|
// They are all for base-2 bucket schemas, where 1 is a bucket boundary in each case, and
|
||||||
|
// then each power of two is divided into 2^n logarithmic buckets.
|
||||||
|
// Or in other words, each bucket boundary is the previous boundary times 2^(2^-n).
|
||||||
|
// In the future, more bucket schemas may be added using numbers < -4 or > 8.
|
||||||
|
sint32 sb_schema = 4;
|
||||||
|
double sb_zero_threshold = 5; // Breadth of the zero bucket.
|
||||||
|
uint64 sb_zero_count = 6; // Count in zero bucket.
|
||||||
|
SparseBuckets sb_negative = 7; // Negative sparse buckets.
|
||||||
|
SparseBuckets sb_positive = 8; // Positive sparse buckets.
|
||||||
|
}
|
||||||
|
|
||||||
|
message Bucket {
|
||||||
|
uint64 cumulative_count = 1; // Cumulative in increasing order.
|
||||||
|
double upper_bound = 2; // Inclusive.
|
||||||
|
Exemplar exemplar = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message SparseBuckets {
|
||||||
|
message Span {
|
||||||
|
sint32 offset = 1; // Gap to previous span, or starting point for 1st span (which can be negative).
|
||||||
|
uint32 length = 2; // Length of consecutive buckets.
|
||||||
|
}
|
||||||
|
repeated Span span = 1;
|
||||||
|
repeated sint64 delta = 2; // Count delta of each bucket compared to previous one (or to zero for 1st bucket).
|
||||||
|
}
|
||||||
|
|
||||||
|
message Exemplar {
|
||||||
|
repeated LabelPair label = 1;
|
||||||
|
double value = 2;
|
||||||
|
google.protobuf.Timestamp timestamp = 3; // OpenMetrics-style.
|
||||||
|
}
|
||||||
|
|
||||||
|
message Metric {
|
||||||
|
repeated LabelPair label = 1;
|
||||||
|
Gauge gauge = 2;
|
||||||
|
Counter counter = 3;
|
||||||
|
Summary summary = 4;
|
||||||
|
Untyped untyped = 5;
|
||||||
|
Histogram histogram = 7;
|
||||||
|
int64 timestamp_ms = 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
message MetricFamily {
|
||||||
|
string name = 1;
|
||||||
|
string help = 2;
|
||||||
|
MetricType type = 3;
|
||||||
|
repeated Metric metric = 4;
|
||||||
|
}
|
|
@ -40,14 +40,16 @@ for dir in ${DIRS}; do
|
||||||
-I="${PROM_PATH}" \
|
-I="${PROM_PATH}" \
|
||||||
-I="${GRPC_GATEWAY_ROOT}/third_party/googleapis" \
|
-I="${GRPC_GATEWAY_ROOT}/third_party/googleapis" \
|
||||||
./*.proto
|
./*.proto
|
||||||
|
protoc --gogofast_out=Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types,paths=source_relative:. -I=. \
|
||||||
|
-I="${GOGOPROTO_PATH}" \
|
||||||
|
./io/prometheus/client/*.proto
|
||||||
sed -i.bak -E 's/import _ \"github.com\/gogo\/protobuf\/gogoproto\"//g' -- *.pb.go
|
sed -i.bak -E 's/import _ \"github.com\/gogo\/protobuf\/gogoproto\"//g' -- *.pb.go
|
||||||
sed -i.bak -E 's/import _ \"google\/protobuf\"//g' -- *.pb.go
|
sed -i.bak -E 's/import _ \"google\/protobuf\"//g' -- *.pb.go
|
||||||
sed -i.bak -E 's/\t_ \"google\/protobuf\"//g' -- *.pb.go
|
sed -i.bak -E 's/\t_ \"google\/protobuf\"//g' -- *.pb.go
|
||||||
sed -i.bak -E 's/golang\/protobuf\/descriptor/gogo\/protobuf\/protoc-gen-gogo\/descriptor/g' -- *.go
|
sed -i.bak -E 's/golang\/protobuf\/descriptor/gogo\/protobuf\/protoc-gen-gogo\/descriptor/g' -- *.go
|
||||||
sed -i.bak -E 's/golang\/protobuf/gogo\/protobuf/g' -- *.go
|
sed -i.bak -E 's/golang\/protobuf/gogo\/protobuf/g' -- *.go
|
||||||
rm -f -- *.bak
|
rm -f -- *.bak
|
||||||
goimports -w ./*.go
|
goimports -w ./*.go ./io/prometheus/client/*.go
|
||||||
popd
|
popd
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue