Skip to content

Commit

Permalink
Merge pull request #19 from yurrriq/feature/gpb-tweaks
Browse files Browse the repository at this point in the history
No compile-time dependency on gpb, clean generated proto stuff on rebar3 clean
  • Loading branch information
deadtrickster authored Aug 15, 2016
2 parents 7fb8c30 + ed0cacd commit 2c4bd1c
Show file tree
Hide file tree
Showing 2 changed files with 129 additions and 132 deletions.
12 changes: 5 additions & 7 deletions rebar.config
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
% -*- mode: Erlang;-*-
{erl_opts, [debug_info, {i,"./_build/default/plugins/gpb/include/"}]}.
%% -*- mode: erlang -*-
{erl_opts, [debug_info]}.
{plugins, [{rebar3_gpb_plugin, "1.7.2"}]}.
{provider_hooks, [
{pre, [{compile, {protobuf, compile}}]}
]}.
{provider_hooks, [{pre, [{compile, {protobuf, compile}}]},
{post, [{clean, {protobuf, clean}}]}]}.
{gpb_opts, [{i, "src/model"},
{o_erl, "src/model"},
{o_hrl, "include"},
{strings_as_binaries, true},
type_specs]}.
defs_as_proplists, strings_as_binaries, type_specs]}.
{deps, []}.
{cover_enabled, true}.

Expand Down
249 changes: 124 additions & 125 deletions src/model/prometheus_model.erl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
-export([gpb_version_as_string/0, gpb_version_as_list/0]).

-include("prometheus_model.hrl").
-include("gpb.hrl").

