Commit 334d720
committed
refactor: extract common log fields and remove data from diagnosticsLog
This commit addresses PR review feedback by refactoring the logger to
improve code maintainability and prevent data duplication between console
and diagnostics client logs.
Key changes:
- Created commonLogFields object containing shared fields: __VTEX_IO_LOG,
level, operationId, requestId, and traceId
- Removed data field from diagnosticsLog by keeping it only in inflatedLog
- Spread commonLogFields at the end of both log objects to maintain key order
The refactoring ensures:
1. Console logs (inflatedLog) include all fields needed for fluent-bit/OpenSearch
2. Diagnostics client logs (diagnosticsLog) use semantic convention keys without
data duplication
3. Common fields are defined once and reused consistently across both log formats
Addresses review comments from @juliobguedes:
- Comment 1: Remove data from diagnosticsLog to avoid duplications
- Comment 2: Extract commonLogFields to reduce code duplication1 parent 38137e8 commit 334d720
1 file changed
Lines changed: 9 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | | - | |
| 82 | + | |
83 | 83 | | |
84 | 84 | | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
85 | 91 | | |
86 | 92 | | |
87 | 93 | | |
88 | 94 | | |
89 | | - | |
90 | | - | |
91 | 95 | | |
92 | | - | |
| 96 | + | |
93 | 97 | | |
94 | 98 | | |
95 | 99 | | |
| |||
103 | 107 | | |
104 | 108 | | |
105 | 109 | | |
106 | | - | |
107 | | - | |
108 | 110 | | |
109 | 111 | | |
110 | 112 | | |
111 | 113 | | |
112 | 114 | | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
| 115 | + | |
117 | 116 | | |
118 | 117 | | |
119 | 118 | | |
| |||
0 commit comments