Skip to content

Commit e726c57

Browse files
chingor13gzsombor
authored andcommitted
feat: remove opencensus (googleapis#834)
* feat: remove beta OpenCensus integration * remove extra references * jsr305 dependency no longer needed after removing opencensus
1 parent 9cdf634 commit e726c57

File tree

7 files changed

+5
-748
lines changed

7 files changed

+5
-748
lines changed

google-http-client-findbugs/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@
7070
<artifactId>annotations</artifactId>
7171
<groupId>com.google.code.findbugs</groupId>
7272
</exclusion>
73+
<exclusion>
74+
<artifactId>jsr305</artifactId>
75+
<groupId>com.google.code.findbugs</groupId>
76+
</exclusion>
7377
</exclusions>
7478
</dependency>
7579
<dependency>

google-http-client/pom.xml

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,6 @@
1818
<build>
1919
<pluginManagement>
2020
<plugins>
21-
<plugin>
22-
<groupId>org.apache.maven.plugins</groupId>
23-
<artifactId>maven-dependency-plugin</artifactId>
24-
<version>3.1.2</version>
25-
<configuration>
26-
<ignoredUnusedDeclaredDependencies>io.opencensus:opencensus-impl</ignoredUnusedDeclaredDependencies>
27-
</configuration>
28-
</plugin>
2921
<plugin>
3022
<groupId>org.codehaus.mojo</groupId>
3123
<artifactId>animal-sniffer-maven-plugin</artifactId>
@@ -131,10 +123,6 @@
131123
<groupId>org.apache.httpcomponents</groupId>
132124
<artifactId>httpcore</artifactId>
133125
</dependency>
134-
<dependency>
135-
<groupId>com.google.code.findbugs</groupId>
136-
<artifactId>jsr305</artifactId>
137-
</dependency>
138126
<dependency>
139127
<groupId>com.google.guava</groupId>
140128
<artifactId>guava</artifactId>
@@ -143,14 +131,6 @@
143131
<groupId>com.google.j2objc</groupId>
144132
<artifactId>j2objc-annotations</artifactId>
145133
</dependency>
146-
<dependency>
147-
<groupId>io.opencensus</groupId>
148-
<artifactId>opencensus-api</artifactId>
149-
</dependency>
150-
<dependency>
151-
<groupId>io.opencensus</groupId>
152-
<artifactId>opencensus-contrib-http-util</artifactId>
153-
</dependency>
154134

155135
<dependency>
156136
<groupId>com.google.guava</groupId>
@@ -167,15 +147,5 @@
167147
<artifactId>truth</artifactId>
168148
<scope>test</scope>
169149
</dependency>
170-
<dependency>
171-
<groupId>io.opencensus</groupId>
172-
<artifactId>opencensus-impl</artifactId>
173-
<scope>test</scope>
174-
</dependency>
175-
<dependency>
176-
<groupId>io.opencensus</groupId>
177-
<artifactId>opencensus-testing</artifactId>
178-
<scope>test</scope>
179-
</dependency>
180150
</dependencies>
181151
</project>

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

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@
2222
import com.google.api.client.util.StreamingContent;
2323
import com.google.api.client.util.StringUtils;
2424
import com.google.common.util.concurrent.ThreadFactoryBuilder;
25-
import io.opencensus.common.Scope;
26-
import io.opencensus.contrib.http.util.HttpTraceAttributeConstants;
27-
import io.opencensus.trace.AttributeValue;
28-
import io.opencensus.trace.Span;
29-
import io.opencensus.trace.Tracer;
3025
import java.io.IOException;
3126
import java.io.InputStream;
3227
import java.util.Properties;
@@ -199,9 +194,6 @@ public final class HttpRequest {
199194
/** Sleeper. */
200195
private Sleeper sleeper = Sleeper.DEFAULT;
201196

202-
/** OpenCensus tracing component. */
203-
private final Tracer tracer = OpenCensusUtils.getTracer();
204-
205197
/**
206198
* Determines whether {@link HttpResponse#getContent()} of this request should return raw input
207199
* stream or not.
@@ -860,13 +852,7 @@ public HttpResponse execute() throws IOException {
860852
Preconditions.checkNotNull(requestMethod);
861853
Preconditions.checkNotNull(url);
862854

863-
Span span =
864-
tracer
865-
.spanBuilder(OpenCensusUtils.SPAN_NAME_HTTP_REQUEST_EXECUTE)
866-
.setRecordEvents(OpenCensusUtils.isRecordEvent())
867-
.startSpan();
868855
do {
869-
span.addAnnotation("retry #" + (numRetries - retriesRemaining));
870856
// Cleanup any unneeded response from a previous iteration
871857
if (response != null) {
872858
response.ignore();
@@ -881,10 +867,6 @@ public HttpResponse execute() throws IOException {
881867
}
882868
// build low-level HTTP request
883869
String urlString = url.build();
884-
addSpanAttribute(span, HttpTraceAttributeConstants.HTTP_METHOD, requestMethod);
885-
addSpanAttribute(span, HttpTraceAttributeConstants.HTTP_HOST, url.getHost());
886-
addSpanAttribute(span, HttpTraceAttributeConstants.HTTP_PATH, url.getRawPath());
887-
addSpanAttribute(span, HttpTraceAttributeConstants.HTTP_URL, urlString);
888870

889871
LowLevelHttpRequest lowLevelHttpRequest = transport.buildRequest(requestMethod, urlString);
890872
Logger logger = HttpTransport.LOGGER;
@@ -914,14 +896,11 @@ public HttpResponse execute() throws IOException {
914896
if (!suppressUserAgentSuffix) {
915897
if (originalUserAgent == null) {
916898
headers.setUserAgent(USER_AGENT_SUFFIX);
917-
addSpanAttribute(span, HttpTraceAttributeConstants.HTTP_USER_AGENT, USER_AGENT_SUFFIX);
918899
} else {
919900
String newUserAgent = originalUserAgent + " " + USER_AGENT_SUFFIX;
920901
headers.setUserAgent(newUserAgent);
921-
addSpanAttribute(span, HttpTraceAttributeConstants.HTTP_USER_AGENT, newUserAgent);
922902
}
923903
}
924-
OpenCensusUtils.propagateTracingContext(span, headers);
925904

926905
// headers
927906
HttpHeaders.serializeHeaders(headers, logbuf, curlbuf, logger, lowLevelHttpRequest);
@@ -1004,18 +983,8 @@ public HttpResponse execute() throws IOException {
1004983
lowLevelHttpRequest.setTimeout(connectTimeout, readTimeout);
1005984
lowLevelHttpRequest.setWriteTimeout(writeTimeout);
1006985

1007-
// switch tracing scope to current span
1008-
@SuppressWarnings("MustBeClosedChecker")
1009-
Scope ws = tracer.withSpan(span);
1010-
OpenCensusUtils.recordSentMessageEvent(span, lowLevelHttpRequest.getContentLength());
1011986
try {
1012987
LowLevelHttpResponse lowLevelHttpResponse = lowLevelHttpRequest.execute();
1013-
if (lowLevelHttpResponse != null) {
1014-
OpenCensusUtils.recordReceivedMessageEvent(span, lowLevelHttpResponse.getContentLength());
1015-
span.putAttribute(
1016-
HttpTraceAttributeConstants.HTTP_STATUS_CODE,
1017-
AttributeValue.longAttributeValue(lowLevelHttpResponse.getStatusCode()));
1018-
}
1019988
// Flag used to indicate if an exception is thrown before the response is constructed.
1020989
boolean responseConstructed = false;
1021990
try {
@@ -1033,17 +1002,13 @@ public HttpResponse execute() throws IOException {
10331002
if (!retryOnExecuteIOException
10341003
&& (ioExceptionHandler == null
10351004
|| !ioExceptionHandler.handleIOException(this, retryRequest))) {
1036-
// static analysis shows response is always null here
1037-
span.end(OpenCensusUtils.getEndSpanOptions(null));
10381005
throw e;
10391006
}
10401007
// Save the exception in case the retries do not work and we need to re-throw it later.
10411008
executeException = e;
10421009
if (loggable) {
10431010
logger.log(Level.WARNING, "exception thrown while executing request", e);
10441011
}
1045-
} finally {
1046-
ws.close();
10471012
}
10481013

10491014
// Flag used to indicate if an exception is thrown before the response has completed
@@ -1100,8 +1065,6 @@ public HttpResponse execute() throws IOException {
11001065
}
11011066
}
11021067
} while (retryRequest);
1103-
span.end(OpenCensusUtils.getEndSpanOptions(response == null ? null : response.getStatusCode()));
1104-
11051068
if (response == null) {
11061069
// Retries did not help resolve the execute exception, re-throw it.
11071070
throw executeException;
@@ -1218,12 +1181,6 @@ public HttpRequest setSleeper(Sleeper sleeper) {
12181181
return this;
12191182
}
12201183

1221-
private static void addSpanAttribute(Span span, String key, String value) {
1222-
if (value != null) {
1223-
span.putAttribute(key, AttributeValue.stringAttributeValue(value));
1224-
}
1225-
}
1226-
12271184
private static String getVersion() {
12281185
// attempt to read the library's version from a properties file generated during the build
12291186
// this value should be read and cached for later use

0 commit comments

Comments
 (0)