Skip to content

Commit f16c777

Browse files
authored
feat: remove opencensus (#834)
* feat: remove beta OpenCensus integration * remove extra references * jsr305 dependency no longer needed after removing opencensus
1 parent 35bb4d7 commit f16c777

File tree

6 files changed

+0
-744
lines changed

6 files changed

+0
-744
lines changed

google-http-client/pom.xml

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,6 @@
1616
</description>
1717

1818
<build>
19-
<pluginManagement>
20-
<plugins>
21-
<plugin>
22-
<groupId>org.apache.maven.plugins</groupId>
23-
<artifactId>maven-dependency-plugin</artifactId>
24-
<version>3.1.1</version>
25-
<configuration>
26-
<ignoredUnusedDeclaredDependencies>io.opencensus:opencensus-impl</ignoredUnusedDeclaredDependencies>
27-
</configuration>
28-
</plugin>
29-
</plugins>
30-
</pluginManagement>
3119
<plugins>
3220
<plugin>
3321
<groupId>org.apache.maven.plugins</groupId>
@@ -109,10 +97,6 @@
10997
<groupId>org.apache.httpcomponents</groupId>
11098
<artifactId>httpcore</artifactId>
11199
</dependency>
112-
<dependency>
113-
<groupId>com.google.code.findbugs</groupId>
114-
<artifactId>jsr305</artifactId>
115-
</dependency>
116100
<dependency>
117101
<groupId>com.google.guava</groupId>
118102
<artifactId>guava</artifactId>
@@ -121,14 +105,6 @@
121105
<groupId>com.google.j2objc</groupId>
122106
<artifactId>j2objc-annotations</artifactId>
123107
</dependency>
124-
<dependency>
125-
<groupId>io.opencensus</groupId>
126-
<artifactId>opencensus-api</artifactId>
127-
</dependency>
128-
<dependency>
129-
<groupId>io.opencensus</groupId>
130-
<artifactId>opencensus-contrib-http-util</artifactId>
131-
</dependency>
132108

133109
<dependency>
134110
<groupId>com.google.guava</groupId>
@@ -150,15 +126,5 @@
150126
<artifactId>mockito-all</artifactId>
151127
<scope>test</scope>
152128
</dependency>
153-
<dependency>
154-
<groupId>io.opencensus</groupId>
155-
<artifactId>opencensus-impl</artifactId>
156-
<scope>test</scope>
157-
</dependency>
158-
<dependency>
159-
<groupId>io.opencensus</groupId>
160-
<artifactId>opencensus-testing</artifactId>
161-
<scope>test</scope>
162-
</dependency>
163129
</dependencies>
164130
</project>

google-http-client/src/main/java/com/google/api/client/http/HttpRequest.java

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@
2323
import com.google.api.client.util.StreamingContent;
2424
import com.google.api.client.util.StringUtils;
2525
import com.google.common.util.concurrent.ThreadFactoryBuilder;
26-
import io.opencensus.common.Scope;
27-
import io.opencensus.contrib.http.util.HttpTraceAttributeConstants;
28-
import io.opencensus.trace.AttributeValue;
29-
import io.opencensus.trace.Span;
30-
import io.opencensus.trace.Tracer;
3126
import java.io.IOException;
3227
import java.io.InputStream;
3328
import java.util.Properties;
@@ -197,9 +192,6 @@ public final class HttpRequest {
197192
/** Sleeper. */
198193
private Sleeper sleeper = Sleeper.DEFAULT;
199194

200-
/** OpenCensus tracing component. */
201-
private final Tracer tracer = OpenCensusUtils.getTracer();
202-
203195
/**
204196
* Determines whether {@link HttpResponse#getContent()} of this request should return raw input
205197
* stream or not.
@@ -843,13 +835,7 @@ public HttpResponse execute() throws IOException {
843835
Preconditions.checkNotNull(requestMethod);
844836
Preconditions.checkNotNull(url);
845837

846-
Span span =
847-
tracer
848-
.spanBuilder(OpenCensusUtils.SPAN_NAME_HTTP_REQUEST_EXECUTE)
849-
.setRecordEvents(OpenCensusUtils.isRecordEvent())
850-
.startSpan();
851838
do {
852-
span.addAnnotation("retry #" + (numRetries - retriesRemaining));
853839
// Cleanup any unneeded response from a previous iteration
854840
if (response != null) {
855841
response.ignore();
@@ -864,10 +850,6 @@ public HttpResponse execute() throws IOException {
864850
}
865851
// build low-level HTTP request
866852
String urlString = url.build();
867-
addSpanAttribute(span, HttpTraceAttributeConstants.HTTP_METHOD, requestMethod);
868-
addSpanAttribute(span, HttpTraceAttributeConstants.HTTP_HOST, url.getHost());
869-
addSpanAttribute(span, HttpTraceAttributeConstants.HTTP_PATH, url.getRawPath());
870-
addSpanAttribute(span, HttpTraceAttributeConstants.HTTP_URL, urlString);
871853

872854
LowLevelHttpRequest lowLevelHttpRequest = transport.buildRequest(requestMethod, urlString);
873855
Logger logger = HttpTransport.LOGGER;
@@ -897,14 +879,11 @@ public HttpResponse execute() throws IOException {
897879
if (!suppressUserAgentSuffix) {
898880
if (originalUserAgent == null) {
899881
headers.setUserAgent(USER_AGENT_SUFFIX);
900-
addSpanAttribute(span, HttpTraceAttributeConstants.HTTP_USER_AGENT, USER_AGENT_SUFFIX);
901882
} else {
902883
String newUserAgent = originalUserAgent + " " + USER_AGENT_SUFFIX;
903884
headers.setUserAgent(newUserAgent);
904-
addSpanAttribute(span, HttpTraceAttributeConstants.HTTP_USER_AGENT, newUserAgent);
905885
}
906886
}
907-
OpenCensusUtils.propagateTracingContext(span, headers);
908887

909888
// headers
910889
HttpHeaders.serializeHeaders(headers, logbuf, curlbuf, logger, lowLevelHttpRequest);
@@ -988,15 +967,8 @@ public HttpResponse execute() throws IOException {
988967
lowLevelHttpRequest.setTimeout(connectTimeout, readTimeout);
989968
lowLevelHttpRequest.setWriteTimeout(writeTimeout);
990969

991-
// switch tracing scope to current span
992-
@SuppressWarnings("MustBeClosedChecker")
993-
Scope ws = tracer.withSpan(span);
994-
OpenCensusUtils.recordSentMessageEvent(span, lowLevelHttpRequest.getContentLength());
995970
try {
996971
LowLevelHttpResponse lowLevelHttpResponse = lowLevelHttpRequest.execute();
997-
if (lowLevelHttpResponse != null) {
998-
OpenCensusUtils.recordReceivedMessageEvent(span, lowLevelHttpResponse.getContentLength());
999-
}
1000972
// Flag used to indicate if an exception is thrown before the response is constructed.
1001973
boolean responseConstructed = false;
1002974
try {
@@ -1014,17 +986,13 @@ public HttpResponse execute() throws IOException {
1014986
if (!retryOnExecuteIOException
1015987
&& (ioExceptionHandler == null
1016988
|| !ioExceptionHandler.handleIOException(this, retryRequest))) {
1017-
// static analysis shows response is always null here
1018-
span.end(OpenCensusUtils.getEndSpanOptions(null));
1019989
throw e;
1020990
}
1021991
// Save the exception in case the retries do not work and we need to re-throw it later.
1022992
executeException = e;
1023993
if (loggable) {
1024994
logger.log(Level.WARNING, "exception thrown while executing request", e);
1025995
}
1026-
} finally {
1027-
ws.close();
1028996
}
1029997

1030998
// Flag used to indicate if an exception is thrown before the response has completed
@@ -1081,8 +1049,6 @@ public HttpResponse execute() throws IOException {
10811049
}
10821050
}
10831051
} while (retryRequest);
1084-
span.end(OpenCensusUtils.getEndSpanOptions(response == null ? null : response.getStatusCode()));
1085-
10861052
if (response == null) {
10871053
// Retries did not help resolve the execute exception, re-throw it.
10881054
throw executeException;
@@ -1197,12 +1163,6 @@ public HttpRequest setSleeper(Sleeper sleeper) {
11971163
return this;
11981164
}
11991165

1200-
private static void addSpanAttribute(Span span, String key, String value) {
1201-
if (value != null) {
1202-
span.putAttribute(key, AttributeValue.stringAttributeValue(value));
1203-
}
1204-
}
1205-
12061166
private static String getVersion() {
12071167
String version = HttpRequest.class.getPackage().getImplementationVersion();
12081168
// in a non-packaged environment (local), there's no implementation version to read

0 commit comments

Comments
 (0)