@@ -54,7 +54,7 @@ export abstract class Tracer {
5454 this . apiClient = new JudgmentApiClient (
5555 this . configuration . apiUrl ,
5656 this . configuration . apiKey ,
57- this . configuration . organizationId ,
57+ this . configuration . organizationId
5858 ) ;
5959
6060 this . _initialized = false ;
@@ -65,7 +65,7 @@ export abstract class Tracer {
6565 private async resolveProjectId ( ) : Promise < string > {
6666 try {
6767 Logger . info (
68- `Resolving project ID for project: ${ this . configuration . projectName } ` ,
68+ `Resolving project ID for project: ${ this . configuration . projectName } `
6969 ) ;
7070
7171 const response = await this . apiClient . projectsResolve ( {
@@ -76,7 +76,7 @@ export abstract class Tracer {
7676
7777 if ( ! resolvedProjectId ) {
7878 throw new Error (
79- `Project ID not found for project: ${ this . configuration . projectName } ` ,
79+ `Project ID not found for project: ${ this . configuration . projectName } `
8080 ) ;
8181 }
8282
@@ -86,15 +86,15 @@ export abstract class Tracer {
8686 return this . projectId ;
8787 } catch ( error ) {
8888 throw new Error (
89- `Failed to resolve project ID: ${ error instanceof Error ? error . message : String ( error ) } ` ,
89+ `Failed to resolve project ID: ${ error instanceof Error ? error . message : String ( error ) } `
9090 ) ;
9191 }
9292 }
9393
9494 public static getExporter (
9595 apiKey : string ,
9696 organizationId : string ,
97- projectId : string ,
97+ projectId : string
9898 ) : JudgmentSpanExporter {
9999 const endpoint = JUDGMENT_API_URL ?. endsWith ( "/" )
100100 ? `${ JUDGMENT_API_URL } otel/v1/traces`
@@ -120,7 +120,7 @@ export abstract class Tracer {
120120 this . configuration . projectName +
121121 ", please create it first at https://app.judgmentlabs.ai/org/" +
122122 ( this . configuration . organizationId || "unknown" ) +
123- "/projects. Skipping Judgment export." ,
123+ "/projects. Skipping Judgment export."
124124 ) ;
125125 return new NoOpSpanExporter ( ) ;
126126 }
@@ -135,7 +135,7 @@ export abstract class Tracer {
135135 if ( kind !== null ) {
136136 currentSpan . setAttribute (
137137 OpenTelemetryKeys . AttributeKeys . JUDGMENT_SPAN_KIND ,
138- kind ,
138+ kind
139139 ) ;
140140 }
141141 }
@@ -186,7 +186,7 @@ export abstract class Tracer {
186186 public asyncEvaluate (
187187 scorer : BaseScorer ,
188188 example : ExampleModel ,
189- model ?: string ,
189+ model ?: string
190190 ) : void {
191191 if ( ! this . _initialized ) {
192192 Logger . warn ( "Tracer not initialized, skipping asyncEvaluate" ) ;
@@ -212,15 +212,15 @@ export abstract class Tracer {
212212 const spanId = spanContext . spanId ;
213213
214214 Logger . info (
215- `asyncEvaluate: project=${ this . configuration . projectName } , traceId=${ traceId } , spanId=${ spanId } , scorer=${ scorer . name } ` ,
215+ `asyncEvaluate: project=${ this . configuration . projectName } , traceId=${ traceId } , spanId=${ spanId } , scorer=${ scorer . name } `
216216 ) ;
217217
218218 const evaluationRun = this . createEvaluationRun (
219219 scorer ,
220220 example ,
221221 model ,
222222 traceId ,
223- spanId ,
223+ spanId
224224 ) ;
225225 this . enqueueEvaluation ( evaluationRun ) ;
226226 }
@@ -250,24 +250,24 @@ export abstract class Tracer {
250250 const spanId = spanContext . spanId ;
251251
252252 Logger . info (
253- `asyncTraceEvaluate: project=${ this . configuration . projectName } , traceId=${ traceId } , spanId=${ spanId } , scorer=${ scorer . name } ` ,
253+ `asyncTraceEvaluate: project=${ this . configuration . projectName } , traceId=${ traceId } , spanId=${ spanId } , scorer=${ scorer . name } `
254254 ) ;
255255
256256 try {
257257 const traceEvaluationRun = this . createTraceEvaluationRun (
258258 scorer ,
259259 model ,
260260 traceId ,
261- spanId ,
261+ spanId
262262 ) ;
263263 const traceEvalJson = this . serializer ( traceEvaluationRun ) ;
264264 currentSpan . setAttribute (
265265 OpenTelemetryKeys . AttributeKeys . PENDING_TRACE_EVAL ,
266- traceEvalJson ,
266+ traceEvalJson
267267 ) ;
268268 } catch ( error ) {
269269 Logger . error (
270- `Failed to serialize trace evaluation: ${ error instanceof Error ? error . message : String ( error ) } ` ,
270+ `Failed to serialize trace evaluation: ${ error instanceof Error ? error . message : String ( error ) } `
271271 ) ;
272272 }
273273 }
@@ -276,7 +276,7 @@ export abstract class Tracer {
276276 scorer : BaseScorer ,
277277 model : string | undefined ,
278278 traceId : string ,
279- spanId : string ,
279+ spanId : string
280280 ) : Record < string , unknown > {
281281 const evalName = `async_trace_evaluate_${ spanId || Date . now ( ) } ` ;
282282 const modelName = model || JUDGMENT_DEFAULT_GPT_MODEL ;
@@ -312,7 +312,7 @@ export abstract class Tracer {
312312 example : ExampleModel ,
313313 model : string | undefined ,
314314 traceId : string ,
315- spanId : string ,
315+ spanId : string
316316 ) : ExampleEvaluationRun {
317317 const runId = `async_evaluate_${ spanId || Date . now ( ) } ` ;
318318 const modelName = model || JUDGMENT_DEFAULT_GPT_MODEL ;
@@ -334,7 +334,7 @@ export abstract class Tracer {
334334 }
335335
336336 private async enqueueEvaluation (
337- evaluationRun : ExampleEvaluationRun ,
337+ evaluationRun : ExampleEvaluationRun
338338 ) : Promise < void > {
339339 if ( ! this . apiClient ) {
340340 Logger . warn ( "API client not available, skipping evaluation enqueue" ) ;
@@ -346,14 +346,14 @@ export abstract class Tracer {
346346 Logger . info ( `Enqueuing evaluation run: ${ evaluationRun . eval_name } ` ) ;
347347 } catch ( error ) {
348348 Logger . error (
349- `Failed to enqueue evaluation run: ${ error instanceof Error ? error . message : String ( error ) } ` ,
349+ `Failed to enqueue evaluation run: ${ error instanceof Error ? error . message : String ( error ) } `
350350 ) ;
351351 }
352352 }
353353
354354 public observe < TArgs extends any [ ] , TResult > (
355355 func : ( ...args : TArgs ) => TResult ,
356- spanKind : SpanKind = "span" ,
356+ spanKind : SpanKind = "span"
357357 ) : ( ...args : TArgs ) => TResult {
358358 return ( ...args : TArgs ) => {
359359 const currentSpan = trace . getActiveSpan ( ) ;
@@ -371,13 +371,11 @@ export abstract class Tracer {
371371 { kind : OpenTelemetrySpanKind . INTERNAL } ,
372372 ( span ) => {
373373 try {
374- // Set span kind attribute
375374 span . setAttribute (
376375 OpenTelemetryKeys . AttributeKeys . JUDGMENT_SPAN_KIND ,
377- spanKind ,
376+ spanKind
378377 ) ;
379378
380- // Automatically set input attributes from function arguments
381379 const argNames = parseFunctionArgs ( func ) ;
382380 if ( argNames . length === args . length ) {
383381 const inputObj : Record < string , unknown > = { } ;
@@ -386,7 +384,7 @@ export abstract class Tracer {
386384 } ) ;
387385 span . setAttribute (
388386 OpenTelemetryKeys . AttributeKeys . JUDGMENT_INPUT ,
389- this . serializer ( inputObj ) ,
387+ this . serializer ( inputObj )
390388 ) ;
391389 }
392390
@@ -395,10 +393,9 @@ export abstract class Tracer {
395393 if ( result instanceof Promise ) {
396394 return result
397395 . then ( ( res ) => {
398- // Set output attribute before ending span
399396 span . setAttribute (
400397 OpenTelemetryKeys . AttributeKeys . JUDGMENT_OUTPUT ,
401- this . serializer ( res ) ,
398+ this . serializer ( res )
402399 ) ;
403400 span . end ( ) ;
404401 return res ;
@@ -409,10 +406,9 @@ export abstract class Tracer {
409406 throw err ;
410407 } ) as TResult ;
411408 } else {
412- // Set output attribute before ending span
413409 span . setAttribute (
414410 OpenTelemetryKeys . AttributeKeys . JUDGMENT_OUTPUT ,
415- this . serializer ( result ) ,
411+ this . serializer ( result )
416412 ) ;
417413 span . end ( ) ;
418414 return result ;
@@ -422,21 +418,11 @@ export abstract class Tracer {
422418 span . end ( ) ;
423419 throw err ;
424420 }
425- } ,
421+ }
426422 ) ;
427423 } ) ;
428424 } ;
429425 }
430426
431- // Helper method for observing methods with proper this binding
432- public observeMethod < TArgs extends any [ ] , TResult > (
433- method : ( ...args : TArgs ) => TResult ,
434- spanKind : SpanKind = "span" ,
435- ) : ( ...args : TArgs ) => TResult {
436- // Bind the method to its instance if it has one
437- const boundMethod = method . bind ? method . bind ( this ) : method ;
438- return this . observe ( boundMethod , spanKind ) ;
439- }
440-
441427 public async shutdown ( ) : Promise < void > { }
442428}
0 commit comments