Skip to content

Generalize setupOptionOtel as an independent runtime - #22

Closed
gtxy27 wants to merge 4 commits into
mainfrom
codex/developer-logs-v4
Closed

Generalize setupOptionOtel as an independent runtime#22
gtxy27 wants to merge 4 commits into
mainfrom
codex/developer-logs-v4

Conversation

@gtxy27

@gtxy27 gtxy27 commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • make setupOptionOtel a generic, independent isolated runtime
  • require a caller-owned private traceparentHeader and reject the standard traceparent carrier
  • accept only explicit resourceAttributes
  • stop reading or exporting the main setupOtel Resource and remove setup ordering
  • remove Developer Logs product names, private headers, and Project examples from public source, tests, and docs
  • bump the package to 3.6.0

Validation

  • Ultracite check
  • TypeScript typecheck
  • 125 unit tests
  • package build
  • deterministic clean-publish package verification
  • packaged runtime exercised by the Developer Logs SDK Docker integration

Related

Summary by CodeRabbit

  • New Features

    • Added an independent OpenTelemetry runtime that can run without the main runtime.
    • Added support for custom resource attributes and configurable trace propagation headers.
    • Added validation for propagation header names and clearer diagnostics.
    • Option runtime startup and shutdown are now managed independently.
  • Documentation

    • Updated API reference, architecture guidance, and usage examples.
  • Tests

    • Expanded coverage for resources, propagation, validation, startup, and shutdown.

Copilot AI lite review requested due to automatic review settings August 12, 2026 11:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6435b437-7144-4e3c-a836-484d78c5476a

📥 Commits

Reviewing files that changed from the base of the PR and between 12ca47d and 48ad4db.

📒 Files selected for processing (1)
  • docs/guides/option-runtime.mdx
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/guides/option-runtime.mdx

📝 Walkthrough

Walkthrough

setupOptionOtel() now creates an independent runtime with its own resource and configurable propagation header. It no longer requires the main runtime or reuses its resource. Documentation, tests, and version metadata reflect the updated behavior.

Changes

Option runtime isolation

Layer / File(s) Summary
Runtime contract and documentation
src/option-runtime.ts, README.md, docs/concepts/architecture.mdx, docs/guides/option-runtime.mdx, docs/reference/api.mdx
The API and documentation define independent resources, explicit resourceAttributes, and configurable traceparentHeader propagation.
Isolated runtime implementation
src/option-runtime.ts, src/setup.ts
setupOptionOtel() creates its own resource, validates the header name, uses option-specific propagation and instrumentation scope, and removes shared active-resource state.
Runtime validation and release metadata
tests/option-runtime.test.ts, package.json, src/version.ts
Tests cover independent startup, resources, propagation, diagnostics, shutdown, and updated identifiers. Package and exported version metadata report the new release version.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Application
  participant setupOptionOtel
  participant OptionRuntime
  participant ConfiguredPropagator
  Application->>setupOptionOtel: provide resourceAttributes and traceparentHeader
  setupOptionOtel->>ConfiguredPropagator: validate traceparentHeader
  setupOptionOtel->>OptionRuntime: create isolated Resource and runtime
  OptionRuntime->>ConfiguredPropagator: extract or inject configured header
Loading

Poem

I’m a rabbit with traces in flight,
An option runtime tucked out of sight.
My resources are mine, my headers are too,
I start independently, as runtimes should do.
Hop, hop—version 3.6.0 is new!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: making setupOptionOtel an independent runtime.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/developer-logs-v4

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

@coderabbitai coderabbitai Bot added the release Fight on! label Aug 12, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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 `@src/option-runtime.ts`:
- Around line 122-132: Update the traceparentHeader validation in the
option-runtime setup path to reject the trimmed value “traceparent”
case-insensitively, while preserving existing invalid-header handling. Add
coverage for both “traceparent” and “TraceParent” to verify they are rejected.
🪄 Autofix

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: CHILL

Plan: Pro

Run ID: 18a10c62-3708-47c9-b030-7803e943e9eb

📥 Commits

Reviewing files that changed from the base of the PR and between f584cc5 and 87c533a.

📒 Files selected for processing (9)
  • README.md
  • docs/concepts/architecture.mdx
  • docs/guides/option-runtime.mdx
  • docs/reference/api.mdx
  • package.json
  • src/option-runtime.ts
  • src/setup.ts
  • src/version.ts
  • tests/option-runtime.test.ts
📜 Review details
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc)

Prefer interface for defining object shapes in TypeScript rather than type aliases

