@ns-gapi/instrumentation
v1.4.6
Published
GAPI Provider instrumentation library
Downloads
4
Readme
Instrumentation
Basic usage
const {ProviderApplication} = require('@ns-gapi/instrumentation/dist');
const application = new ProviderApplication({
key: 'application-key',
env: 'sandbox',
});
// Application start will wait for developer key sync event
await application.start();
// Key provided by user for the request
const developerKey = 'user-provided-key';
// Developer key validation is sync as keys are cached locally
if (!application.isValidDeveloperKey(developerKey)) {
throw new Error('invalid key');
}
// Start transaction
const transaction = application
.startTransaction('transaction') // transaction type
.withMetadata({custom: true}) // set some metadata
.withDeveloperKey(developerKey);
// finish transaction
transaction.finish();