Skip to main content

Getting started

pnpm add @syntrac/node-sdk

Sdk overview

@syntrac/node-sdk provides below functionalities:

  • Automatic tracing with Open Telemetry.
  • Helper functions for manual tracing.

Setup sdk

Setup @syntrac/node-sdk client once at the entry of your application:


import * as syntrac from '@syntrac/node-sdk';

syntrac.initialize({
appName: '<YOUR APP NAME>',
apiKey: process.env.SYNTRAC_API_KEY,
});

The api key is available on Environment > Settings > Api Key page on Syntrac Dashboard.

That's it, if you run your backend application with OpenAI or Langchain, traces should be logged on Syntrac dashboard on Environment > Logs.

Troubleshooting

No telemetry sent with OpenAI

This might happen when you are using mono-repo and there are two OpenAI libs are installed. To fix this, we need to manually add OpenAIto instrument modules as below:

import OpenAI from 'openai';
import * as syntrac from '@syntrac/node-sdk';

syntrac.initialize({
appName: 'app',
baseUrl: process.env.SYNTRAC_ENDPOINT,
instrumentModules: {
openAI: OpenAI,
},
});