Code Monkey home page Code Monkey logo

libprom's Introduction

libprom

This repo is a fork of the Prometheus client libraries for C repository.

It provides shared libraries for instrumenting software and exposing metrics in text format as defined by the Prometheus exposition format (see https://prometheus.io/docs/instrumenting/exposition_formats/ for more details). libprom provides the core API implementation, libpromhttp a simple web handler to expose metrics for scraping.

Improvements wrt. to the forked source:

  • bug and test fixes
  • much less useless bloat
  • compact function and type names, reduced code dups
  • better performance
  • enhanced and re-usable logging
  • better documentation
  • better process metrics about the collector itself incl. scrapetimes
  • compact output, i.e. option that allows to supress the huge # HELP and # TYPE overhead in prometheus formatted output
  • has now a prom_counter_reset() function
  • prom_string_builder() is now public, i.e. usable by libprom consumers
  • improved/KISSed process limit scraping (10..200x faster)
  • libprom's process_collector is enhanced and now public, i.e. can now be used by libprom consumers to collect metrics of other processes easily
  • new functions prom_collector_data_set() and prom_collector_data_get() allow to attach custom data by reference to every collector as well as read them back
  • Solaris/Smartos/OmniOS/Illumos support

Build, Install, Test

Requirements: A recent cmake, gcc and libmicrohttpd version incl. development aka header files. Other compilers than gcc may work, too (but have not been tested yet).

To build libprom and libpromhttp just run make. To build the API docs, run make docs. To install the libs, etc. change the working directory to target/build/ and run make install (e.g. cd prom/build && DESTDIR=/tmp/libprom make install).

To test the libs, run make test.

If you do not want to compile libprom by yourself, any successful CI job on the Github Action Page contains the libprom archive for x86_64 Ubuntu, where the CI tests have been run. Just click on a CI job and scroll down to the Artifacts section. On Linux they probably work on most more or less recent distributions.

Last but not least you may try the Ubuntu packages hosted on https://pkg.cs.ovgu.de/LNF/linux/ubuntu/release/.

API, Documentation, Usage

  • https://jelmd.github.io/libprom/
  • example directory of libprom
  • To compile your own libprom enhanced app, just add #include <libprom/prom.h> and optionally #include <libprom/promhttp.h> to the related source and link it with -lprom and optionally with -lpromhttp.

Branch info

The master branch is used to track the main development branch of the upstream repo, the main branch is the main development branch of this repo.

libprom's People

Contributors

miroswan avatar lyda avatar michaelxniu avatar pavelmash avatar prksu avatar andrewwa0 avatar cfsmp3 avatar qmx avatar jecklabs avatar juergenhoetzel avatar taotetek avatar

Stargazers

[riftlab] ErgoZ avatar Leonardo Rodoni avatar Frank Solli avatar Jens Elkner avatar

Watchers

James Cloos avatar

libprom's Issues

make fails

~/downloads/libprom $ make
mkdir prom/build && cd prom/build &&
TEST= cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_SKIP_BUILD_RPATH=TRUE -DCMAKE_C_FLAGS="-DPROM_LOG_ENABLE -g -O3" ..
-- The C compiler identification is Clang 15.0.7
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /data/data/com.termux/files/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Configuring done
-- Generating done
-- Build files have been written to: /data/data/com.termux/files/home/downloads/libprom/prom/build
cd prom/build && make VERBOSE=1
make[1]: Entering directory '/data/data/com.termux/files/home/downloads/libprom/prom/build'
/data/data/com.termux/files/usr/bin/cmake -S/data/data/com.termux/files/home/downloads/libprom/prom -B/data/data/com.termux/files/home/downloads/libprom/prom/build --check-build-system CMakeFiles/Makefile.cmake 0
/data/data/com.termux/files/usr/bin/cmake -E cmake_progress_start /data/data/com.termux/files/home/downloads/libprom/prom/build/CMakeFiles /data/data/com.termux/files/home/downloads/libprom/prom/build//CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[2]: Entering directory '/data/data/com.termux/files/home/downloads/libprom/prom/build'
make -f CMakeFiles/prom.dir/build.make CMakeFiles/prom.dir/depend
make[3]: Entering directory '/data/data/com.termux/files/home/downloads/libprom/prom/build'
cd /data/data/com.termux/files/home/downloads/libprom/prom/build && /data/data/com.termux/files/usr/bin/cmake -E cmake_depends "Unix Makefiles" /data/data/com.termux/files/home/downloads/libprom/prom /data/data/com.termux/files/home/downloads/libprom/prom /data/data/com.termux/files/home/downloads/libprom/prom/build /data/data/com.termux/files/home/downloads/libprom/prom/build /data/data/com.termux/files/home/downloads/libprom/prom/build/CMakeFiles/prom.dir/DependInfo.cmake --color=
make[3]: Leaving directory '/data/data/com.termux/files/home/downloads/libprom/prom/build'
make -f CMakeFiles/prom.dir/build.make CMakeFiles/prom.dir/build
make[3]: Entering directory '/data/data/com.termux/files/home/downloads/libprom/prom/build'
[ 5%] Building C object CMakeFiles/prom.dir/src/prom_collector.c.o
/data/data/com.termux/files/usr/bin/cc -Dprom_EXPORTS -I/data/data/com.termux/files/home/downloads/libprom/prom/include -I/data/data/com.termux/files/home/downloads/libprom/prom/src -DPROM_LOG_ENABLE -g -O3 -O2 -g -DNDEBUG -fPIC -Werror -Wuninitialized -Wall -Wno-unused-label -Wno-pragmas -std=gnu11 -std=gnu11 -MD -MT CMakeFiles/prom.dir/src/prom_collector.c.o -MF CMakeFiles/prom.dir/src/prom_collector.c.o.d -o CMakeFiles/prom.dir/src/prom_collector.c.o -c /data/data/com.termux/files/home/downloads/libprom/prom/src/prom_collector.c
[ 10%] Building C object CMakeFiles/prom.dir/src/prom_collector_registry.c.o
/data/data/com.termux/files/usr/bin/cc -Dprom_EXPORTS -I/data/data/com.termux/files/home/downloads/libprom/prom/include -I/data/data/com.termux/files/home/downloads/libprom/prom/src -DPROM_LOG_ENABLE -g -O3 -O2 -g -DNDEBUG -fPIC -Werror -Wuninitialized -Wall -Wno-unused-label -Wno-pragmas -std=gnu11 -std=gnu11 -MD -MT CMakeFiles/prom.dir/src/prom_collector_registry.c.o -MF CMakeFiles/prom.dir/src/prom_collector_registry.c.o.d -o CMakeFiles/prom.dir/src/prom_collector_registry.c.o -c /data/data/com.termux/files/home/downloads/libprom/prom/src/prom_collector_registry.c
[ 15%] Building C object CMakeFiles/prom.dir/src/prom_counter.c.o
/data/data/com.termux/files/usr/bin/cc -Dprom_EXPORTS -I/data/data/com.termux/files/home/downloads/libprom/prom/include -I/data/data/com.termux/files/home/downloads/libprom/prom/src -DPROM_LOG_ENABLE -g -O3 -O2 -g -DNDEBUG -fPIC -Werror -Wuninitialized -Wall -Wno-unused-label -Wno-pragmas -std=gnu11 -std=gnu11 -MD -MT CMakeFiles/prom.dir/src/prom_counter.c.o -MF CMakeFiles/prom.dir/src/prom_counter.c.o.d -o CMakeFiles/prom.dir/src/prom_counter.c.o -c /data/data/com.termux/files/home/downloads/libprom/prom/src/prom_counter.c
[ 21%] Building C object CMakeFiles/prom.dir/src/prom_gauge.c.o
/data/data/com.termux/files/usr/bin/cc -Dprom_EXPORTS -I/data/data/com.termux/files/home/downloads/libprom/prom/include -I/data/data/com.termux/files/home/downloads/libprom/prom/src -DPROM_LOG_ENABLE -g -O3 -O2 -g -DNDEBUG -fPIC -Werror -Wuninitialized -Wall -Wno-unused-label -Wno-pragmas -std=gnu11 -std=gnu11 -MD -MT CMakeFiles/prom.dir/src/prom_gauge.c.o -MF CMakeFiles/prom.dir/src/prom_gauge.c.o.d -o CMakeFiles/prom.dir/src/prom_gauge.c.o -c /data/data/com.termux/files/home/downloads/libprom/prom/src/prom_gauge.c
[ 26%] Building C object CMakeFiles/prom.dir/src/prom_histogram.c.o
/data/data/com.termux/files/usr/bin/cc -Dprom_EXPORTS -I/data/data/com.termux/files/home/downloads/libprom/prom/include -I/data/data/com.termux/files/home/downloads/libprom/prom/src -DPROM_LOG_ENABLE -g -O3 -O2 -g -DNDEBUG -fPIC -Werror -Wuninitialized -Wall -Wno-unused-label -Wno-pragmas -std=gnu11 -std=gnu11 -MD -MT CMakeFiles/prom.dir/src/prom_histogram.c.o -MF CMakeFiles/prom.dir/src/prom_histogram.c.o.d -o CMakeFiles/prom.dir/src/prom_histogram.c.o -c /data/data/com.termux/files/home/downloads/libprom/prom/src/prom_histogram.c
[ 31%] Building C object CMakeFiles/prom.dir/src/prom_histogram_buckets.c.o
/data/data/com.termux/files/usr/bin/cc -Dprom_EXPORTS -I/data/data/com.termux/files/home/downloads/libprom/prom/include -I/data/data/com.termux/files/home/downloads/libprom/prom/src -DPROM_LOG_ENABLE -g -O3 -O2 -g -DNDEBUG -fPIC -Werror -Wuninitialized -Wall -Wno-unused-label -Wno-pragmas -std=gnu11 -std=gnu11 -MD -MT CMakeFiles/prom.dir/src/prom_histogram_buckets.c.o -MF CMakeFiles/prom.dir/src/prom_histogram_buckets.c.o.d -o CMakeFiles/prom.dir/src/prom_histogram_buckets.c.o -c /data/data/com.termux/files/home/downloads/libprom/prom/src/prom_histogram_buckets.c
[ 36%] Building C object CMakeFiles/prom.dir/src/prom_linked_list.c.o
/data/data/com.termux/files/usr/bin/cc -Dprom_EXPORTS -I/data/data/com.termux/files/home/downloads/libprom/prom/include -I/data/data/com.termux/files/home/downloads/libprom/prom/src -DPROM_LOG_ENABLE -g -O3 -O2 -g -DNDEBUG -fPIC -Werror -Wuninitialized -Wall -Wno-unused-label -Wno-pragmas -std=gnu11 -std=gnu11 -MD -MT CMakeFiles/prom.dir/src/prom_linked_list.c.o -MF CMakeFiles/prom.dir/src/prom_linked_list.c.o.d -o CMakeFiles/prom.dir/src/prom_linked_list.c.o -c /data/data/com.termux/files/home/downloads/libprom/prom/src/prom_linked_list.c
[ 42%] Building C object CMakeFiles/prom.dir/src/prom_log.c.o
/data/data/com.termux/files/usr/bin/cc -Dprom_EXPORTS -I/data/data/com.termux/files/home/downloads/libprom/prom/include -I/data/data/com.termux/files/home/downloads/libprom/prom/src -DPROM_LOG_ENABLE -g -O3 -O2 -g -DNDEBUG -fPIC -Werror -Wuninitialized -Wall -Wno-unused-label -Wno-pragmas -std=gnu11 -std=gnu11 -MD -MT CMakeFiles/prom.dir/src/prom_log.c.o -MF CMakeFiles/prom.dir/src/prom_log.c.o.d -o CMakeFiles/prom.dir/src/prom_log.c.o -c /data/data/com.termux/files/home/downloads/libprom/prom/src/prom_log.c
[ 47%] Building C object CMakeFiles/prom.dir/src/prom_map.c.o
/data/data/com.termux/files/usr/bin/cc -Dprom_EXPORTS -I/data/data/com.termux/files/home/downloads/libprom/prom/include -I/data/data/com.termux/files/home/downloads/libprom/prom/src -DPROM_LOG_ENABLE -g -O3 -O2 -g -DNDEBUG -fPIC -Werror -Wuninitialized -Wall -Wno-unused-label -Wno-pragmas -std=gnu11 -std=gnu11 -MD -MT CMakeFiles/prom.dir/src/prom_map.c.o -MF CMakeFiles/prom.dir/src/prom_map.c.o.d -o CMakeFiles/prom.dir/src/prom_map.c.o -c /data/data/com.termux/files/home/downloads/libprom/prom/src/prom_map.c
[ 52%] Building C object CMakeFiles/prom.dir/src/prom_metric.c.o
/data/data/com.termux/files/usr/bin/cc -Dprom_EXPORTS -I/data/data/com.termux/files/home/downloads/libprom/prom/include -I/data/data/com.termux/files/home/downloads/libprom/prom/src -DPROM_LOG_ENABLE -g -O3 -O2 -g -DNDEBUG -fPIC -Werror -Wuninitialized -Wall -Wno-unused-label -Wno-pragmas -std=gnu11 -std=gnu11 -MD -MT CMakeFiles/prom.dir/src/prom_metric.c.o -MF CMakeFiles/prom.dir/src/prom_metric.c.o.d -o CMakeFiles/prom.dir/src/prom_metric.c.o -c /data/data/com.termux/files/home/downloads/libprom/prom/src/prom_metric.c
[ 57%] Building C object CMakeFiles/prom.dir/src/prom_metric_formatter.c.o
/data/data/com.termux/files/usr/bin/cc -Dprom_EXPORTS -I/data/data/com.termux/files/home/downloads/libprom/prom/include -I/data/data/com.termux/files/home/downloads/libprom/prom/src -DPROM_LOG_ENABLE -g -O3 -O2 -g -DNDEBUG -fPIC -Werror -Wuninitialized -Wall -Wno-unused-label -Wno-pragmas -std=gnu11 -std=gnu11 -MD -MT CMakeFiles/prom.dir/src/prom_metric_formatter.c.o -MF CMakeFiles/prom.dir/src/prom_metric_formatter.c.o.d -o CMakeFiles/prom.dir/src/prom_metric_formatter.c.o -c /data/data/com.termux/files/home/downloads/libprom/prom/src/prom_metric_formatter.c
[ 63%] Building C object CMakeFiles/prom.dir/src/prom_metric_sample.c.o
/data/data/com.termux/files/usr/bin/cc -Dprom_EXPORTS -I/data/data/com.termux/files/home/downloads/libprom/prom/include -I/data/data/com.termux/files/home/downloads/libprom/prom/src -DPROM_LOG_ENABLE -g -O3 -O2 -g -DNDEBUG -fPIC -Werror -Wuninitialized -Wall -Wno-unused-label -Wno-pragmas -std=gnu11 -std=gnu11 -MD -MT CMakeFiles/prom.dir/src/prom_metric_sample.c.o -MF CMakeFiles/prom.dir/src/prom_metric_sample.c.o.d -o CMakeFiles/prom.dir/src/prom_metric_sample.c.o -c /data/data/com.termux/files/home/downloads/libprom/prom/src/prom_metric_sample.c
/data/data/com.termux/files/home/downloads/libprom/prom/src/prom_metric_sample.c:69:52: error: incompatible pointer types passing '_Atomic(double) *' to parameter of type 'double *' [-Werror,-Wincompatible-pointer-types]
if (atomic_compare_exchange_weak(&self->r_value, &old, new))
^~~~
/data/data/com.termux/files/usr/include/bits/stdatomic.h:240:48: note: expanded from macro 'atomic_compare_exchange_weak'
atomic_compare_exchange_weak_explicit(object, expected,
^~~~~~~~
/data/data/com.termux/files/usr/include/bits/stdatomic.h:213:45: note: expanded from macro 'atomic_compare_exchange_weak_explicit'
__c11_atomic_compare_exchange_weak(object, expected, desired,
^~~~~~~~
/data/data/com.termux/files/home/downloads/libprom/prom/src/prom_metric_sample.c:85:52: error: incompatible pointer types passing '_Atomic(double) *' to parameter of type 'double *' [-Werror,-Wincompatible-pointer-types]
if (atomic_compare_exchange_weak(&self->r_value, &old, new))
^~~~
/data/data/com.termux/files/usr/include/bits/stdatomic.h:240:48: note: expanded from macro 'atomic_compare_exchange_weak'
atomic_compare_exchange_weak_explicit(object, expected,
^~~~~~~~
/data/data/com.termux/files/usr/include/bits/stdatomic.h:213:45: note: expanded from macro 'atomic_compare_exchange_weak_explicit'
__c11_atomic_compare_exchange_weak(object, expected, desired,
^~~~~~~~
2 errors generated.
make[3]: *** [CMakeFiles/prom.dir/build.make:230: CMakeFiles/prom.dir/src/prom_metric_sample.c.o] Error 1
make[3]: Leaving directory '/data/data/com.termux/files/home/downloads/libprom/prom/build'
make[2]: *** [CMakeFiles/Makefile2:83: CMakeFiles/prom.dir/all] Error 2
make[2]: Leaving directory '/data/data/com.termux/files/home/downloads/libprom/prom/build'
make[1]: *** [Makefile:156: all] Error 2
make[1]: Leaving directory '/data/data/com.termux/files/home/downloads/libprom/prom/build'
make: *** [Makefile:35: prom] Error 2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.