Skip to content

Commit

Permalink
allow using simple span processor in evals
Browse files Browse the repository at this point in the history
  • Loading branch information
dinmukhamedm committed Dec 27, 2024
1 parent a1c0815 commit 472682d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
7 changes: 7 additions & 0 deletions src/evaluations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -210,6 +214,7 @@ class Evaluation<D, T, O> {
private groupId?: string;
private name?: string;
private batchSize: number = DEFAULT_BATCH_SIZE;
private disableTraceBatch: boolean = false;

constructor({
data, executor, evaluators, humanEvaluators, groupId, name, config
Expand Down Expand Up @@ -238,13 +243,15 @@ class Evaluation<D, T, O> {
this.name = name;
if (config) {
this.batchSize = config.batchSize ?? DEFAULT_BATCH_SIZE;
this.disableTraceBatch = config.disableTraceBatch ?? false;
}
Laminar.initialize({
projectApiKey: config?.projectApiKey,
baseUrl: config?.baseUrl,
httpPort: config?.httpPort,
grpcPort: config?.grpcPort,
instrumentModules: config?.instrumentModules,
disableBatch: this.disableTraceBatch,
});
}

Expand Down
5 changes: 4 additions & 1 deletion src/laminar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ interface LaminarInitializeProps {
instrumentModules?: InitializeOptions["instrumentModules"];
useExternalTracerProvider?: boolean;
preserveNextJsSpans?: boolean;
disableBatch?: boolean;
}

export class Laminar {
Expand All @@ -57,6 +58,7 @@ export class Laminar {
private static projectApiKey: string;
private static env: Record<string, string> = {};
private static isInitialized: boolean = false;
private static disableBatch: boolean = false;

/**
* Initialize Laminar context across the application.
Expand Down Expand Up @@ -114,6 +116,7 @@ export class Laminar {
instrumentModules,
useExternalTracerProvider,
preserveNextJsSpans,
disableBatch,
}: LaminarInitializeProps) {

let key = projectApiKey ?? process.env.LMNR_PROJECT_API_KEY;
Expand Down Expand Up @@ -148,7 +151,7 @@ export class Laminar {
exporter,
silenceInitializationMessage: true,
instrumentModules,
disableBatch: false,
disableBatch,
useExternalTracerProvider,
preserveNextJsSpans,
});
Expand Down

0 comments on commit 472682d

Please sign in to comment.