Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

statful-client-javascript

Package Overview
Dependencies
Maintainers
5
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

statful-client-javascript

Statful client for Javascript applications

  • 2.2.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
14
Maintainers
5
Weekly downloads
 
Created
Source

statful-client-javascript

Statful client for Javascript. This client is intended to gather metrics and send them to Statful.

Build Status devDependency Status install size

Table of Contents

Supported Versions

It supports every browser that has full support for the ECMAScript 5 specification.

Installation

npm install --save statful-client-javascript

or

bower install --save statful-client-javascript

Quick Start

After installing Statful Client you are ready to use it. The quickest way is to do the following:

    <script type="text/javascript" src="node_modules/statful-client-javascript/dist/statful.umd.min.js"></script>

    <script>    
        // Init statful       
        statful.initialize({
            dryrun: false,
            debug: false,
            app: 'exampleApp',          
            flushInterval: 5000
        });

        // Send a metric
        statful.counter('page_load');
    </script>

Reference

Reference if you want to take full advantage from Statful.

Global configuration

The custom options that can be set on config param are detailed below.

OptionDescriptionTypeDefaultRequired
dryRunDefines if metrics should be output to the logger instead of being send.booleanfalseNO
debugDefines logs should be sent to console.booleanfalseNO
appDefines the application global name. If specified sets a global tag app=setValue.stringundefinedNO
namespaceDefines the global namespace.stringwebNO
sampleRateDefines the rate sampling. Should be a number between [1, 100].number100NO
flushIntervalDefines the periodicity of buffer flushes in milliseconds.number10000NO
timeoutDefines the timeout.number2000NO
tagsDefines the global tags.object{}NO
aggregationsDefines the global aggregations.object[]NO
aggregationFrequencyDefines the global aggregation frequency.number10NO

Methods

- statful.counter('myCounter', 1, {agg: ['sum']});
- statful.gauge('myGauge', 10, { tags: { host: 'localhost' } });
- statful.timer('myCounter', 200, {namespace: 'sandbox'});

These methods receive a metric name and a metric value as arguments and send a counter/gauge/timer metric.

If the options parameter is omitted, the default values are used.

These methods will add metrics to a queue that will be flushed using the interval defined on flushInterval.

- statful.sendMetric('counter', 'myCounter', 1, {agg: ['sum']});

These methods receive a metric type, metric name and a metric value as arguments and send a counter/gauge/timer metric.

If the options parameter is omitted, the default values are used.

These methods will send metrics to the server without being added to the queue.

Read the methods options reference bellow to get more information about the default values.

OptionDescriptionTypeDefault for CounterDefault for GaugeDefault for Timer
aggDefines the aggregations to be executed. These aggregations are merged with the ones configured globally, including method defaults.

Valid Aggregations: avg, count, sum, first, last, p90, p95, p99, min, max
array['sum', 'count'][last]['avg', 'p90', 'count']
aggFreqDefines the aggregation frequency in seconds. It overrides the global aggregation frequency configuration.

Valid Aggregation Frequencies: 10, 30, 60, 120, 180, 300
number101010
sampleRateDefines the rate sampling. It overrides the global namespace configuration.number100100100
namespaceDefines the namespace of the metric. It overrides the global namespace configuration.stringwebwebweb
tagsDefines the tags of the metric. These tags are merged with the ones configured globally, including method defaults.object{}{}{ unit: 'ms' }

Plugins

User Timing

Support for the user-timing specification is available. You can check the current compatibility table here.

Performance Mark
statful.registerMark('mark_start');
statful.registerMark('mark_end');
Performance Measure sent to Statful as a Timer
// Measure and Timer between two marks

statful.registerMark('mark_start');
statful.registerMark('mark_end');

var options = {
    startMark: 'mark_start',
    endMark: 'mark_end'
    tags: {mark: my_tag}
}

statful.registerMeasure('measure_name', 'metric_name' options);
// Measure and Timer from the navigationStart event until the current time

var options = {
    tags: {mark: my_tag}
}

statful.registerMeasure('measure_name', 'metric_name' options);

You can omit both start and end mark names:

  • if startMark is missing it will be measured from the navigationStart event
  • if endMark is missing it will be measured until the current high precision time

Development

Installation

$ npm install

Tests

$ npm test

Contribute

Follow the standard Fork and Pull Request workflow and:

  • Add tests for new feats
  • Make sure the test suite passes
  • Update or add documentation accordingly

Authors

Mindera - Software Craft

License

Statful Javascript Client is available under the MIT license. See the LICENSE file for more information.

FAQs

Package last updated on 21 Nov 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc