libprom  1.2.0
C based libraries to expose metrics in Promtheus exposition format
prom_histogram_buckets.h
Go to the documentation of this file.
1 /*
2 Copyright 2019-2020 DigitalOcean Inc.
3 Copyright 2021 Jens Elkner <jel+libprom@cs.uni-magdeburg.de>
4 
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
8 
9  http://www.apache.org/licenses/LICENSE-2.0
10 
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16 */
17 
25 #include "stdlib.h"
26 
27 #ifndef PROM_HISTOGRAM_BUCKETS_H
28 #define PROM_HISTOGRAM_BUCKETS_H
29 
30 typedef struct phb {
31  int count;
32  const double *upper_bound;
33  const char **key;
34 } phb_t;
35 
42 phb_t *phb_new(size_t count, double bucket, ...);
43 
48 
57 phb_t *phb_linear(double start, double width, size_t count);
58 
68 phb_t *phb_exponential(double start, double factor, size_t count);
69 
77 int phb_destroy(phb_t *self);
78 
84 size_t phb_count(phb_t *self);
85 
86 #endif // PROM_HISTOGRAM_BUCKETS_H
phb::upper_bound
const double * upper_bound
count ascending upper limits
Definition: prom_histogram_buckets.h:32
phb::key
const char ** key
count keys used to lookup samples.
Definition: prom_histogram_buckets.h:33
phb_exponential
phb_t * phb_exponential(double start, double factor, size_t count)
Construct an exponentially sized prom histogram bucket.
phb_linear
phb_t * phb_linear(double start, double width, size_t count)
Construct a linearly sized prom histogram bucket.
phb
Definition: prom_histogram_buckets.h:30
prom_histogram_default_buckets
phb_t * prom_histogram_default_buckets
default histogram buckets: .005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10
phb_destroy
int phb_destroy(phb_t *self)
Destroy the given prom histogram bucket.
phb_new
phb_t * phb_new(size_t count, double bucket,...)
Construct a new histogram bucket with the given values.
phb_count
size_t phb_count(phb_t *self)
Get the number of valus in the given bucket.
phb::count
int count
Number of buckets.
Definition: prom_histogram_buckets.h:31