%% enumerated types
-type 'MetricType'() :: 'COUNTER' | 'GAUGE' | 'SUMMARY' | 'UNTYPED' | 'HISTOGRAM'.
Expand Down Expand Up @@ -2286,77 +2285,77 @@ get_msg_defs() ->
[{'COUNTER', 0}, {'GAUGE', 1}, {'SUMMARY', 2},
{'UNTYPED', 3}, {'HISTOGRAM', 4}]},
{{msg, 'Bucket'},
[#field{name = cumulative_count, fnum = 1, rnum = 2,
type = uint64, occurrence = optional, opts = []},
#field{name = upper_bound, fnum = 2, rnum = 3,
type = double, occurrence = optional, opts = []}]},
[[{name, cumulative_count}, {fnum, 1}, {rnum, 2},
{type, uint64}, {occurrence, optional}, {opts, []}],
[{name, upper_bound}, {fnum, 2}, {rnum, 3},
{type, double}, {occurrence, optional}, {opts, []}]]},
{{msg, 'Histogram'},
[#field{name = sample_count, fnum = 1, rnum = 2,
type = uint64, occurrence = optional, opts = []},
#field{name = sample_sum, fnum = 2, rnum = 3,
type = double, occurrence = optional, opts = []},
#field{name = bucket, fnum = 3, rnum = 4,
type = {msg, 'Bucket'}, occurrence = repeated,
opts = []}]},
[[{name, sample_count}, {fnum, 1}, {rnum, 2},
{type, uint64}, {occurrence, optional}, {opts, []}],
[{name, sample_sum}, {fnum, 2}, {rnum, 3},
{type, double}, {occurrence, optional}, {opts, []}],
[{name, bucket}, {fnum, 3}, {rnum, 4},
{type, {msg, 'Bucket'}}, {occurrence, repeated},
{opts, []}]]},
{{msg, 'Untyped'},
[#field{name = value, fnum = 1, rnum = 2, type = double,
occurrence = optional, opts = []}]},
[[{name, value}, {fnum, 1}, {rnum, 2}, {type, double},
{occurrence, optional}, {opts, []}]]},
{{msg, 'Quantile'},
[#field{name = quantile, fnum = 1, rnum = 2,
type = double, occurrence = optional, opts = []},
#field{name = value, fnum = 2, rnum = 3, type = double,
occurrence = optional, opts = []}]},
[[{name, quantile}, {fnum, 1}, {rnum, 2},
{type, double}, {occurrence, optional}, {opts, []}],
[{name, value}, {fnum, 2}, {rnum, 3}, {type, double},
{occurrence, optional}, {opts, []}]]},
{{msg, 'Summary'},
[#field{name = sample_count, fnum = 1, rnum = 2,
type = uint64, occurrence = optional, opts = []},
#field{name = sample_sum, fnum = 2, rnum = 3,
type = double, occurrence = optional, opts = []},
#field{name = quantile, fnum = 3, rnum = 4,
type = {msg, 'Quantile'}, occurrence = repeated,
opts = []}]},
[[{name, sample_count}, {fnum, 1}, {rnum, 2},
{type, uint64}, {occurrence, optional}, {opts, []}],
[{name, sample_sum}, {fnum, 2}, {rnum, 3},
{type, double}, {occurrence, optional}, {opts, []}],
[{name, quantile}, {fnum, 3}, {rnum, 4},
{type, {msg, 'Quantile'}}, {occurrence, repeated},
{opts, []}]]},
{{msg, 'Counter'},
[#field{name = value, fnum = 1, rnum = 2, type = double,
occurrence = optional, opts = []}]},
[[{name, value}, {fnum, 1}, {rnum, 2}, {type, double},
{occurrence, optional}, {opts, []}]]},
{{msg, 'Gauge'},
[#field{name = value, fnum = 1, rnum = 2, type = double,
occurrence = optional, opts = []}]},
[[{name, value}, {fnum, 1}, {rnum, 2}, {type, double},
{occurrence, optional}, {opts, []}]]},
{{msg, 'LabelPair'},
[#field{name = name, fnum = 1, rnum = 2, type = string,
occurrence = optional, opts = []},
#field{name = value, fnum = 2, rnum = 3, type = string,
occurrence = optional, opts = []}]},
[[{name, name}, {fnum, 1}, {rnum, 2}, {type, string},
{occurrence, optional}, {opts, []}],
[{name, value}, {fnum, 2}, {rnum, 3}, {type, string},
{occurrence, optional}, {opts, []}]]},
{{msg, 'Metric'},
[#field{name = label, fnum = 1, rnum = 2,
type = {msg, 'LabelPair'}, occurrence = repeated,
opts = []},
#field{name = gauge, fnum = 2, rnum = 3,
type = {msg, 'Gauge'}, occurrence = optional,
opts = []},
#field{name = counter, fnum = 3, rnum = 4,
type = {msg, 'Counter'}, occurrence = optional,
opts = []},
#field{name = summary, fnum = 4, rnum = 5,
type = {msg, 'Summary'}, occurrence = optional,
opts = []},
#field{name = untyped, fnum = 5, rnum = 6,
type = {msg, 'Untyped'}, occurrence = optional,
opts = []},
#field{name = histogram, fnum = 7, rnum = 7,
type = {msg, 'Histogram'}, occurrence = optional,
opts = []},
#field{name = timestamp_ms, fnum = 6, rnum = 8,
type = int64, occurrence = optional, opts = []}]},
[[{name, label}, {fnum, 1}, {rnum, 2},
{type, {msg, 'LabelPair'}}, {occurrence, repeated},
{opts, []}],
[{name, gauge}, {fnum, 2}, {rnum, 3},
{type, {msg, 'Gauge'}}, {occurrence, optional},
{opts, []}],
[{name, counter}, {fnum, 3}, {rnum, 4},
{type, {msg, 'Counter'}}, {occurrence, optional},
{opts, []}],
[{name, summary}, {fnum, 4}, {rnum, 5},
{type, {msg, 'Summary'}}, {occurrence, optional},
{opts, []}],
[{name, untyped}, {fnum, 5}, {rnum, 6},
{type, {msg, 'Untyped'}}, {occurrence, optional},
{opts, []}],
[{name, histogram}, {fnum, 7}, {rnum, 7},
{type, {msg, 'Histogram'}}, {occurrence, optional},
{opts, []}],
[{name, timestamp_ms}, {fnum, 6}, {rnum, 8},
{type, int64}, {occurrence, optional}, {opts, []}]]},
{{msg, 'MetricFamily'},
[#field{name = name, fnum = 1, rnum = 2, type = string,
occurrence = optional, opts = []},
#field{name = help, fnum = 2, rnum = 3, type = string,
occurrence = optional, opts = []},
#field{name = type, fnum = 3, rnum = 4,
type = {enum, 'MetricType'}, occurrence = optional,
opts = []},
#field{name = metric, fnum = 4, rnum = 5,
type = {msg, 'Metric'}, occurrence = repeated,
opts = []}]}].
[[{name, name}, {fnum, 1}, {rnum, 2}, {type, string},
{occurrence, optional}, {opts, []}],
[{name, help}, {fnum, 2}, {rnum, 3}, {type, string},
{occurrence, optional}, {opts, []}],
[{name, type}, {fnum, 3}, {rnum, 4},
{type, {enum, 'MetricType'}}, {occurrence, optional},
{opts, []}],
[{name, metric}, {fnum, 4}, {rnum, 5},
{type, {msg, 'Metric'}}, {occurrence, repeated},
{opts, []}]]}].