**/*.{ts,tsx}: Use explicit types for function parameters and return values when they enhance clarity
Prefer unknown over any when the type is genuinely unknown
Use as const const assertions for immutable values and literal types
Leverage TypeScript type narrowing instead of type assertions
Use meaningful variable names instead of magic numbers; extract descriptive constants
Use arrow functions for callbacks and short functions
Prefer for...of loops over .forEach() and indexed for loops
Use optional chaining (?.) and nullish coalescing (??) for safer property access
Prefer template literals over string concatenation
Use destructuring for object and array assignments
Use const by default, let only when reassignment is needed, and never use var
Always await promises in async functions and use the return value
Use async/await syntax instead of promise chains for better readability
Handle errors appropriately in async code with try-catch blocks
Don't use async functions as Promise executors

Files:

  • src/version.ts
  • src/setup.ts
  • tests/option-runtime.test.ts
  • src/option-runtime.ts
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc)

**/*.{js,jsx,ts,tsx}: Use camelCase for variable and function names in JavaScript/TypeScript
Use PascalCase for class and component names in JavaScript/TypeScript
Always use async/await for promise handling instead of .then() chains
Include JSDoc comments for exported functions and classes
Use meaningful variable names that clearly describe their purpose
Avoid deeply nested conditionals; use early returns or guard clauses instead
Use const by default, let when reassignment is needed, avoid var

**/*.{js,jsx,ts,tsx}: Remove console.log, debugger, and alert statements from production code
Throw Error objects with descriptive messages, not strings or other values
Use try-catch blocks meaningfully; don't catch errors just to rethrow them
Prefer early returns over nested conditionals for error cases
Keep functions focused and under reasonable cognitive complexity limits
Extract complex conditions into well-named boolean variables
Use early returns to reduce nesting
Prefer simple conditionals over nested ternary operators
Group related code together and separate concerns
Add rel="noopener" when using target="_blank" on links
Avoid dangerouslySetInnerHTML unless absolutely necessary
Don't use eval() or assign directly to document.cookie
Validate and sanitize user input
Avoid spread syntax in accumulators within loops
Use top-level regex literals instead of creating them in loops
Prefer specific imports over namespace imports
Avoid barrel files (index files that re-export everything)
Use proper image components (for example, Next.js <Image>) over <img> tags
Use next/head or the App Router metadata API for head elements
Use Server Components for async data fetching instead of async Client Components

Files:

  • src/version.ts
  • src/setup.ts
  • tests/option-runtime.test.ts
  • src/option-runtime.ts
**/*.test.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc)

Write unit tests for all public functions and components

Files:

  • tests/option-runtime.test.ts
**/*.{test,spec}.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{test,spec}.{js,jsx,ts,tsx}: Write assertions inside it() or test() blocks
Avoid done callbacks in async tests; use async/await instead
Don't use .only or .skip in committed code
Keep test suites reasonably flat; avoid excessive describe nesting

Files:

  • tests/option-runtime.test.ts
🔇 Additional comments (9)
src/option-runtime.ts (1)

20-23: LGTM!

Also applies to: 36-51, 66-68, 165-191, 303-310

docs/reference/api.mdx (1)

93-110: LGTM!

Also applies to: 144-145

README.md (1)

8-8: LGTM!

Also applies to: 98-98, 119-140

docs/concepts/architecture.mdx (1)

60-63: LGTM!

docs/guides/option-runtime.mdx (1)

6-15: LGTM!

Also applies to: 24-39, 56-67

src/setup.ts (1)

22-22: LGTM!

Also applies to: 356-366

tests/option-runtime.test.ts (1)

29-116: LGTM!

Also applies to: 127-397

package.json (1)

3-3: LGTM!

src/version.ts (1)

1-1: LGTM!

Comment thread src/option-runtime.ts
Copilot AI review requested due to automatic review settings August 12, 2026 12:04

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI review requested due to automatic review settings August 12, 2026 13:54

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai coderabbitai Bot removed the release Fight on! label Aug 12, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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 `@tests/option-runtime.test.ts`:
- Around line 177-184: Update the resource assertion in the option runtime test
to require exact equality with only the explicit service.name and
service.version attributes, replacing the partial toMatchObject check while
preserving the existing span-count assertion.
🪄 Autofix

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: CHILL

Plan: Pro

Run ID: 0c646675-3d89-44c0-a7fc-48c3f5498a0c

📥 Commits

Reviewing files that changed from the base of the PR and between df04413 and 12ca47d.

📒 Files selected for processing (4)
  • docs/guides/option-runtime.mdx
  • docs/reference/api.mdx
  • src/option-runtime.ts
  • tests/option-runtime.test.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • docs/reference/api.mdx
  • docs/guides/option-runtime.mdx
  • src/option-runtime.ts
📜 Review details
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc)

Prefer interface for defining object shapes in TypeScript rather than type aliases

**/*.{ts,tsx}: Use explicit types for function parameters and return values when they enhance clarity
Prefer unknown over any when the type is genuinely unknown
Use as const const assertions for immutable values and literal types
Leverage TypeScript type narrowing instead of type assertions
Use meaningful variable names instead of magic numbers; extract descriptive constants
Use arrow functions for callbacks and short functions
Prefer for...of loops over .forEach() and indexed for loops
Use optional chaining (?.) and nullish coalescing (??) for safer property access
Prefer template literals over string concatenation
Use destructuring for object and array assignments
Use const by default, let only when reassignment is needed, and never use var
Always await promises in async functions and use the return value
Use async/await syntax instead of promise chains for better readability
Handle errors appropriately in async code with try-catch blocks
Don't use async functions as Promise executors

