// Example: A well-structured trace implementation
import { Laminar, observe } from '@lmnr-ai/lmnr';
// Initialize with your project key
Laminar.initialize({
projectApiKey: process.env.LMNR_PROJECT_API_KEY,
});
// Create a parent span for the entire request
await observe({ name: 'processUserRequest' }, async (userId, requestId) => {
// Your LLM calls and other operations will be children
// of this 'processUserRequest' span
// and inherit the session id, user id, and metadata
Laminar.setTraceUserId(userId);
Laminar.setTraceSessionId(`session-${requestId}`);
Laminar.setTraceMetadata({
environment: process.env.NODE_ENV
});
// ... you LLM calls here ...
});