@ns-gapi/instrumentation

GAPI Provider instrumentation library

Usage no npm install needed!

<script type="module">
  import nsGapiInstrumentation from 'https://cdn.skypack.dev/@ns-gapi/instrumentation';
</script>

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();