Overview
This guide will walk you through the steps to set up Langtrace with OpenTelemetry (OTEL) Collector using the HTTP/JSON protocol in a TypeScript project.Configurations
OTEL Collector
Refer to the OTEL configuration page for instructions on running and configuring the OpenTelemetry Collector with a custom configuration file. OTEL Configuration Ensure that you configure the Langtrace API token in the OTEL collector configuration file before proceeding.
TypeScript SDK
To send traces from your TypeScript project to Langtrace, use the following code snippet. Update the API key and endpoint as necessary. Install the OpenTelemetry HTTP/JSON exporter package:Implementation
Initialize the Langtrace SDK with a custom remote exporter that uses the OTLPTraceExporter to send traces to Langtrace Cloud or your self-hosted Langtrace instance.Example pre-requisite steps for running the code.
Example pre-requisite steps for running the code.
Create a folder and setup a projectEdit the Install the required packages:Export the OpenAI key:
package.json
file and add "type": "module"
to enable running JS files directly:langtrace_otel.js
Ignore the following warning message from the Langtrace SDK: