Skip to content

Memcrab/metrics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Memcrab Metrics

Memcrab Metrics is a library that provides an additional layer over the InfluxDB client to asynchronously send metrics to InfluxDB. It integrates with OpenSwoole for coroutine-based asynchronous operations and uses the InfluxDB line protocol for metric formatting.

Features

  • Asynchronous metric sending with OpenSwoole coroutine support.
  • Easy integration with InfluxDB client (version 3.1.0).
  • Allows metrics to be sent in the InfluxDB line protocol format.

Installation

composer require memcrab/metrics

Usage

Initialize a client

You must call init() before sending any metrics. If you want to disable metric sending (e.g., in a LOCAL or test environment), pass false as the second argument.

$influxDBListenerUrl = 'http://127.0.0.1:8186/api/v2/write';
Metric::obj()->init($influxDBListenerUrl, ENVIRONMENT !== 'local');

Sending Metrics

Metric::obj()->write('cpu_usage', [
        'host' => 'server01'
    ],
    [
        'usage' => 45
    ],
    time()
);

License

The gem is available as open source under the terms of the MIT License.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages