-
Notifications
You must be signed in to change notification settings - Fork 0
/
HttpMessageBodySizeUtil.java
37 lines (30 loc) · 1 KB
/
HttpMessageBodySizeUtil.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
package io.opentelemetry.instrumentation.api.incubator.semconv.http;
import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.common.Attributes;
import javax.annotation.Nullable;
final class HttpMessageBodySizeUtil {
@Nullable
static Long getHttpRequestBodySize(Attributes... attributesList) {
return getAttribute(HttpExperimentalAttributesExtractor.HTTP_REQUEST_BODY_SIZE, attributesList);
}
@Nullable
static Long getHttpResponseBodySize(Attributes... attributesList) {
return getAttribute(
HttpExperimentalAttributesExtractor.HTTP_RESPONSE_BODY_SIZE, attributesList);
}
@Nullable
private static <T> T getAttribute(AttributeKey<T> key, Attributes... attributesList) {
for (Attributes attributes : attributesList) {
T value = attributes.get(key);
if (value != null) {
return value;
}
}
return null;
}
private HttpMessageBodySizeUtil() {}
}