Skip to content

fix: align adapter docs and tests with apiKey conventions#354

Merged
HugoRCD merged 3 commits into
mainfrom
fix/align-doc-and-repo
May 25, 2026
Merged

fix: align adapter docs and tests with apiKey conventions#354
HugoRCD merged 3 commits into
mainfrom
fix/align-doc-and-repo

Conversation

@HugoRCD

@HugoRCD HugoRCD commented May 24, 2026

Copy link
Copy Markdown
Owner

🔗 Linked issue

📚 Description

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

Summary by CodeRabbit

  • Documentation

    • Consolidated adapter credentials to apiKey (legacy names deprecated); added “Missing credentials” guidance, Memory adapter env vars/max-events, framework API cheat sheet, and built-in enrichers helper.
  • New Features

    • Added in-memory ring-buffer store with configurable max events and a memory-reset helper.
  • Tests

    • Added/expanded drain-factory tests for env/runtime config and credential cases; consolidated HTTP framework tests into a shared test matrix.

Review Change Stack

@HugoRCD HugoRCD self-assigned this May 24, 2026
@vercel

vercel Bot commented May 24, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
evlog-docs Ready Ready Preview, Comment, Open in v0 May 24, 2026 8:02pm
just-use-evlog Ready Ready Preview, Comment May 24, 2026 8:02pm

@github-actions github-actions Bot added the bug Something isn't working label May 24, 2026
@github-actions

github-actions Bot commented May 24, 2026

Copy link
Copy Markdown
Contributor

Thank you for following the naming conventions! 🙏

@coderabbitai

coderabbitai Bot commented May 24, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: f42ae8d7-d70a-4cfb-9ccd-99bb54beb80c

📥 Commits

Reviewing files that changed from the base of the PR and between c68faa9 and 423db10.

📒 Files selected for processing (1)
  • packages/evlog/src/adapters/memory.ts

📝 Walkthrough

Walkthrough

Migrates adapter credential examples to apiKey (keeping legacy aliases deprecated), adds memory adapter env/config resolution and ring-buffer limits, expands create*Drain tests, consolidates framework HTTP tests into a shared matrix, documents built-in enrichers and framework API patterns, and bumps a peer dependency.

Changes

Credential Field Transition (Axiom & Better Stack)

