Commit 78768e4
committed
otelgin: update error handling to set attributes instead of recording errors
Fixes open-telemetry#8441
This change updates the error handling in otelgin middleware to follow
the instrumentation guidelines established in open-telemetry#8386:
- Replace span.RecordError() calls with span.SetAttributes(ErrorType())
- Set error.type attribute for the first error when c.Errors is not empty
- Multiple errors are still captured in the status description via c.Errors.String()
- Update tests to verify error.type attribute instead of span events
This provides better consistency across OpenTelemetry instrumentation
packages and follows the semantic conventions for error handling.1 parent 8c6be24 commit 78768e4
2 files changed
Lines changed: 11 additions & 14 deletions
Lines changed: 4 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
120 | 121 | | |
121 | 122 | | |
122 | 123 | | |
123 | | - | |
124 | | - | |
125 | | - | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
126 | 127 | | |
127 | 128 | | |
128 | 129 | | |
| |||
Lines changed: 7 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| |||
202 | 203 | | |
203 | 204 | | |
204 | 205 | | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
214 | 209 | | |
215 | 210 | | |
216 | 211 | | |
| |||
261 | 256 | | |
262 | 257 | | |
263 | 258 | | |
264 | | - | |
265 | | - | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
266 | 262 | | |
267 | 263 | | |
268 | 264 | | |
| |||
0 commit comments