Make HttpStatusConverter package private
DELETE
instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpClientStatusConverter.java
-/*
- * Copyright The OpenTelemetry Authors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-package io.opentelemetry.instrumentation.api.instrumenter.http;
-
-import io.opentelemetry.api.trace.StatusCode;
-
-final class HttpClientStatusConverter implements HttpStatusConverter {
-
- static final HttpStatusConverter INSTANCE = new HttpClientStatusConverter();
-
- // https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/semantic_conventions/http.md#status
- @Override
- public StatusCode statusFromHttpStatus(int httpStatus) {
- if (httpStatus >= 100 && httpStatus < 400) {
- return StatusCode.UNSET;
- }
-
- return StatusCode.ERROR;
- }
-
- private HttpClientStatusConverter() {}
-}

DELETE
instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpServerStatusConverter.java
-/*
- * Copyright The OpenTelemetry Authors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-package io.opentelemetry.instrumentation.api.instrumenter.http;
-
-import io.opentelemetry.api.trace.StatusCode;
-
-final class HttpServerStatusConverter implements HttpStatusConverter {
-
- static final HttpStatusConverter INSTANCE = new HttpServerStatusConverter();
-
- // https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/semantic_conventions/http.md#status
- @Override
- public StatusCode statusFromHttpStatus(int httpStatus) {
- if (httpStatus >= 100 && httpStatus < 500) {
- return StatusCode.UNSET;
- }
-
- return StatusCode.ERROR;
- }
-
- private HttpServerStatusConverter() {}
-}

MODIFY
instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpStatusConverter.java
instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpStatusConverter.java
@@ -7,10 +7,28 @@ package io.opentelemetry.instrumentation.api.instrumenter.http;
import io.opentelemetry.api.trace.StatusCode;
-public interface HttpStatusConverter {
+// https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/semantic_conventions/http.md#status
+enum HttpStatusConverter {
+ SERVER {
+ @Override
+ StatusCode statusFromHttpStatus(int httpStatus) {
+ if (httpStatus >= 100 && httpStatus < 500) {
+ return StatusCode.UNSET;
+ }
- HttpStatusConverter SERVER = HttpServerStatusConverter.INSTANCE;
- HttpStatusConverter CLIENT = HttpClientStatusConverter.INSTANCE;
+ return StatusCode.ERROR;
+ }
+ },
+ CLIENT {
+ @Override
+ StatusCode statusFromHttpStatus(int httpStatus) {
+ if (httpStatus >= 100 && httpStatus < 400) {
+ return StatusCode.UNSET;
+ }
+
+ return StatusCode.ERROR;
+ }
+ };
- StatusCode statusFromHttpStatus(int httpStatus);
+ abstract StatusCode statusFromHttpStatus(int httpStatus);
}

Make HttpStatusConverter package private (#5268)