Skip to content

traceroot-ai/traceroot-sdk-ts

Repository files navigation

TraceRoot TypeScript SDK

Testing Status Documentation npm version TraceRoot.AI Website

Please see TypeScript SDK Docs for details

Installation

npm install traceroot-sdk-ts@latest

Examples

import * as traceroot from 'traceroot-sdk-ts';

const logger = traceroot.get_logger();

async function main() {
  const greet = traceroot.traceFunction(
    async function greet(name: string): Promise<string> {
      logger.info(`Greeting inside traced function: ${name}`);
      // Simulate some async work
      await new Promise(resolve => setTimeout(resolve, 100));
      return `Hello, ${name}!`;
    },
    { spanName: 'greet' }
  );

  const result = await greet('world');
  logger.info(`Greeting result: ${result}`);
}

main().then(async () => {
  await traceroot.forceFlushTracer();
  await traceroot.shutdownTracing();
  await traceroot.forceFlushLogger();
  await traceroot.shutdownLogger();
  process.exit(0);
});

Contact Us

Please reach out to founders@traceroot.ai if you have any questions.