Skip to content

Commit 8b4979f

Browse files
authored
Make ApacheHttpClient5Request public (#12394)
1 parent e90959b commit 8b4979f

File tree

1 file changed

+1
-62
lines changed
  • instrumentation/apache-httpclient/apache-httpclient-5.2/library/src/main/java/io/opentelemetry/instrumentation/apachehttpclient/v5_2

1 file changed

+1
-62
lines changed

instrumentation/apache-httpclient/apache-httpclient-5.2/library/src/main/java/io/opentelemetry/instrumentation/apachehttpclient/v5_2/ApacheHttpClient5Request.java

+1-62
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,19 @@
77

88
import static java.util.logging.Level.FINE;
99

10-
import java.net.InetAddress;
11-
import java.net.InetSocketAddress;
1210
import java.net.URI;
1311
import java.net.URISyntaxException;
14-
import java.util.ArrayList;
15-
import java.util.Collections;
16-
import java.util.List;
1712
import java.util.logging.Logger;
1813
import javax.annotation.Nullable;
19-
import org.apache.hc.core5.http.Header;
2014
import org.apache.hc.core5.http.HttpHost;
2115
import org.apache.hc.core5.http.HttpRequest;
22-
import org.apache.hc.core5.http.ProtocolVersion;
2316

24-
final class ApacheHttpClient5Request {
17+
public final class ApacheHttpClient5Request {
2518

2619
private static final Logger logger = Logger.getLogger(ApacheHttpClient5Request.class.getName());
2720

2821
@Nullable private final URI uri;
29-
3022
private final HttpRequest delegate;
31-
@Nullable private final HttpHost target;
3223

3324
ApacheHttpClient5Request(@Nullable HttpHost httpHost, HttpRequest httpRequest) {
3425
URI calculatedUri = getUri(httpRequest);
@@ -38,34 +29,13 @@ final class ApacheHttpClient5Request {
3829
uri = calculatedUri;
3930
}
4031
delegate = httpRequest;
41-
target = httpHost;
4232
}
4333

4434
/** Returns the actual {@link HttpRequest} being executed by the client. */
4535
public HttpRequest getDelegate() {
4636
return delegate;
4737
}
4838

49-
List<String> getHeader(String name) {
50-
return headersToList(delegate.getHeaders(name));
51-
}
52-
53-
// minimize memory overhead by not using streams
54-
static List<String> headersToList(Header[] headers) {
55-
if (headers.length == 0) {
56-
return Collections.emptyList();
57-
}
58-
List<String> headersList = new ArrayList<>(headers.length);
59-
for (Header header : headers) {
60-
headersList.add(header.getValue());
61-
}
62-
return headersList;
63-
}
64-
65-
void setHeader(String name, String value) {
66-
delegate.setHeader(name, value);
67-
}
68-
6939
String getMethod() {
7040
return delegate.getMethod();
7141
}
@@ -75,28 +45,6 @@ String getUrl() {
7545
return uri != null ? uri.toString() : null;
7646
}
7747

78-
String getProtocolName() {
79-
return delegate.getVersion().getProtocol();
80-
}
81-
82-
String getProtocolVersion() {
83-
ProtocolVersion protocolVersion = delegate.getVersion();
84-
if (protocolVersion.getMinor() == 0) {
85-
return Integer.toString(protocolVersion.getMajor());
86-
}
87-
return protocolVersion.getMajor() + "." + protocolVersion.getMinor();
88-
}
89-
90-
@Nullable
91-
public String getServerAddress() {
92-
return uri == null ? null : uri.getHost();
93-
}
94-
95-
@Nullable
96-
public Integer getServerPort() {
97-
return uri == null ? null : uri.getPort();
98-
}
99-
10048
@Nullable
10149
private static URI getUri(HttpRequest httpRequest) {
10250
try {
@@ -124,13 +72,4 @@ private static URI getCalculatedUri(HttpHost httpHost, URI uri) {
12472
return null;
12573
}
12674
}
127-
128-
@Nullable
129-
public InetSocketAddress getServerSocketAddress() {
130-
if (target == null) {
131-
return null;
132-
}
133-
InetAddress inetAddress = target.getAddress();
134-
return inetAddress == null ? null : new InetSocketAddress(inetAddress, target.getPort());
135-
}
13675
}

0 commit comments

Comments
 (0)