Layer / File(s) Summary
Overview & adapter docs
apps/docs/content/3.integrate/adapters/*, apps/docs/content/3.integrate/frameworks/*
Change Axiom/Better Stack doc examples and env vars from token/sourceToken to apiKey (e.g., AXIOM_API_KEY, BETTER_STACK_API_KEY), update direct-API examples, and add a “missing credentials” note.
Nuxt module, README, shared config docs
packages/evlog/src/nuxt/module.ts, packages/evlog/src/shared/config.ts, packages/evlog/README.md, .changeset/*
Make apiKey the primary Axiom option in Nuxt module types (keep token deprecated), update JSDoc/runtime-config examples and README env-var names.
README and peer dependency
packages/evlog/README.md, packages/evlog/package.json
Update adapters README (Axiom/Better Stack + HyperDX/FS/Memory snippets) and set peerDependencies.hono to >=4.11.0.

Memory adapter & shared config

Layer / File(s) Summary
Memory adapter implementation and config resolution
packages/evlog/src/adapters/memory.ts, packages/evlog/src/shared/config.ts
Add MEMORY_FIELDS, parseMaxEvents, resolveMemoryConfig, getOrCreateStore registry, and switch createMemoryDrain to async resolve via shared resolveAdapterConfig.
Memory docs & env vars
apps/docs/content/3.integrate/adapters/self-hosted/03.memory.md, .changeset/add-memory-drain-adapter.md, packages/evlog/README.md
Document EVLOG_MEMORY_STORE and EVLOG_MEMORY_MAX_EVENTS, Nuxt aliases, and config precedence (overrides → runtimeConfig → env).
Memory adapter tests
packages/evlog/test/adapters/memory.test.ts
Test added asserting createMemoryDrain picks up EVLOG_MEMORY_STORE / EVLOG_MEMORY_MAX_EVENTS and enforces ring-buffer capping.

create*Drain() test expansions

Layer / File(s) Summary
Adapter create*Drain tests
packages/evlog/test/adapters/* (axiom, better-stack, datadog, fs, hyperdx, otlp, sentry)
Add create*Drain() suites verifying drains call network/file ops when configured, log and no-op when credentials are missing, and accept legacy aliases where applicable.

HTTP Framework Test Consolidation

Layer / File(s) Summary
Standard HTTP matrix harness & README
packages/evlog/test/README.md, packages/evlog/test/adapters/config.test.ts
Document and use describeStandardHttpMatrix; update config test imports to shared resolveAdapterConfig.
Framework test migrations
packages/evlog/test/frameworks/* (express, fastify, hono, nestjs, react-router, sveltekit, elysia)
Each framework test now instantiates describeStandardHttpMatrix with mount/fire/cleanup helpers.
Removal of duplicated per-framework tests
packages/evlog/test/frameworks/*
Removed per-framework standalone tests for emitted method/path/status, x-request-id propagation, and route-based service override now covered by the matrix.

Tooling & Documentation Enhancements

Layer / File(s) Summary
Built-in enrichers composition and test
apps/docs/content/4.use-cases/5.enrichers.md, packages/evlog/test/toolkit/enrichers.test.ts
Document createDefaultEnrichers() and add test ensuring userAgent, geo, requestSize, and traceContext are set.
PostHog events drain deprecation
apps/docs/content/3.integrate/adapters/cloud/03.posthog.md
Deprecate createPostHogEventsDrain() in favor of createPostHogDrain({ mode: 'events' }) and update examples.
Framework integration cheat sheet & logger notes
apps/docs/content/3.integrate/frameworks/00.overview.md, apps/docs/content/6.reference/5.vs-other-loggers.md
Add API cheat sheet for framework bootstrapping/logger access and update runtime-level/minLevel notes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • HugoRCD/evlog#351: Prior work focused on the memory adapter; related to this PR’s memory adapter config/env changes and tests.

Suggested labels

documentation

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description contains only the template boilerplate with no actual implementation details, linked issues, or explanation of changes provided by the author. Complete the description section with details about the changes: explain what was aligned (adapter docs and tests), which adapters were affected (Axiom, Better Stack, etc.), and the specific apiKey convention changes made.
Docstring Coverage ⚠️ Warning Docstring coverage is 18.18% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix: align adapter docs and tests with apiKey conventions' follows conventional commits format and clearly describes the main change across the PR.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/align-doc-and-repo

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

github-actions Bot commented May 24, 2026

Copy link
Copy Markdown
Contributor

Benchmark report

Bundle size

Threshold: 5% · 🔴 larger · 🟡 warning · 🟢 smaller · ⚪ unchanged · 🆕 new

Status Entry Base (gzip) Current (gzip) Change Raw delta
🔴 framework/sveltekit 1.59 kB 1.96 kB +23.5% +1.33 kB
🔴 adapter/memory 2.04 kB 2.36 kB +16.0% +1.00 kB
🔴 logger 225 B 255 B +13.3% +51 B
🔴 framework/fastify 1.02 kB 1.08 kB +6.2% +61 B
framework/nestjs 1.26 kB 1.26 kB +0.1% 0 B
framework/next 5.20 kB 5.21 kB +0.1% +3 B
framework/nitro 7.23 kB 7.23 kB +0.0% 0 B
framework/ai 4.67 kB 4.67 kB 0.0% 0 B
framework/vite 2.40 kB 2.40 kB 0.0% 0 B
enrichers 1.99 kB 1.99 kB 0.0% 0 B
utils 1.78 kB 1.78 kB 0.0% 0 B
error 1.57 kB 1.57 kB 0.0% 0 B
pipeline 1.35 kB 1.35 kB 0.0% 0 B
framework/elysia 1.33 kB 1.33 kB 0.0% 0 B
http 1.24 kB 1.24 kB 0.0% 0 B
framework/hono 614 B 614 B 0.0% 0 B
browser 289 B 289 B 0.0% 0 B
client 128 B 128 B 0.0% 0 B
types 31 B 31 B 0.0% 0 B
workers 1.31 kB 1.30 kB -0.1% 0 B
core (index) 2.16 kB 2.15 kB -0.1% 0 B
framework/express 740 B 738 B -0.3% 0 B
adapter/otlp 2.15 kB 2.14 kB -0.4% -41 B
adapter/datadog 2.50 kB 2.48 kB -0.4% -41 B
adapter/fs 3.36 kB 3.35 kB -0.4% -41 B
adapter/sentry 2.42 kB 2.40 kB -0.4% -41 B
adapter/axiom 1.51 kB 1.50 kB -0.7% -41 B
adapter/posthog 1.48 kB 1.47 kB -0.7% -41 B
adapter/better-stack 1.27 kB 1.26 kB -0.9% -41 B
adapter/hyperdx 1.19 kB 1.18 kB -1.2% -41 B
toolkit 796 B 784 B -1.5% -40 B
Total 56.77 kB 57.45 kB +1.2% +2.09 kB

@pkg-pr-new

pkg-pr-new Bot commented May 24, 2026

Copy link
Copy Markdown
npm i https://pkg.pr.new/evlog@354
npm i https://pkg.pr.new/@evlog/nuxthub@354

commit: 423db10

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 7

🤖 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/evlog/src/adapters/memory.ts`:
- Around line 31-33: The parseMaxEvents function currently accepts positive
non-integer numbers and returns Math.floor(value) which for values like 0.5
becomes 0 and disables draining; update parseMaxEvents (the function named
parseMaxEvents) to ensure fractional numbers do not resolve to 0 by either
requiring integers or re-checking after flooring: if value is a number, compute
const n = Math.floor(value) and then return n > 0 ? n : undefined (or
throw/validate for non-integers per project policy); similarly for string input,
parse to number, floor, and ensure the floored result is > 0 before returning
it.

In `@packages/evlog/test/adapters/datadog.test.ts`:
- Around line 321-325: The test’s environment cleanup runs only after tests,
allowing pre-set DATADOG_API_KEY/DD_API_KEY/NUXT_DATADOG_API_KEY to leak into
the “missing API key” scenario; make it hermetic by saving originals in a
variable (e.g., origDatadogApiKey, origDdApiKey, origNuxtDatadogApiKey) in a
beforeEach, then delete those env vars in that beforeEach to ensure the test
starts with no keys, and finally restore the saved originals in afterEach
(replace the current delete-only afterEach with restore logic). Ensure you
update both places referenced in the file (the existing afterEach and the
similar block around the other tests).

In `@packages/evlog/test/adapters/fs.test.ts`:
- Around line 312-316: The test "uses default dir when no config is provided"
only checks that mockedAppendFile was called but doesn't assert the resolved
output path; update the test for createFsDrain / createDrainContext to capture
the first call args of mockedAppendFile (or its path parameter) and assert that
the file path includes the expected default directory/name (the computed output
path used by createFsDrain when no config is passed). Use
mockedAppendFile.mock.calls[0][0] (or equivalent) to read the path and assert it
equals or matches the expected default path string.

In `@packages/evlog/test/adapters/hyperdx.test.ts`:
- Around line 118-121: The missing-apiKey test can be influenced by the
environment because you only clear env vars in the afterEach; add a beforeEach
(adjacent to the existing afterEach) that deletes
process.env.NUXT_HYPERDX_API_KEY and process.env.HYPERDX_API_KEY to ensure the
test runs with a clean environment, and apply the same beforeEach/afterEach
pattern for the other related test block referenced around the existing
afterEach to guarantee isolation.

In `@packages/evlog/test/adapters/memory.test.ts`:
- Around line 106-120: The test mutates process.env (EVLOG_MEMORY_STORE,
EVLOG_MEMORY_MAX_EVENTS) but only deletes them on the success path; to prevent
leaking env into other tests, snapshot the original values before setting them,
run the test logic (using clearMemoryLogs, createMemoryDrain, readMemoryLogs as
currently used), and in a finally block restore the original env entries
(reassign originals or delete if originally undefined) and perform any necessary
cleanup like clearMemoryLogs('env-store'); ensure the try/finally wraps the
setup and assertions so env restoration always runs even on failure.

In `@packages/evlog/test/adapters/otlp.test.ts`:
- Around line 433-436: The missing-endpoint tests are non-deterministic because
environment variables are only cleared in afterEach; add a beforeEach that
deletes process.env.NUXT_OTLP_ENDPOINT and
process.env.OTEL_EXPORTER_OTLP_ENDPOINT so the "missing-endpoint" path is
isolated, and apply the same beforeEach change for the other test block covering
lines 444-451; reference the env names (process.env.NUXT_OTLP_ENDPOINT,
process.env.OTEL_EXPORTER_OTLP_ENDPOINT) and add the cleanup at the start of the
relevant describe/it blocks.

In `@packages/evlog/test/adapters/sentry.test.ts`:
- Around line 308-311: The tests are flaky because SENTRY_DSN/NUXT_SENTRY_DSN
are only cleared in afterEach (see afterEach block), which is too late if the
environment already defines them; add a beforeEach that deletes
process.env.SENTRY_DSN and process.env.NUXT_SENTRY_DSN (or clear them at the top
of the test file) so each test starts with a clean environment, and apply the
same change for the other test group that currently clears these vars only in
its afterEach.
🪄 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: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 52d22602-42f9-45cd-a89d-bb4e043860a3

📥 Commits

Reviewing files that changed from the base of the PR and between 354275f and 877b9c3.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (38)
  • .changeset/add-memory-drain-adapter.md
  • apps/docs/content/3.integrate/adapters/01.overview.md
  • apps/docs/content/3.integrate/adapters/cloud/01.axiom.md
  • apps/docs/content/3.integrate/adapters/cloud/03.posthog.md
  • apps/docs/content/3.integrate/adapters/cloud/05.better-stack.md
  • apps/docs/content/3.integrate/adapters/self-hosted/03.memory.md
  • apps/docs/content/3.integrate/frameworks/00.overview.md
  • apps/docs/content/3.integrate/frameworks/02.nextjs.md
  • apps/docs/content/3.integrate/frameworks/06.nestjs.md
  • apps/docs/content/4.use-cases/4.audit/04.pipeline.md
  • apps/docs/content/4.use-cases/4.audit/06.recipes.md
  • apps/docs/content/4.use-cases/5.enrichers.md
  • apps/docs/content/6.reference/5.vs-other-loggers.md
  • apps/docs/skills/review-logging-patterns/SKILL.md
  • packages/evlog/README.md
  • packages/evlog/package.json
  • packages/evlog/src/adapters/memory.ts
  • packages/evlog/src/next/index.ts
  • packages/evlog/src/nuxt/module.ts
  • packages/evlog/src/shared/config.ts
  • packages/evlog/test/README.md
  • packages/evlog/test/adapters/axiom.test.ts
  • packages/evlog/test/adapters/better-stack.test.ts
  • packages/evlog/test/adapters/config.test.ts
  • packages/evlog/test/adapters/datadog.test.ts
  • packages/evlog/test/adapters/fs.test.ts
  • packages/evlog/test/adapters/hyperdx.test.ts
  • packages/evlog/test/adapters/memory.test.ts
  • packages/evlog/test/adapters/otlp.test.ts
  • packages/evlog/test/adapters/sentry.test.ts
  • packages/evlog/test/frameworks/elysia.test.ts
  • packages/evlog/test/frameworks/express.test.ts
  • packages/evlog/test/frameworks/fastify.test.ts
  • packages/evlog/test/frameworks/hono.test.ts
  • packages/evlog/test/frameworks/nestjs.test.ts
  • packages/evlog/test/frameworks/react-router.test.ts
  • packages/evlog/test/frameworks/sveltekit.test.ts
  • packages/evlog/test/toolkit/enrichers.test.ts
💤 Files with no reviewable changes (1)
  • packages/evlog/test/frameworks/express.test.ts

Comment thread packages/evlog/src/adapters/memory.ts
Comment thread packages/evlog/test/adapters/datadog.test.ts Outdated
Comment thread packages/evlog/test/adapters/fs.test.ts
Comment thread packages/evlog/test/adapters/hyperdx.test.ts Outdated
Comment thread packages/evlog/test/adapters/memory.test.ts
Comment thread packages/evlog/test/adapters/otlp.test.ts Outdated
Comment thread packages/evlog/test/adapters/sentry.test.ts Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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/evlog/src/adapters/memory.ts`:
- Around line 32-38: The string branch of parseMaxEvents (in
packages/evlog/src/adapters/memory.ts) accepts values like "Infinity" because it
parses then floors without checking finiteness; update the string-handling path
in parseMaxEvents to parse the string to a number, verify
Number.isFinite(parsed) and that the floored value is > 0 before returning it
(otherwise return undefined) so writeToMemory's trimming logic works and
Infinity is rejected.
🪄 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: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 455c4703-0cf1-404b-adef-0bba3c944fe7

📥 Commits

Reviewing files that changed from the base of the PR and between 877b9c3 and c68faa9.

📒 Files selected for processing (7)
  • packages/evlog/src/adapters/memory.ts
  • packages/evlog/test/adapters/datadog.test.ts
  • packages/evlog/test/adapters/fs.test.ts
  • packages/evlog/test/adapters/hyperdx.test.ts
  • packages/evlog/test/adapters/memory.test.ts
  • packages/evlog/test/adapters/otlp.test.ts
  • packages/evlog/test/adapters/sentry.test.ts

Comment thread packages/evlog/src/adapters/memory.ts Outdated
@HugoRCD HugoRCD merged commit 59f1890 into main May 25, 2026
20 checks passed
@HugoRCD HugoRCD deleted the fix/align-doc-and-repo branch May 25, 2026 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant