3.2.0 • Published 2 years ago

elastic-apm-utils v3.2.0

Weekly downloads
18
License
MIT
Repository
github
Last release
2 years ago

elastic-apm-utils

Utilities for Elastic APM

Installation

$ npm install elastic-apm-utils

API

APM

apmUtils.apm.spanFilter({ filterShorterThan })

Filters spans.

apmClient.addSpanFilter(apmUtils.apm.spanFilter({
    // remove spans shorter than this value in ms
    filterShorterThan: 10,
}));

apmUtils.apm.addTransactionFilter({ keepRequest, keepResponse, keepSocket })

Filters request and response properties.

apmClient.transactionFilter(apmUtils.apm.transactionFilter({
    // completely remove non-sampled transactions
    // (otherwise those are still sent to APM, just with less details)
    filterNotSampled: true,
    
    // list of request headers to keep, optional
    keepRequest: [ 'referer', 'user-agent' ], 

    // list of response headers to keep, optional
    keepResponse: [], 

    // list of socket properties to keep, optional
    keepSocket: [], 
}));

Express integration

apmUtils.express.middleware(apmClient, { setAddress, setOrigin })

Returns an express middleware.

server.use(apmUtils.express.middleware(apmCient, {
    // set remote IP address as a tag to allow filtering in Kibana
    setAddress: true,
    
    // set request origin / referrer hostname as a tag to allow filtering in Kibana
    setOrigin: true,
}));

Koa integration

apmUtils.koa.middleware(apmClient, { prefix, setAddress, setOrigin, setRouteName })

Returns a koa middleware.

router.use(apmUtils.koa.middleware(apmCient, {
    // a prefix for all transaction names, only used if setRouteName = true
    prefix: '',
    
    // set remote IP address as a tag to allow filtering in Kibana
    setAddress: true,
    
    // set request origin / referrer hostname as a tag to allow filtering in Kibana
    setOrigin: true,
    
    // more accurate route names when using koa-router
    setRouteName: true,
}));

License

Copyright (c) 2018 Martin Kolárik. Released under the MIT license.

3.2.0

2 years ago

3.1.1

2 years ago

3.1.0

3 years ago

3.0.2

3 years ago

3.0.1

3 years ago

3.0.0

4 years ago

2.1.0

5 years ago

2.0.0

5 years ago

1.1.0

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago