1*81b1a5f5Stb /* $OpenBSD: ometric.h,v 1.6 2023/01/06 13:26:57 tb Exp $ */ 277a10e6fSclaudio 377a10e6fSclaudio /* 477a10e6fSclaudio * Copyright (c) 2022 Claudio Jeker <claudio@openbsd.org> 577a10e6fSclaudio * 677a10e6fSclaudio * Permission to use, copy, modify, and distribute this software for any 777a10e6fSclaudio * purpose with or without fee is hereby granted, provided that the above 877a10e6fSclaudio * copyright notice and this permission notice appear in all copies. 977a10e6fSclaudio * 1077a10e6fSclaudio * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 1177a10e6fSclaudio * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 1277a10e6fSclaudio * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 1377a10e6fSclaudio * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 1477a10e6fSclaudio * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 1577a10e6fSclaudio * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 1677a10e6fSclaudio * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 1777a10e6fSclaudio */ 1877a10e6fSclaudio 1977a10e6fSclaudio enum ometric_type { 2077a10e6fSclaudio OMT_UNKNOWN, 2177a10e6fSclaudio OMT_GAUGE, 2277a10e6fSclaudio OMT_COUNTER, 2377a10e6fSclaudio OMT_STATESET, 2477a10e6fSclaudio OMT_HISTOGRAM, 2577a10e6fSclaudio OMT_SUMMARY, 2677a10e6fSclaudio OMT_INFO, 2777a10e6fSclaudio }; 2877a10e6fSclaudio 2977a10e6fSclaudio struct ometric; 3077a10e6fSclaudio struct olabels; 3177a10e6fSclaudio 3277a10e6fSclaudio struct ometric *ometric_new(enum ometric_type, const char *, const char *); 3377a10e6fSclaudio struct ometric *ometric_new_state(const char * const *, size_t, const char *, 3477a10e6fSclaudio const char *); 3577a10e6fSclaudio void ometric_free_all(void); 3677a10e6fSclaudio struct olabels *olabels_new(const char * const *, const char **); 3777a10e6fSclaudio void olabels_free(struct olabels *); 3877a10e6fSclaudio 3960a4dc80Sclaudio int ometric_output_all(FILE *); 4077a10e6fSclaudio 4177a10e6fSclaudio /* functions to set gauge and counter metrics */ 4277a10e6fSclaudio void ometric_set_int(struct ometric *, uint64_t, struct olabels *); 4377a10e6fSclaudio void ometric_set_float(struct ometric *, double, struct olabels *); 4481e584e8Sclaudio void ometric_set_timespec(struct ometric *, const struct timespec *, 458168f856Sclaudio struct olabels *); 4677a10e6fSclaudio void ometric_set_info(struct ometric *, const char **, const char **, 4777a10e6fSclaudio struct olabels *); 4877a10e6fSclaudio void ometric_set_state(struct ometric *, const char *, struct olabels *); 49e70d5757Sclaudio void ometric_set_int_with_labels(struct ometric *, uint64_t, const char **, 50e70d5757Sclaudio const char **, struct olabels *); 5181e584e8Sclaudio void ometric_set_timespec_with_labels(struct ometric *, struct timespec *, 528168f856Sclaudio const char **, const char **, struct olabels *); 53e70d5757Sclaudio #define OKV(...) (const char *[]){ __VA_ARGS__, NULL } 54