Enable context-flattening to support context field searching#491
Open
nickmarden wants to merge 4 commits intoopen-telemetry:mainfrom
Open
Enable context-flattening to support context field searching#491nickmarden wants to merge 4 commits intoopen-telemetry:mainfrom
nickmarden wants to merge 4 commits intoopen-telemetry:mainfrom
Conversation
brettmc
approved these changes
Dec 19, 2025
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #491 +/- ##
============================================
+ Coverage 83.46% 83.48% +0.02%
- Complexity 2330 2344 +14
============================================
Files 149 149
Lines 8791 8816 +25
============================================
+ Hits 7337 7360 +23
- Misses 1454 1456 +2 Flags with carried forward coverage won't be shown. Click here to find out more.
... and 1 file with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
c13169b to
2e340d8
Compare
Author
|
@brettmc I'm unclear how to trigger another CI run. I believe I've fixed all but one of the previously-failing CI tests, but I can't be sure. Is this something you need to trigger, or can I? |
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.
Description
Resolves open-telemetry/opentelemetry-php#1837
This PR adds an optional configuration to flatten log context attributes into individual OTLP attributes, improving searchability in observability backends.
Problem
The Laravel LogWatcher currently JSON-encodes the entire log context into a single context attribute:
context: {"http":{"method":"GET","path":"/users","status":200},"user_id":"123"}
This makes it impossible to search/filter by specific values (e.g., http.method = "GET") in backends like SigNoz, Jaeger, or Grafana.
Solution
A new configuration option OTEL_PHP_LARAVEL_LOG_ATTRIBUTES_FLATTEN that, when enabled, spreads context as individual attributes with dot-notation for nested arrays:
http.method: GET
http.path: /users
http.status: 200
user_id: 123
Changes
Backward Compatibility
Testing
./vendor/bin/phpunit --testsuite=unit # 18 tests, 42 assertions
./vendor/bin/phpunit --testsuite=integration # 21 tests, 120 assertions
Screenshot