Enable context-flattening to support context field searching#491
Enable context-flattening to support context field searching#491nickmarden wants to merge 4 commits intoopen-telemetry:mainfrom
Conversation
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
|
@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? |
2e340d8 to
ff353e9
Compare
|
Hi @brettmc, I just updated the fork by re-basing to main. Could you please run CI? thanks! |
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