Append a logfmt key into sb, normalising two characters that are inconvenient downstream: . is rewritten as _. Many OTel semantic-convention keys are dotted (exception.type, http.method, db.statement, …); a dot in a logfmt key r
(StringBuilder sb, String key)
| 103 | * append, no allocation. |
| 104 | */ |
| 105 | public static void appendLogfmtKey(StringBuilder sb, String key) { |
| 106 | if (key.indexOf('.') < 0 && key.indexOf('?') < 0) { |
| 107 | sb.append(key); |
| 108 | return; |
| 109 | } |
| 110 | int n = key.length(); |
| 111 | for (int i = 0; i < n; i++) { |
| 112 | char c = key.charAt(i); |
| 113 | if (c == '?') { |
| 114 | // Drop, don't replace — `rate_limited` reads better than |
| 115 | // `rate_limited_`. |
| 116 | continue; |
| 117 | } |
| 118 | sb.append(c == '.' ? '_' : c); |
| 119 | } |
| 120 | } |
| 121 | } |
nothing calls this directly
no outgoing calls
no test coverage detected