Skip to content

feat: add optional OpenTelemetry tracing support#18

Merged
yltw27 merged 6 commits intomainfrom
feature/opentelemetry-tracing
Mar 5, 2026
Merged

feat: add optional OpenTelemetry tracing support#18
yltw27 merged 6 commits intomainfrom
feature/opentelemetry-tracing

Conversation

@yltw27
Copy link
Copy Markdown
Collaborator

@yltw27 yltw27 commented Mar 3, 2026

Summary

  • Add optional @opentelemetry/api peer dependency for distributed tracing with zero overhead when disabled
  • Instrument batch evaluation, single evaluations, and async metrics (BERTScore, Perplexity) with span hierarchy
  • Export public withSpan API for custom evaluator instrumentation
  • Add comprehensive telemetry documentation and 27 new telemetry tests

Test plan

  • All 165 tests passing (15 suites)
  • CodeScene code health: both modified files at 10/10 (no regressions)
  • Build succeeds with OTel externalized (not bundled)
  • Manual verification with ConsoleSpanExporter

🤖 Generated with Claude Code

…cessing, and async metrics

- Install @opentelemetry/api as optional peer dependency for zero overhead when disabled
- Implement telemetry module with dynamic import and no-op fallback pattern
- Add span instrumentation across batch evaluation, single evaluations, and async metrics
- Support custom evaluator instrumentation via public withSpan API
- Comprehensive span hierarchy: batch.evaluate -> process_row -> run_evaluators -> evaluator.evaluate
- Retry events recorded on process_row spans with attempt number and delay tracking
- Token usage tracking across evaluations (input/output/total tokens)
- All OpenTelemetry integration is optional - zero performance impact when package not installed
- Add Telemetry documentation with setup instructions and production examples

Refactored for code health:
- Extracted span lifecycle management from evaluate() method into helper methods
- Simplified retry logic in batch processing with context object pattern
- All files maintain 10/10 code health scores with no regressions

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@yltw27 yltw27 force-pushed the feature/opentelemetry-tracing branch from 7694302 to 2a5a4ac Compare March 3, 2026 08:09
yltw27 and others added 3 commits March 3, 2026 16:11
Extract shared helpers (runBatch, getSpan) to reduce duplication and
eliminate optional chaining in assertions, bringing score to 10/10.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Fix biome formatting in telemetry spec files
- Remove unused private startTime field in ProgressTracker

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@yltw27 yltw27 marked this pull request as ready for review March 3, 2026 08:39
@yltw27 yltw27 requested a review from a team as a code owner March 3, 2026 08:39
@yltw27 yltw27 requested review from djslimbo, horlaarsco and matt-koevort and removed request for a team March 3, 2026 08:39
yltw27 and others added 2 commits March 3, 2026 17:29
Add enableTelemetry(enabled) and isTelemetryEnabled() to control
eval-kit tracing globally. When disabled, all spans are suppressed
including Vercel AI SDK's experimental_telemetry. This lets users
run OTel for other services without eval-kit cluttering their traces.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown

@djslimbo djslimbo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@yltw27 yltw27 merged commit 2f2c9ec into main Mar 5, 2026
2 checks passed
@yltw27 yltw27 deleted the feature/opentelemetry-tracing branch March 5, 2026 03:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants