From 472682d5507fc86369f70aa293f9443ea2086503 Mon Sep 17 00:00:00 2001 From: Din Date: Fri, 27 Dec 2024 19:01:33 +0500 Subject: [PATCH] allow using simple span processor in evals --- package.json | 2 +- src/evaluations.ts | 7 +++++++ src/laminar.ts | 5 ++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 12f1f45..94b3e1d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lmnr-ai/lmnr", - "version": "0.4.29", + "version": "0.4.30", "description": "TypeScript SDK for Laminar AI", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/src/evaluations.ts b/src/evaluations.ts index d55e152..2b82e90 100644 --- a/src/evaluations.ts +++ b/src/evaluations.ts @@ -76,6 +76,10 @@ interface EvaluatorConfig { * See {@link https://docs.lmnr.ai/tracing/automatic-instrumentation} */ instrumentModules?: InitializeOptions['instrumentModules']; + /** + * If true, then the spans will not be batched. + */ + disableTraceBatch?: boolean; } /** @@ -210,6 +214,7 @@ class Evaluation { private groupId?: string; private name?: string; private batchSize: number = DEFAULT_BATCH_SIZE; + private disableTraceBatch: boolean = false; constructor({ data, executor, evaluators, humanEvaluators, groupId, name, config @@ -238,6 +243,7 @@ class Evaluation { this.name = name; if (config) { this.batchSize = config.batchSize ?? DEFAULT_BATCH_SIZE; + this.disableTraceBatch = config.disableTraceBatch ?? false; } Laminar.initialize({ projectApiKey: config?.projectApiKey, @@ -245,6 +251,7 @@ class Evaluation { httpPort: config?.httpPort, grpcPort: config?.grpcPort, instrumentModules: config?.instrumentModules, + disableBatch: this.disableTraceBatch, }); } diff --git a/src/laminar.ts b/src/laminar.ts index 13b1c0a..3a2ec57 100644 --- a/src/laminar.ts +++ b/src/laminar.ts @@ -49,6 +49,7 @@ interface LaminarInitializeProps { instrumentModules?: InitializeOptions["instrumentModules"]; useExternalTracerProvider?: boolean; preserveNextJsSpans?: boolean; + disableBatch?: boolean; } export class Laminar { @@ -57,6 +58,7 @@ export class Laminar { private static projectApiKey: string; private static env: Record = {}; private static isInitialized: boolean = false; + private static disableBatch: boolean = false; /** * Initialize Laminar context across the application. @@ -114,6 +116,7 @@ export class Laminar { instrumentModules, useExternalTracerProvider, preserveNextJsSpans, + disableBatch, }: LaminarInitializeProps) { let key = projectApiKey ?? process.env.LMNR_PROJECT_API_KEY; @@ -148,7 +151,7 @@ export class Laminar { exporter, silenceInitializationMessage: true, instrumentModules, - disableBatch: false, + disableBatch, useExternalTracerProvider, preserveNextJsSpans, });