Usage

Installation

Gauge can be installed as a regular Python package. Currently, it is not published on PyPI so you have to clone the repository to install it.

Prerequisites

  • CMake above 3.14.
  • Some sort of C++ 14 compatible compiler.
  • CPython 3.5+.
  • CPython’s headers.

On recent Debian/Ubuntu version you would be able to install everything necessary with similar commands:

sudo apt-get update
sudo apt-get install build-essential cmake python3.8 python3.8-dev

These exact commands work on Ubuntu 18.04 for example.

Installation steps

  1. Clone the project from the GitHub repo.
  2. Execute python setup.py install.

Warning

The project doesn’t store C++ dependency libraries in the repository like some others do, instead - it downloads them on demand. Downloading can take some time so don’t be surprised to find yourself waiting a little bit during installation.

That’s it.

Quickstart

Gauge built on three types of entities - collectors, aggregators, exporters. Collectors - collect raw data about execution, aggregators - aggregate them, exporters - push them to somewhere (monitor software).

To instantiate the profiler implementations of these entities has to be combined.

Minimal example

import gauge
from elasticapm import Client
from elasticapm.contrib.opentracing import Tracer


client = Client({
    'SERVICE_NAME': 'my-service',
})
tracer = Tracer(client_instance=client)

collector = gauge.SamplingCollector()
aggregator = gauge.SpanAggregator()
collector.subscribe(aggregator)
exporter = gauge.OpenTracingExporter(tracer=tracer)
aggregator.subscribe(exporter)
collector.start()

# ... work work work

collector.stop()
aggregator.finish_open_spans()
client.close()