Skip to content

feat(observability): extract Laminar wrapper from growth_insights (B2) - #18

Merged
nyashkn merged 1 commit into
mainfrom
feat/observability-lmnr-wrap
Jun 9, 2026
Merged

nyashkn merged 1 commit into
mainfrom
feat/observability-lmnr-wrap

Conversation

@nyashkn

@nyashkn nyashkn commented Jun 9, 2026

Copy link
Copy Markdown
Owner

Summary

B2 of the eval-harness extraction. Pure Laminar/OTel infra moves into insight-kit so any analyst/critic consumer can wire telemetry without copying boilerplate.

New module

insight_kit.platform.observability.lmnr — init_from_env, RunIdentity, emit_session_spans, score_check_span, read_capped.

  • Optional dep group observability = ["lmnr>=0.7.51"] added.
  • Lazy _require_lmnr() guard keeps insight-kit importable without the extra; ImportError fires only when an lmnr-touching function is called.

Version

0.1.4 → 0.1.5

Tests

+11 in tests/platform/observability/test_lmnr.py covering pure helpers (init_from_env without API key, RunIdentity capture + metadata shape, read_capped truncation). Live span emission covered end-to-end by growth_insights smoke run.

Test plan

  • pytest tests/platform/observability/ — 11/11
  • pytest full suite — 824/824 (no regression)

Companion

  • growth_insights PR to follow — replace inlined helpers in deploy/eval/lmnr_harness.py with imports from insight_kit.platform.observability.lmnr.

…ghts

B2 of the eval-harness extraction. Pure infrastructure helpers for
Laminar-instrumented analyst/critic runs move into insight-kit so any
consumer can wire telemetry without copying boilerplate.

## New module

`insight_kit.platform.observability.lmnr`:

- `init_from_env()` — read LMNR_* env vars + Laminar.initialize(). Returns
  True/False so callers can skip telemetry cleanly when LMNR_PROJECT_API_KEY
  is unset. Same self-host vs cloud switch (LMNR_BASE_URL presence) as the
  growth_insights original.
- `RunIdentity` dataclass + `RunIdentity.from_env(cwd, image, harness_version)`
  — capture run_id / git_sha / git_branch / image_digest / started_at from
  env + git. `.as_metadata()` flattens to a Laminar.set_trace_metadata() dict.
- `emit_session_spans(parsed_turns, *, namespace, gen_ai_system)` — back-emit
  one LLM span per assistant turn + child TOOL spans via an independent
  OTLP HTTP exporter parented to the live OTel span. Works against any
  ParsedTurn-shaped object (compatible with
  insight_kit.integrations.omp.session_parser.ParsedTurn out of the box).
- `score_check_span(check_name, passed, *, namespace, file_path)` — per-check
  child span emitter (synchronous open/close).
- `read_capped(path, cap)` — capped text read for span output attachment.

## Pyproject

- `observability` optional dep group added: `lmnr>=0.7.51`.
- Lazy `_require_lmnr()` guard keeps insight-kit importable without the
  extra; ImportError fires only when an lmnr-touching function is called.
- Version 0.1.4 → 0.1.5.

## Tests

11 new tests in `tests/platform/observability/test_lmnr.py` cover:
- init_from_env returns False without API key (no Laminar import needed)
- RunIdentity.from_env captures RUN_ID + env fallbacks + real git
- RunIdentity.as_metadata shape (required + optional fields)
- read_capped byte-cap, truncation marker, default cap

Live OTel/Laminar span emission (emit_session_spans, score_check_span) is
deferred to integration tests against a self-host Laminar instance — covered
end-to-end by the growth_insights smoke run.

## Next (B2 cont. on growth_insights side)

Shrink deploy/eval/lmnr_harness.py to import insight-kit helpers instead of
inlining them. Phases (build_views / omp / score) stay business-local.
@nyashkn
nyashkn merged commit 8a1f537 into main Jun 9, 2026
@nyashkn
nyashkn deleted the feat/observability-lmnr-wrap branch June 9, 2026 00: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.

1 participant