https://github.com/pulyaevskiy/dart-statsd
StatsD client for Dart
https://github.com/pulyaevskiy/dart-statsd
Last synced: 3 months ago
JSON representation
StatsD client for Dart
- Host: GitHub
- URL: https://github.com/pulyaevskiy/dart-statsd
- Owner: pulyaevskiy
- License: bsd-2-clause
- Created: 2016-01-08T00:38:48.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2024-01-22T18:48:15.000Z (over 1 year ago)
- Last Synced: 2025-02-12T03:34:37.856Z (3 months ago)
- Language: Dart
- Homepage:
- Size: 14.6 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# StatsD client for Dart
[](https://travis-ci.org/pulyaevskiy/dart-statsd)
[](https://pub.dartlang.org/packages/statsd)
[](https://raw.githubusercontent.com/pulyaevskiy/dart-statsd/master/LICENSE)A [StatsD](https://github.com/etsy/statsd) client library implemented in Dart.
## Installation
Use git dependency in your `pubspec.yaml`:
```yaml
dependencies:
statsd: "^0.2.0"
```And then import it as usual:
```dart
import 'package:statsd/statsd.dart';
```## Usage
Basic example:
```dart
import 'dart:io';
import 'dart:async';
import 'package:statsd/statsd.dart';Future main() async {
var connection = await StatsdConnection.connect(
Uri.parse('udp://127.0.0.1:5678'));
var client = new StatsdClient(connection, prefix: 'myapp');
// Sending counters:
await client.count('metric1'); // increment `myapp.metric1` by 1
await client.count('metric1', -1); // decrement `myapp.metric1` by 1
await client.count('metric1', 5, 0.1); // increment `myapp.metric1` by 5 with 0.1 sample rate// Sending timings:
var stopwatch = new Stopwatch();
stopwatch.start();
// client will use value of stopwatch.elapsedMilliseconds
await client.time('response-time', stopwatch);// Sending gauges:
await client.gauge('metric2', 428); // sets gauge value to 428
await client.gaugeDelta('metric2', 3); // increments value by 3
await client.gaugeDelta('metric2', -10); // decrements value by 10// Sending sets:
await client.set('uniques', 345);// Sending multiple metrics at once:
var batch = client.batch();
batch
..time('response-time', stopwatch)
..count('total-requests', 3)
..set('metric1', 56);
await batch.send();// Make sure to close the connection when done:
connection.close();
}
```Current limitations:
* Only UDP connections are supported at this moment.
## License
BSD-2