get_msg_names() ->
Expand All @@ -2383,77 +2382,77 @@ fetch_enum_def(EnumName) ->


find_msg_def('Bucket') ->
[#field{name = cumulative_count, fnum = 1, rnum = 2,
type = uint64, occurrence = optional, opts = []},
#field{name = upper_bound, fnum = 2, rnum = 3,
type = double, occurrence = optional, opts = []}];
[[{name, cumulative_count}, {fnum, 1}, {rnum, 2},
{type, uint64}, {occurrence, optional}, {opts, []}],
[{name, upper_bound}, {fnum, 2}, {rnum, 3},
{type, double}, {occurrence, optional}, {opts, []}]];
find_msg_def('Histogram') ->
[#field{name = sample_count, fnum = 1, rnum = 2,
type = uint64, occurrence = optional, opts = []},
#field{name = sample_sum, fnum = 2, rnum = 3,
type = double, occurrence = optional, opts = []},
#field{name = bucket, fnum = 3, rnum = 4,
type = {msg, 'Bucket'}, occurrence = repeated,
opts = []}];
[[{name, sample_count}, {fnum, 1}, {rnum, 2},
{type, uint64}, {occurrence, optional}, {opts, []}],
[{name, sample_sum}, {fnum, 2}, {rnum, 3},
{type, double}, {occurrence, optional}, {opts, []}],
[{name, bucket}, {fnum, 3}, {rnum, 4},
{type, {msg, 'Bucket'}}, {occurrence, repeated},
{opts, []}]];
find_msg_def('Untyped') ->
[#field{name = value, fnum = 1, rnum = 2, type = double,
occurrence = optional, opts = []}];
[[{name, value}, {fnum, 1}, {rnum, 2}, {type, double},
{occurrence, optional}, {opts, []}]];
find_msg_def('Quantile') ->
[#field{name = quantile, fnum = 1, rnum = 2,
type = double, occurrence = optional, opts = []},
#field{name = value, fnum = 2, rnum = 3, type = double,
occurrence = optional, opts = []}];
[[{name, quantile}, {fnum, 1}, {rnum, 2},
{type, double}, {occurrence, optional}, {opts, []}],
[{name, value}, {fnum, 2}, {rnum, 3}, {type, double},
{occurrence, optional}, {opts, []}]];
find_msg_def('Summary') ->
[#field{name = sample_count, fnum = 1, rnum = 2,
type = uint64, occurrence = optional, opts = []},
#field{name = sample_sum, fnum = 2, rnum = 3,
type = double, occurrence = optional, opts = []},
#field{name = quantile, fnum = 3, rnum = 4,
type = {msg, 'Quantile'}, occurrence = repeated,
opts = []}];
[[{name, sample_count}, {fnum, 1}, {rnum, 2},
{type, uint64}, {occurrence, optional}, {opts, []}],
[{name, sample_sum}, {fnum, 2}, {rnum, 3},
{type, double}, {occurrence, optional}, {opts, []}],
[{name, quantile}, {fnum, 3}, {rnum, 4},
{type, {msg, 'Quantile'}}, {occurrence, repeated},
{opts, []}]];
find_msg_def('Counter') ->
[#field{name = value, fnum = 1, rnum = 2, type = double,
occurrence = optional, opts = []}];
[[{name, value}, {fnum, 1}, {rnum, 2}, {type, double},
{occurrence, optional}, {opts, []}]];
find_msg_def('Gauge') ->
[#field{name = value, fnum = 1, rnum = 2, type = double,
occurrence = optional, opts = []}];
[[{name, value}, {fnum, 1}, {rnum, 2}, {type, double},
{occurrence, optional}, {opts, []}]];
find_msg_def('LabelPair') ->
[#field{name = name, fnum = 1, rnum = 2, type = string,
occurrence = optional, opts = []},
#field{name = value, fnum = 2, rnum = 3, type = string,
occurrence = optional, opts = []}];
[[{name, name}, {fnum, 1}, {rnum, 2}, {type, string},
{occurrence, optional}, {opts, []}],
[{name, value}, {fnum, 2}, {rnum, 3}, {type, string},
{occurrence, optional}, {opts, []}]];
find_msg_def('Metric') ->
[#field{name = label, fnum = 1, rnum = 2,
type = {msg, 'LabelPair'}, occurrence = repeated,
opts = []},
#field{name = gauge, fnum = 2, rnum = 3,
type = {msg, 'Gauge'}, occurrence = optional,
opts = []},
#field{name = counter, fnum = 3, rnum = 4,
type = {msg, 'Counter'}, occurrence = optional,
opts = []},
#field{name = summary, fnum = 4, rnum = 5,
type = {msg, 'Summary'}, occurrence = optional,
opts = []},
#field{name = untyped, fnum = 5, rnum = 6,
type = {msg, 'Untyped'}, occurrence = optional,
opts = []},
#field{name = histogram, fnum = 7, rnum = 7,
type = {msg, 'Histogram'}, occurrence = optional,
opts = []},
#field{name = timestamp_ms, fnum = 6, rnum = 8,
type = int64, occurrence = optional, opts = []}];
[[{name, label}, {fnum, 1}, {rnum, 2},
{type, {msg, 'LabelPair'}}, {occurrence, repeated},
{opts, []}],
[{name, gauge}, {fnum, 2}, {rnum, 3},
{type, {msg, 'Gauge'}}, {occurrence, optional},
{opts, []}],
[{name, counter}, {fnum, 3}, {rnum, 4},
{type, {msg, 'Counter'}}, {occurrence, optional},
{opts, []}],
[{name, summary}, {fnum, 4}, {rnum, 5},
{type, {msg, 'Summary'}}, {occurrence, optional},
{opts, []}],
[{name, untyped}, {fnum, 5}, {rnum, 6},
{type, {msg, 'Untyped'}}, {occurrence, optional},
{opts, []}],
[{name, histogram}, {fnum, 7}, {rnum, 7},
{type, {msg, 'Histogram'}}, {occurrence, optional},
{opts, []}],
[{name, timestamp_ms}, {fnum, 6}, {rnum, 8},
{type, int64}, {occurrence, optional}, {opts, []}]];
find_msg_def('MetricFamily') ->
[#field{name = name, fnum = 1, rnum = 2, type = string,
occurrence = optional, opts = []},
#field{name = help, fnum = 2, rnum = 3, type = string,
occurrence = optional, opts = []},
#field{name = type, fnum = 3, rnum = 4,
type = {enum, 'MetricType'}, occurrence = optional,
opts = []},
#field{name = metric, fnum = 4, rnum = 5,
type = {msg, 'Metric'}, occurrence = repeated,
opts = []}];
[[{name, name}, {fnum, 1}, {rnum, 2}, {type, string},
{occurrence, optional}, {opts, []}],
[{name, help}, {fnum, 2}, {rnum, 3}, {type, string},
{occurrence, optional}, {opts, []}],
[{name, type}, {fnum, 3}, {rnum, 4},
{type, {enum, 'MetricType'}}, {occurrence, optional},
{opts, []}],
[{name, metric}, {fnum, 4}, {rnum, 5},
{type, {msg, 'Metric'}}, {occurrence, repeated},
{opts, []}]];
find_msg_def(_) -> error.


Expand Down

0 comments on commit 2c4bd1c

Please sign in to comment.