Repository navigation
Conversation
…n-fleet#150) Hand-rolled Prometheus histogram and request counter labeled by status and tenant (embed id), structured JSON access lines with a request id, and traceparent left on the upstream proxy hop. Keeps the zero-npm / no-secrets shape of embed-filter; PostHog stays out of this process. Test: embed-filter/test.js obs group fails before (no /metrics, no helpers) and passes after. Suite: 30 assertion groups.
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Unbounded client-controlled metric labels threaten proxy availability, and request accounting and correlation remain incomplete.
3 open issues
What changed in this PR
Adds zero-dependency observability to the AnythingLLM embed proxy in both the deployment template and beta site, preserving its no-secrets design.
Changes:
- Adds Prometheus request counters and duration histograms, excluding health and metrics requests.
- Adds structured access logs and request IDs while retaining trace-header passthrough.
- Adds observability assertions and documents the feature in the template changelog.
| File | Description |
|---|---|
anythingllm-docker/template/embed-filter/test.js |
Adds metrics, endpoint, and request-ID assertions. |
anythingllm-docker/template/embed-filter/server.js |
Implements metrics and structured request logging. |
anythingllm-docker/template/CHANGELOG.md.jinja |
Documents observability features and scope. |
anythingllm-docker/sites/beta-weown-chat/embed-filter/test.js |
Mirrors observability assertions for the beta site. |
anythingllm-docker/sites/beta-weown-chat/embed-filter/server.js |
Applies observability changes to the beta deployment. |
Review effort: Balanced
Comment on lines
+83
to
+85
| if (!row) { | ||
| row = { count: 0, sum: 0, buckets: DURATION_BUCKETS.map(() => 0) }; | ||
| metrics.duration.set(key, row); |
| try { res.setHeader('x-request-id', requestId); } catch (_) { /* headers may already be on the way */ } | ||
| // Meter the hot path only (not health/metrics scrapes). | ||
| const meter = pathname !== '/healthz' && pathname !== '/metrics'; | ||
| res.on('finish', () => { |
Comment on lines
+348
to
349
| attachObs(req, res, target.pathname); | ||
| const headers = { ...req.headers }; |
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
Implements the embed-filter slice of weown-fleet#150 without breaking the zero-npm / no-secrets shape of this process.
GET /metrics— hand-rolled Prom histogramembed_filter_request_duration_secondsand counterembed_filter_requests_total, labelsstatus+tenant(embed id from/api/embed/<id>/…)request_id, method, path, status, duration_ms, tenant, optional traceparent)traceparentleft on the upstream hop (passthrough);x-request-idechoed (generated if absent)/healthzand/metricsare local and not metered as chat trafficTest
node anythingllm-docker/template/embed-filter/test.js— obs group + full suite (30 assertion groups) pass after; helpers//metricsabsent before.Notes
Agent merges OFF. Prefer forge CI. Seat: ai-grok.