Skip to content

add OtelErrorLoggingMiddleware#1

Merged
kaz29 merged 2 commits intomainfrom
feat/error_log_middleware
Mar 28, 2026
Merged

add OtelErrorLoggingMiddleware#1
kaz29 merged 2 commits intomainfrom
feat/error_log_middleware

Conversation

@kaz29
Copy link
Copy Markdown
Owner

@kaz29 kaz29 commented Mar 28, 2026

No description provided.

@kaz29 kaz29 requested a review from Copilot March 28, 2026 05:14
@kaz29 kaz29 self-assigned this Mar 28, 2026
@kaz29 kaz29 added the enhancement New feature or request label Mar 28, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds OpenTelemetry error logging support for CakePHP via a new middleware, plus shared OpenTelemetry test setup helpers and integration tests to validate span/log behavior.

Changes:

  • Introduces OtelErrorLoggingMiddleware to emit OpenTelemetry log records for 500-level (and unexpected) exceptions.
  • Adds OtelTestTrait to centralize in-memory span/log exporter setup for tests, and refactors existing integration tests to use it.
  • Updates README (EN/JA) and adds a spec document describing the feature and test strategy.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/Middleware/OtelErrorLoggingMiddleware.php New PSR-15 middleware that logs eligible exceptions to OTel logs and rethrows.
tests/TestCase/OtelTestTrait.php New shared test trait for configuring in-memory OTel exporters/providers.
tests/TestCase/Integration/Middleware/OtelErrorLoggingMiddlewareTest.php New integration tests validating logging behavior for different exception types.
tests/TestCase/Integration/ControllerInstrumentationTest.php Refactor to use OtelTestTrait and add ext-opentelemetry skip + teardown reset.
tests/TestCase/Integration/TableInstrumentationTest.php Refactor to use OtelTestTrait and add ext-opentelemetry skip + teardown reset.
README.md Documents the new middleware and recommended placement in the middleware queue.
README.ja.md Japanese documentation for the new middleware and configuration guidance.
specs/001-exception-logger/SPEC.md New feature spec (currently has some drift vs repo layout/phpunit config).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Add exception.message to OTel log attributes per semantic conventions
- Rename resetSpans() to resetOtel() to reflect actual behavior (resets all globals)
- Update SPEC.md to match implementation (file paths, suite names, composer.json)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@kaz29 kaz29 merged commit a74e514 into main Mar 28, 2026
3 checks passed
@kaz29 kaz29 deleted the feat/error_log_middleware branch March 28, 2026 05:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants