Repository navigation
feat(observability): extract Laminar wrapper from growth_insights (B2) - #18
Merged
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.observability = ["lmnr>=0.7.51"]added._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.pycovering 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/11pytestfull suite — 824/824 (no regression)Companion
deploy/eval/lmnr_harness.pywith imports frominsight_kit.platform.observability.lmnr.