Repository navigation
feat(agent,runtime): gzip OTLP posts + auto-wire agent generations + eslint fixes - #162
Conversation
…emetry - @lunora/runtime: otlpSink gzips OTLP bodies past 1 KB (Content-Encoding: gzip, via CompressionStream) — tiny single-span posts stay plain. - @lunora/agent: the compiled workflow auto-appends an otlpTelemetry integration when LUNORA_OTLP_ENDPOINT is injected (the platform), so a deployed agent emits gen_ai.* generation spans with no app wiring. Byte-identical no-op locally or when telemetry is explicitly disabled; privacy-safe (structural metadata only unless recordInputs/Outputs). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0197KjhmBDB3PXAc6TXiPqZ9
eslint (which only runs on alpha, TS-6 pinned) flagged real issues the tsc/vitest gate missed: the agent otlpTelemetry detached observer tripped promise/always-return + no-confusing-void-expression (rewritten as a named async `observe().catch(...)`), plus exports-last / jsdoc-link / jsdoc-indentation nits; a nested ternary + needless cast in the workflow auto-wire; a chained assignment in define-rag; and jsdoc description/link nits in runtime + rag types. No behavior change. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0197KjhmBDB3PXAc6TXiPqZ9
✅ Deploy Preview for lunorash ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Important Review skippedReview was skipped due to path filters ⛔ Files ignored due to path filters (1)
CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
WalkthroughThe workflow now auto-configures OTLP telemetry from environment variables. Span settlement and attribute encoding are centralized, OTLP payloads can be gzipped above a threshold, and minor RAG implementation and documentation cleanup is included. ChangesOTLP telemetry integration
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant WorkflowHandler
participant RuntimeAgent
participant AgentLoop
participant OTLPIntegration
participant OTLPHTTP
WorkflowHandler->>RuntimeAgent: Configure from OTLP environment variables
WorkflowHandler->>AgentLoop: Run with RuntimeAgent
AgentLoop->>OTLPIntegration: Observe generation or tool settlement
OTLPIntegration->>OTLPHTTP: Send serialized payload, optionally gzipped
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Thank you for following the naming conventions! 🙏 |
|
Thank you for confirming the Contributor License Agreement! 🙏 |
Merging this PR will improve performance by 11.2%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ⚡ | with shardKey: explicit shard selection |
1.6 ms | 1.4 ms | +11.2% |
Tip
Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.
Comparing feat/framework-otlp-followups (c595fc7) with alpha (4c7f0cb)2
Footnotes
-
134 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
-
No successful run was found on
alpha(837b8ec) during the generation of this report, so 4c7f0cb was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩
… span) The detached observer wrapped `emit()` inside the try, so a throw from `emit` on the SUCCESS path (e.g. JSON.stringify on a circular recorded input/output) was mis-caught and recorded a successful call as an error span. Extract a shared `observeSettled(promise, onSettle)` helper that guards only the `await` — a success-path throw now propagates to the detached `.catch` (no span) instead of a wrong error span — and dedupes the two near-identical observer blocks. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0197KjhmBDB3PXAc6TXiPqZ9
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/runtime/src/observability-sinks.ts`:
- Around line 264-270: Update the gzip threshold check in the observability
export flow to measure the serialized JSON payload in UTF-8 bytes rather than
UTF-16 code units. Replace the json.length comparison with the byteLength of new
TextEncoder().encode(json), while preserving the existing gzip and fetch
branches.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 98dd711b-c57e-4c15-9e82-dc48cce937e8
📒 Files selected for processing (5)
packages/agent/src/telemetry/otlp.tspackages/agent/src/workflow.tspackages/ai/src/rag/define-rag.tspackages/ai/src/rag/types.tspackages/runtime/src/observability-sinks.ts
| const json = JSON.stringify(body); | ||
| // `.catch` swallows any rejection so a failed export can never reject | ||
| // into the dispatch path. | ||
| const sent = fetch(url, { body: JSON.stringify(body), headers, method: "POST" }).catch(() => { | ||
| // Network error / non-OK response — intentionally ignored. | ||
| const sent = ( | ||
| json.length < OTLP_GZIP_THRESHOLD | ||
| ? fetch(url, { body: json, headers, method: "POST" }) | ||
| : gzipEncode(json).then((gz) => fetch(url, { body: gz, headers: { ...headers, "content-encoding": "gzip" }, method: "POST" })) |
There was a problem hiding this comment.
🚀 Performance & Scalability | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Map the file structure and inspect the relevant area
ast-grep outline packages/runtime/src/observability-sinks.ts --view expanded || true
printf '\n--- lines around the target ---\n'
sed -n '220,320p' packages/runtime/src/observability-sinks.ts
printf '\n--- search for threshold/helper usage ---\n'
rg -n "OTLP_GZIP_THRESHOLD|TextEncoder|gzipEncode|content-encoding|json.length" packages/runtime/src/observability-sinks.ts packages/runtime/src -SRepository: anolilab/lunora
Length of output: 9206
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Check how byte length is computed elsewhere in the repo and whether TextEncoder is assumed available
rg -n "new TextEncoder\(|TextEncoder\.|byteLength" packages/runtime/src packages -SRepository: anolilab/lunora
Length of output: 9984
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Verify the environment exposes the relevant web APIs in TypeScript typings used by the repo, without executing repo code.
node - <<'JS'
const names = ['TextEncoder', 'CompressionStream', 'Blob', 'Response', 'fetch'];
for (const name of names) {
console.log(name, typeof globalThis[name]);
}
JSRepository: anolilab/lunora
Length of output: 248
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Inspect the runtime TypeScript sources for any explicit byte-length helper or threshold comments.
sed -n '1,220p' packages/runtime/src/observability-sinks.tsRepository: anolilab/lunora
Length of output: 10016
Measure the gzip cutoff in UTF-8 bytes. json.length counts UTF-16 code units, so non-ASCII payloads can stay under the 1 KiB threshold while exceeding it on the wire; use new TextEncoder().encode(json).byteLength here.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/runtime/src/observability-sinks.ts` around lines 264 - 270, Update
the gzip threshold check in the observability export flow to measure the
serialized JSON payload in UTF-8 bytes rather than UTF-16 code units. Replace
the json.length comparison with the byteLength of new
TextEncoder().encode(json), while preserving the existing gzip and fetch
branches.
Source: Path instructions
Move `afterEach` inside the describe (require-top-level-describe) and hoist the fixed 32-hex trace id to a single `no-secrets`-disabled const (a fake test id, not a credential) reused across assertions. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0197KjhmBDB3PXAc6TXiPqZ9
…, otp reset From better-auth-ui #173, #162, #211 and #337, checked against our code. The password minimum was hard-coded to 8, which is a guess at the server's rule: too low and the user is told 'too short' only after a round-trip, too high and we refuse passwords the server would take. It is config now, meant to be matched to emailAndPassword, and every password field routes through it. <PasswordStrength> shows the rules as a checklist rather than a bar, because a bar says a password is unacceptable without saying what to change. The providers dropped the field. AuthUIConfig.password existed and resolveContext honoured it, but all five rebuilt their config object field-by-field and omitted it — so a configured policy was unreachable and the checklist always showed the default. Regression test added. Username availability now uses /is-username-available, which better-auth exposed all along: a taken name surfaced only as a failed sign-up. It is debounced and drops out-of-order answers, and reports 'unknown' rather than 'taken' on failure so it can never block a sign-up the server would allow. Forgot-password can use the emailOTP endpoints. An app that recovers by code got 'Reset password isn't enabled' from /request-password-reset, which names neither cause nor fix. Sign-up seeds email/name from the link, and the invitation bounce now carries the invited address — retyping it is how an invitee ends up creating a different account the invitation doesn't match. Passwords are never prefilled: an allow-list, because a password in a query string lands in history, referrers and logs. Also organization.showSlug, and the last-used badge now covers email and magic-link — better-auth records those too, so badging only social buttons made the feature invisible for the commonest route. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Follow-up to the merged #160 (OTLP generation spans), completing items 8, 9, and the eslint pass from the "do 1 to 10" gap-closure:
otlpSinkgzips bodies past 1 KB (Content-Encoding: gzip, viaCompressionStream); tiny single-span posts stay plain.otlpTelemetrywhenLUNORA_OTLP_ENDPOINTis injected (the platform), so a deployed agent emitsgen_ai.*spans with no app wiring. No-op locally / when telemetry is explicitly disabled; privacy-safe (structural metadata only).promise/always-return, exports-last, jsdoc nits, a nested ternary, a chained assignment). Fixed here; no behavior change.Test plan
@lunora/agent+@lunora/runtimetsc clean, agent telemetry suite green,@lunora/ai/@lunora/runtimeunchanged behavior. eslint clean on the changed files.🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes
Documentation