|
17 | 17 | final class CapturedHttpHeadersUtil {
|
18 | 18 |
|
19 | 19 | // these are naturally bounded because they only store keys listed in
|
20 |
| - // otel.instrumentation.http.capture-headers.server.request and |
21 |
| - // otel.instrumentation.http.capture-headers.server.response |
22 |
| - private static final ConcurrentMap<String, AttributeKey<List<String>>> requestKeysCache = |
23 |
| - new ConcurrentHashMap<>(); |
24 |
| - private static final ConcurrentMap<String, AttributeKey<List<String>>> responseKeysCache = |
25 |
| - new ConcurrentHashMap<>(); |
| 20 | + // otel.instrumentation.http.server.capture-request-headers and |
| 21 | + // otel.instrumentation.http.server.capture-response-headers |
| 22 | + private static final ConcurrentMap<String, AttributeKey<List<String>>> |
| 23 | + oldSemconvRequestKeysCache = new ConcurrentHashMap<>(); |
| 24 | + private static final ConcurrentMap<String, AttributeKey<List<String>>> |
| 25 | + stableSemconvRequestKeysCache = new ConcurrentHashMap<>(); |
| 26 | + private static final ConcurrentMap<String, AttributeKey<List<String>>> |
| 27 | + oldSemconvResponseKeysCache = new ConcurrentHashMap<>(); |
| 28 | + private static final ConcurrentMap<String, AttributeKey<List<String>>> |
| 29 | + stableSemconvResponseKeysCache = new ConcurrentHashMap<>(); |
26 | 30 |
|
27 | 31 | static List<String> lowercase(List<String> names) {
|
28 | 32 | return unmodifiableList(
|
29 | 33 | names.stream().map(s -> s.toLowerCase(Locale.ROOT)).collect(Collectors.toList()));
|
30 | 34 | }
|
31 | 35 |
|
32 |
| - static AttributeKey<List<String>> requestAttributeKey(String headerName) { |
33 |
| - return requestKeysCache.computeIfAbsent(headerName, n -> createKey("request", n)); |
| 36 | + static AttributeKey<List<String>> oldSemconvRequestAttributeKey(String headerName) { |
| 37 | + return oldSemconvRequestKeysCache.computeIfAbsent( |
| 38 | + headerName, n -> createOldSemconvKey("request", n)); |
34 | 39 | }
|
35 | 40 |
|
36 |
| - static AttributeKey<List<String>> responseAttributeKey(String headerName) { |
37 |
| - return responseKeysCache.computeIfAbsent(headerName, n -> createKey("response", n)); |
| 41 | + static AttributeKey<List<String>> stableSemconvRequestAttributeKey(String headerName) { |
| 42 | + return stableSemconvRequestKeysCache.computeIfAbsent( |
| 43 | + headerName, n -> createStableSemconvKey("request", n)); |
38 | 44 | }
|
39 | 45 |
|
40 |
| - private static AttributeKey<List<String>> createKey(String type, String headerName) { |
41 |
| - // headerName is always lowercase, see CapturedHttpHeaders |
| 46 | + static AttributeKey<List<String>> oldSemconvResponseAttributeKey(String headerName) { |
| 47 | + return oldSemconvResponseKeysCache.computeIfAbsent( |
| 48 | + headerName, n -> createOldSemconvKey("response", n)); |
| 49 | + } |
| 50 | + |
| 51 | + static AttributeKey<List<String>> stableSemconvResponseAttributeKey(String headerName) { |
| 52 | + return stableSemconvResponseKeysCache.computeIfAbsent( |
| 53 | + headerName, n -> createStableSemconvKey("response", n)); |
| 54 | + } |
| 55 | + |
| 56 | + private static AttributeKey<List<String>> createOldSemconvKey(String type, String headerName) { |
| 57 | + // headerName is always lowercase, see CapturedHttpHeadersUtil#lowercase |
42 | 58 | String key = "http." + type + ".header." + headerName.replace('-', '_');
|
43 | 59 | return AttributeKey.stringArrayKey(key);
|
44 | 60 | }
|
45 | 61 |
|
| 62 | + private static AttributeKey<List<String>> createStableSemconvKey(String type, String headerName) { |
| 63 | + // headerName is always lowercase, see CapturedHttpHeadersUtil#lowercase |
| 64 | + String key = "http." + type + ".header." + headerName; |
| 65 | + return AttributeKey.stringArrayKey(key); |
| 66 | + } |
| 67 | + |
46 | 68 | private CapturedHttpHeadersUtil() {}
|
47 | 69 | }
|
0 commit comments