Files:

  • tests/option-runtime.test.ts
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc)

**/*.{js,jsx,ts,tsx}: Use camelCase for variable and function names in JavaScript/TypeScript
Use PascalCase for class and component names in JavaScript/TypeScript
Always use async/await for promise handling instead of .then() chains
Include JSDoc comments for exported functions and classes
Use meaningful variable names that clearly describe their purpose
Avoid deeply nested conditionals; use early returns or guard clauses instead
Use const by default, let when reassignment is needed, avoid var

**/*.{js,jsx,ts,tsx}: Remove console.log, debugger, and alert statements from production code
Throw Error objects with descriptive messages, not strings or other values
Use try-catch blocks meaningfully; don't catch errors just to rethrow them
Prefer early returns over nested conditionals for error cases
Keep functions focused and under reasonable cognitive complexity limits
Extract complex conditions into well-named boolean variables
Use early returns to reduce nesting
Prefer simple conditionals over nested ternary operators
Group related code together and separate concerns
Add rel="noopener" when using target="_blank" on links
Avoid dangerouslySetInnerHTML unless absolutely necessary
Don't use eval() or assign directly to document.cookie
Validate and sanitize user input
Avoid spread syntax in accumulators within loops
Use top-level regex literals instead of creating them in loops
Prefer specific imports over namespace imports
Avoid barrel files (index files that re-export everything)
Use proper image components (for example, Next.js <Image>) over <img> tags
Use next/head or the App Router metadata API for head elements
Use Server Components for async data fetching instead of async Client Components

Files:

  • tests/option-runtime.test.ts
**/*.test.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc)

Write unit tests for all public functions and components

Files:

  • tests/option-runtime.test.ts
**/*.{test,spec}.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{test,spec}.{js,jsx,ts,tsx}: Write assertions inside it() or test() blocks
Avoid done callbacks in async tests; use async/await instead
Don't use .only or .skip in committed code
Keep test suites reasonably flat; avoid excessive describe nesting

Files:

  • tests/option-runtime.test.ts
🔇 Additional comments (1)
tests/option-runtime.test.ts (1)

20-20: LGTM!

Also applies to: 36-61, 85-87

Comment on lines +177 to +184
expect(publicExportedSpans).toHaveLength(1);
expect(publicExportedSpans[0]?.resource.attributes).toMatchObject({
"service.name": "option-service",
"service.version": "1.2.3",
});
expect(
publicExportedSpans[0]?.resource.attributes["main.runtime"]
).toBeUndefined();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Assert the complete option resource.

toMatchObject accepts unspecified resource attributes. The test can pass if the option runtime retains an unintended attribute, such as the main runtime's deployment.environment.

Assert that resource.attributes equals the two supplied attributes. This verifies the contract that the option runtime uses only its explicit resource attributes.

Proposed test change
-    expect(publicExportedSpans[0]?.resource.attributes).toMatchObject({
+    expect(publicExportedSpans[0]?.resource.attributes).toEqual({
       "service.name": "option-service",
       "service.version": "1.2.3",
     });
-    expect(
-      publicExportedSpans[0]?.resource.attributes["main.runtime"]
-    ).toBeUndefined();
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
expect(publicExportedSpans).toHaveLength(1);
expect(publicExportedSpans[0]?.resource.attributes).toMatchObject({
"service.name": "option-service",
"service.version": "1.2.3",
});
expect(
publicExportedSpans[0]?.resource.attributes["main.runtime"]
).toBeUndefined();
expect(publicExportedSpans).toHaveLength(1);
expect(publicExportedSpans[0]?.resource.attributes).toEqual({
"service.name": "option-service",
"service.version": "1.2.3",
});
🤖 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 `@tests/option-runtime.test.ts` around lines 177 - 184, Update the resource
assertion in the option runtime test to require exact equality with only the
explicit service.name and service.version attributes, replacing the partial
toMatchObject check while preserving the existing span-count assertion.

Copilot AI review requested due to automatic review settings August 12, 2026 14:04

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@gtxy27 gtxy27 closed this Aug 12, 2026
@gtxy27
gtxy27 deleted the codex/developer-logs-v4 branch August 12, 2026 14:32
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.

2 participants