1.0.1 • Published 1 year ago

@cn-npm/opentelemetry v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

Charity Navigator opentelemetry classes

This NPM module exposes the base OpenTelemetry classes used to instrument application code iwth OTel tracing. It is separate from any OTel provider library (e.g. Honeycomb in our case). If you want to initialize the Honeycomb provider, see @cn-npm/logtrace

Installation

After cloning the repo, run:

npm install

Building and publishing the library

To compile the project locally run:

npm run tsc

This will compile the typescript modules and place them in the \lib directory.

To run the tests, run:

npm run test

This should run test scripts for logging and honeycomb tracing.

To publish the library to NPM, do the following:

Bump the version in package.json. If you don't do this, the publish will fail because that version has been published prior.

npm publish

Internally this will call the prePublish command in package.json which will build both Typescript and CommonJS (to support plain Javascript) versions of the library, then publish the package to NPM.

Usage

To use the module in your application, do the following:

npm install @cn-npm/opentelemetry --save

Then in your code, import the logging module:

Or import the tracing module:

Typescript:

import { Trace } from '@cn-npm/opentelemetry';

async function foo() {
    return Trace.startSpan('MyModule', 'foo', async (span) => {
      const result = await someAsyncFunction();
      span.end({ result });   // end the span and add the result to the span
      return result;
    });
 }
1.0.1

1 year ago