Commit ba21f95d authored by Bjoern Rabenstein's avatar Bjoern Rabenstein

Add timestamp_ms and type Custom to protobuf.

This implements version 0.0.4 of the protobuf-based exchange format.

Change-Id: Ib5b5ea85e00b647877031d2b05ed23352ac0c598
parent 5bcaf69e
This diff is collapsed.
......@@ -41,17 +41,19 @@ class Gauge;
class Counter;
class Quantile;
class Summary;
class Custom;
class Metric;
class MetricFamily;
enum MetricType {
COUNTER = 0,
GAUGE = 1,
SUMMARY = 2
SUMMARY = 2,
CUSTOM = 3
};
bool MetricType_IsValid(int value);
const MetricType MetricType_MIN = COUNTER;
const MetricType MetricType_MAX = SUMMARY;
const MetricType MetricType_MAX = CUSTOM;
const int MetricType_ARRAYSIZE = MetricType_MAX + 1;
const ::google::protobuf::EnumDescriptor* MetricType_descriptor();
......@@ -529,6 +531,88 @@ class Summary : public ::google::protobuf::Message {
};
// -------------------------------------------------------------------
class Custom : public ::google::protobuf::Message {
public:
Custom();
virtual ~Custom();
Custom(const Custom& from);
inline Custom& operator=(const Custom& from) {
CopyFrom(from);
return *this;
}
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
return _unknown_fields_;
}
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
return &_unknown_fields_;
}
static const ::google::protobuf::Descriptor* descriptor();
static const Custom& default_instance();
void Swap(Custom* other);
// implements Message ----------------------------------------------
Custom* New() const;
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const Custom& from);
void MergeFrom(const Custom& from);
void Clear();
bool IsInitialized() const;
int ByteSize() const;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input);
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const;
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
int GetCachedSize() const { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const;
public:
::google::protobuf::Metadata GetMetadata() const;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
// optional double value = 1;
inline bool has_value() const;
inline void clear_value();
static const int kValueFieldNumber = 1;
inline double value() const;
inline void set_value(double value);
// @@protoc_insertion_point(class_scope:io.prometheus.client.Custom)
private:
inline void set_has_value();
inline void clear_has_value();
::google::protobuf::UnknownFieldSet _unknown_fields_;
double value_;
mutable int _cached_size_;
::google::protobuf::uint32 _has_bits_[(1 + 31) / 32];
friend void protobuf_AddDesc_metrics_2eproto();
friend void protobuf_AssignDesc_metrics_2eproto();
friend void protobuf_ShutdownFile_metrics_2eproto();
void InitAsDefaultInstance();
static Custom* default_instance_;
};
// -------------------------------------------------------------------
class Metric : public ::google::protobuf::Message {
public:
Metric();
......@@ -622,6 +706,22 @@ class Metric : public ::google::protobuf::Message {
inline ::io::prometheus::client::Summary* release_summary();
inline void set_allocated_summary(::io::prometheus::client::Summary* summary);
// optional .io.prometheus.client.Custom custom = 5;
inline bool has_custom() const;
inline void clear_custom();
static const int kCustomFieldNumber = 5;
inline const ::io::prometheus::client::Custom& custom() const;
inline ::io::prometheus::client::Custom* mutable_custom();
inline ::io::prometheus::client::Custom* release_custom();
inline void set_allocated_custom(::io::prometheus::client::Custom* custom);
// optional int64 timestamp_ms = 6;
inline bool has_timestamp_ms() const;
inline void clear_timestamp_ms();
static const int kTimestampMsFieldNumber = 6;
inline ::google::protobuf::int64 timestamp_ms() const;
inline void set_timestamp_ms(::google::protobuf::int64 value);
// @@protoc_insertion_point(class_scope:io.prometheus.client.Metric)
private:
inline void set_has_gauge();
......@@ -630,6 +730,10 @@ class Metric : public ::google::protobuf::Message {
inline void clear_has_counter();
inline void set_has_summary();
inline void clear_has_summary();
inline void set_has_custom();
inline void clear_has_custom();
inline void set_has_timestamp_ms();
inline void clear_has_timestamp_ms();
::google::protobuf::UnknownFieldSet _unknown_fields_;
......@@ -637,9 +741,11 @@ class Metric : public ::google::protobuf::Message {
::io::prometheus::client::Gauge* gauge_;
::io::prometheus::client::Counter* counter_;
::io::prometheus::client::Summary* summary_;
::io::prometheus::client::Custom* custom_;
::google::protobuf::int64 timestamp_ms_;
mutable int _cached_size_;
::google::protobuf::uint32 _has_bits_[(4 + 31) / 32];
::google::protobuf::uint32 _has_bits_[(6 + 31) / 32];
friend void protobuf_AddDesc_metrics_2eproto();
friend void protobuf_AssignDesc_metrics_2eproto();
......@@ -1095,6 +1201,32 @@ Summary::mutable_quantile() {
// -------------------------------------------------------------------
// Custom
// optional double value = 1;
inline bool Custom::has_value() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
inline void Custom::set_has_value() {
_has_bits_[0] |= 0x00000001u;
}
inline void Custom::clear_has_value() {
_has_bits_[0] &= ~0x00000001u;
}
inline void Custom::clear_value() {
value_ = 0;
clear_has_value();
}
inline double Custom::value() const {
return value_;
}
inline void Custom::set_value(double value) {
set_has_value();
value_ = value;
}
// -------------------------------------------------------------------
// Metric
// repeated .io.prometheus.client.LabelPair label = 1;
......@@ -1236,6 +1368,66 @@ inline void Metric::set_allocated_summary(::io::prometheus::client::Summary* sum
}
}
// optional .io.prometheus.client.Custom custom = 5;
inline bool Metric::has_custom() const {
return (_has_bits_[0] & 0x00000010u) != 0;
}
inline void Metric::set_has_custom() {
_has_bits_[0] |= 0x00000010u;
}
inline void Metric::clear_has_custom() {
_has_bits_[0] &= ~0x00000010u;
}
inline void Metric::clear_custom() {
if (custom_ != NULL) custom_->::io::prometheus::client::Custom::Clear();
clear_has_custom();
}
inline const ::io::prometheus::client::Custom& Metric::custom() const {
return custom_ != NULL ? *custom_ : *default_instance_->custom_;
}
inline ::io::prometheus::client::Custom* Metric::mutable_custom() {
set_has_custom();
if (custom_ == NULL) custom_ = new ::io::prometheus::client::Custom;
return custom_;
}
inline ::io::prometheus::client::Custom* Metric::release_custom() {
clear_has_custom();
::io::prometheus::client::Custom* temp = custom_;
custom_ = NULL;
return temp;
}
inline void Metric::set_allocated_custom(::io::prometheus::client::Custom* custom) {
delete custom_;
custom_ = custom;
if (custom) {
set_has_custom();
} else {
clear_has_custom();
}
}
// optional int64 timestamp_ms = 6;
inline bool Metric::has_timestamp_ms() const {
return (_has_bits_[0] & 0x00000020u) != 0;
}
inline void Metric::set_has_timestamp_ms() {
_has_bits_[0] |= 0x00000020u;
}
inline void Metric::clear_has_timestamp_ms() {
_has_bits_[0] &= ~0x00000020u;
}
inline void Metric::clear_timestamp_ms() {
timestamp_ms_ = GOOGLE_LONGLONG(0);
clear_has_timestamp_ms();
}
inline ::google::protobuf::int64 Metric::timestamp_ms() const {
return timestamp_ms_;
}
inline void Metric::set_timestamp_ms(::google::protobuf::int64 value) {
set_has_timestamp_ms();
timestamp_ms_ = value;
}
// -------------------------------------------------------------------
// MetricFamily
......
......@@ -2,6 +2,22 @@
// source: metrics.proto
// DO NOT EDIT!
/*
Package io_prometheus_client is a generated protocol buffer package.
It is generated from these files:
metrics.proto
It has these top-level messages:
LabelPair
Gauge
Counter
Quantile
Summary
Custom
Metric
MetricFamily
*/
package io_prometheus_client
import proto "code.google.com/p/goprotobuf/proto"
......@@ -19,17 +35,20 @@ const (
MetricType_COUNTER MetricType = 0
MetricType_GAUGE MetricType = 1
MetricType_SUMMARY MetricType = 2
MetricType_CUSTOM MetricType = 3
)
var MetricType_name = map[int32]string{
0: "COUNTER",
1: "GAUGE",
2: "SUMMARY",
3: "CUSTOM",
}
var MetricType_value = map[string]int32{
"COUNTER": 0,
"GAUGE": 1,
"SUMMARY": 2,
"CUSTOM": 3,
}
func (x MetricType) Enum() *MetricType {
......@@ -40,9 +59,6 @@ func (x MetricType) Enum() *MetricType {
func (x MetricType) String() string {
return proto.EnumName(MetricType_name, int32(x))
}
func (x MetricType) MarshalJSON() ([]byte, error) {
return json.Marshal(x.String())
}
func (x *MetricType) UnmarshalJSON(data []byte) error {
value, err := proto.UnmarshalJSONEnum(MetricType_value, data, "MetricType")
if err != nil {
......@@ -164,11 +180,29 @@ func (m *Summary) GetQuantile() []*Quantile {
return nil
}
type Custom struct {
Value *float64 `protobuf:"fixed64,1,opt,name=value" json:"value,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
func (m *Custom) Reset() { *m = Custom{} }
func (m *Custom) String() string { return proto.CompactTextString(m) }
func (*Custom) ProtoMessage() {}
func (m *Custom) GetValue() float64 {
if m != nil && m.Value != nil {
return *m.Value
}
return 0
}
type Metric struct {
Label []*LabelPair `protobuf:"bytes,1,rep,name=label" json:"label,omitempty"`
Gauge *Gauge `protobuf:"bytes,2,opt,name=gauge" json:"gauge,omitempty"`
Counter *Counter `protobuf:"bytes,3,opt,name=counter" json:"counter,omitempty"`
Summary *Summary `protobuf:"bytes,4,opt,name=summary" json:"summary,omitempty"`
Custom *Custom `protobuf:"bytes,5,opt,name=custom" json:"custom,omitempty"`
TimestampMs *int64 `protobuf:"varint,6,opt,name=timestamp_ms" json:"timestamp_ms,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
......@@ -204,6 +238,20 @@ func (m *Metric) GetSummary() *Summary {
return nil
}
func (m *Metric) GetCustom() *Custom {
if m != nil {
return m.Custom
}
return nil
}
func (m *Metric) GetTimestampMs() int64 {
if m != nil && m.TimestampMs != nil {
return *m.TimestampMs
}
return 0
}
type MetricFamily struct {
Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
Help *string `protobuf:"bytes,2,opt,name=help" json:"help,omitempty"`
......@@ -234,7 +282,7 @@ func (m *MetricFamily) GetType() MetricType {
if m != nil && m.Type != nil {
return *m.Type
}
return 0
return MetricType_COUNTER
}
func (m *MetricFamily) GetMetric() []*Metric {
......
......@@ -25,6 +25,7 @@ enum MetricType {
COUNTER = 0;
GAUGE = 1;
SUMMARY = 2;
CUSTOM = 3;
}
message Gauge {
......@@ -46,11 +47,17 @@ message Summary {
repeated Quantile quantile = 3;
}
message Custom {
optional double value = 1;
}
message Metric {
repeated LabelPair label = 1;
optional Gauge gauge = 2;
optional Counter counter = 3;
optional Summary summary = 4;
repeated LabelPair label = 1;
optional Gauge gauge = 2;
optional Counter counter = 3;
optional Summary summary = 4;
optional Custom custom = 5;
optional int64 timestamp_ms = 6;
}
message MetricFamily {
......
......@@ -14,7 +14,7 @@ from google.protobuf import descriptor_pb2
DESCRIPTOR = _descriptor.FileDescriptor(
name='metrics.proto',
package='io.prometheus.client',
serialized_pb='\n\rmetrics.proto\x12\x14io.prometheus.client\"(\n\tLabelPair\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t\"\x16\n\x05Gauge\x12\r\n\x05value\x18\x01 \x01(\x01\"\x18\n\x07\x43ounter\x12\r\n\x05value\x18\x01 \x01(\x01\"+\n\x08Quantile\x12\x10\n\x08quantile\x18\x01 \x01(\x01\x12\r\n\x05value\x18\x02 \x01(\x01\"e\n\x07Summary\x12\x14\n\x0csample_count\x18\x01 \x01(\x04\x12\x12\n\nsample_sum\x18\x02 \x01(\x01\x12\x30\n\x08quantile\x18\x03 \x03(\x0b\x32\x1e.io.prometheus.client.Quantile\"\xc4\x01\n\x06Metric\x12.\n\x05label\x18\x01 \x03(\x0b\x32\x1f.io.prometheus.client.LabelPair\x12*\n\x05gauge\x18\x02 \x01(\x0b\x32\x1b.io.prometheus.client.Gauge\x12.\n\x07\x63ounter\x18\x03 \x01(\x0b\x32\x1d.io.prometheus.client.Counter\x12.\n\x07summary\x18\x04 \x01(\x0b\x32\x1d.io.prometheus.client.Summary\"\x88\x01\n\x0cMetricFamily\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0c\n\x04help\x18\x02 \x01(\t\x12.\n\x04type\x18\x03 \x01(\x0e\x32 .io.prometheus.client.MetricType\x12,\n\x06metric\x18\x04 \x03(\x0b\x32\x1c.io.prometheus.client.Metric*1\n\nMetricType\x12\x0b\n\x07\x43OUNTER\x10\x00\x12\t\n\x05GAUGE\x10\x01\x12\x0b\n\x07SUMMARY\x10\x02\x42\x16\n\x14io.prometheus.client')
serialized_pb='\n\rmetrics.proto\x12\x14io.prometheus.client\"(\n\tLabelPair\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t\"\x16\n\x05Gauge\x12\r\n\x05value\x18\x01 \x01(\x01\"\x18\n\x07\x43ounter\x12\r\n\x05value\x18\x01 \x01(\x01\"+\n\x08Quantile\x12\x10\n\x08quantile\x18\x01 \x01(\x01\x12\r\n\x05value\x18\x02 \x01(\x01\"e\n\x07Summary\x12\x14\n\x0csample_count\x18\x01 \x01(\x04\x12\x12\n\nsample_sum\x18\x02 \x01(\x01\x12\x30\n\x08quantile\x18\x03 \x03(\x0b\x32\x1e.io.prometheus.client.Quantile\"\x17\n\x06\x43ustom\x12\r\n\x05value\x18\x01 \x01(\x01\"\x88\x02\n\x06Metric\x12.\n\x05label\x18\x01 \x03(\x0b\x32\x1f.io.prometheus.client.LabelPair\x12*\n\x05gauge\x18\x02 \x01(\x0b\x32\x1b.io.prometheus.client.Gauge\x12.\n\x07\x63ounter\x18\x03 \x01(\x0b\x32\x1d.io.prometheus.client.Counter\x12.\n\x07summary\x18\x04 \x01(\x0b\x32\x1d.io.prometheus.client.Summary\x12,\n\x06\x63ustom\x18\x05 \x01(\x0b\x32\x1c.io.prometheus.client.Custom\x12\x14\n\x0ctimestamp_ms\x18\x06 \x01(\x03\"\x88\x01\n\x0cMetricFamily\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0c\n\x04help\x18\x02 \x01(\t\x12.\n\x04type\x18\x03 \x01(\x0e\x32 .io.prometheus.client.MetricType\x12,\n\x06metric\x18\x04 \x03(\x0b\x32\x1c.io.prometheus.client.Metric*=\n\nMetricType\x12\x0b\n\x07\x43OUNTER\x10\x00\x12\t\n\x05GAUGE\x10\x01\x12\x0b\n\x07SUMMARY\x10\x02\x12\n\n\x06\x43USTOM\x10\x03\x42\x16\n\x14io.prometheus.client')
_METRICTYPE = _descriptor.EnumDescriptor(
name='MetricType',
......@@ -34,17 +34,22 @@ _METRICTYPE = _descriptor.EnumDescriptor(
name='SUMMARY', index=2, number=2,
options=None,
type=None),
_descriptor.EnumValueDescriptor(
name='CUSTOM', index=3, number=3,
options=None,
type=None),
],
containing_type=None,
options=None,
serialized_start=617,
serialized_end=666,
serialized_start=710,
serialized_end=771,
)
MetricType = enum_type_wrapper.EnumTypeWrapper(_METRICTYPE)
COUNTER = 0
GAUGE = 1
SUMMARY = 2
CUSTOM = 3
......@@ -216,6 +221,34 @@ _SUMMARY = _descriptor.Descriptor(
)
_CUSTOM = _descriptor.Descriptor(
name='Custom',
full_name='io.prometheus.client.Custom',
filename=None,
file=DESCRIPTOR,
containing_type=None,
fields=[
_descriptor.FieldDescriptor(
name='value', full_name='io.prometheus.client.Custom.value', index=0,
number=1, type=1, cpp_type=5, label=1,
has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
],
extensions=[
],
nested_types=[],
enum_types=[
],
options=None,
is_extendable=False,
extension_ranges=[],
serialized_start=279,
serialized_end=302,
)
_METRIC = _descriptor.Descriptor(
name='Metric',
full_name='io.prometheus.client.Metric',
......@@ -251,6 +284,20 @@ _METRIC = _descriptor.Descriptor(
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
_descriptor.FieldDescriptor(
name='custom', full_name='io.prometheus.client.Metric.custom', index=4,
number=5, type=11, cpp_type=10, label=1,
has_default_value=False, default_value=None,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
_descriptor.FieldDescriptor(
name='timestamp_ms', full_name='io.prometheus.client.Metric.timestamp_ms', index=5,
number=6, type=3, cpp_type=2, label=1,
has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
],
extensions=[
],
......@@ -260,8 +307,8 @@ _METRIC = _descriptor.Descriptor(
options=None,
is_extendable=False,
extension_ranges=[],
serialized_start=280,
serialized_end=476,
serialized_start=305,
serialized_end=569,
)
......@@ -309,8 +356,8 @@ _METRICFAMILY = _descriptor.Descriptor(
options=None,
is_extendable=False,
extension_ranges=[],
serialized_start=479,
serialized_end=615,
serialized_start=572,
serialized_end=708,
)
_SUMMARY.fields_by_name['quantile'].message_type = _QUANTILE
......@@ -318,6 +365,7 @@ _METRIC.fields_by_name['label'].message_type = _LABELPAIR
_METRIC.fields_by_name['gauge'].message_type = _GAUGE
_METRIC.fields_by_name['counter'].message_type = _COUNTER
_METRIC.fields_by_name['summary'].message_type = _SUMMARY
_METRIC.fields_by_name['custom'].message_type = _CUSTOM
_METRICFAMILY.fields_by_name['type'].enum_type = _METRICTYPE
_METRICFAMILY.fields_by_name['metric'].message_type = _METRIC
DESCRIPTOR.message_types_by_name['LabelPair'] = _LABELPAIR
......@@ -325,6 +373,7 @@ DESCRIPTOR.message_types_by_name['Gauge'] = _GAUGE
DESCRIPTOR.message_types_by_name['Counter'] = _COUNTER
DESCRIPTOR.message_types_by_name['Quantile'] = _QUANTILE
DESCRIPTOR.message_types_by_name['Summary'] = _SUMMARY
DESCRIPTOR.message_types_by_name['Custom'] = _CUSTOM
DESCRIPTOR.message_types_by_name['Metric'] = _METRIC
DESCRIPTOR.message_types_by_name['MetricFamily'] = _METRICFAMILY
......@@ -358,6 +407,12 @@ class Summary(_message.Message):
# @@protoc_insertion_point(class_scope:io.prometheus.client.Summary)
class Custom(_message.Message):
__metaclass__ = _reflection.GeneratedProtocolMessageType
DESCRIPTOR = _CUSTOM
# @@protoc_insertion_point(class_scope:io.prometheus.client.Custom)
class Metric(_message.Message):
__metaclass__ = _reflection.GeneratedProtocolMessageType
DESCRIPTOR = _METRIC
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment