Skip to content

Commit

Permalink
Update instrumentation version (#489)
Browse files Browse the repository at this point in the history
* update instrumentation version

* remove unneeded extractor

* spotless
  • Loading branch information
breedx-splk authored Mar 7, 2023
1 parent 51baaa9 commit 88ef1b3
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 23 deletions.
2 changes: 1 addition & 1 deletion splunk-otel-android-volley/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ android {

val otelVersion = "1.23.1"
val otelAlphaVersion = "$otelVersion-alpha"
val otelInstrumentationAlphaVersion = "1.23.0-alpha"
val otelInstrumentationAlphaVersion = "1.24.0-alpha-SNAPSHOT"

dependencies {
implementation("androidx.appcompat:appcompat:1.6.1")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@ enum VolleyHttpClientAttributesGetter
INSTANCE;

@Override
public String url(RequestWrapper requestWrapper) {
public String getUrl(RequestWrapper requestWrapper) {
return requestWrapper.getRequest().getUrl();
}

@Nullable
@Override
public String flavor(RequestWrapper requestWrapper, @Nullable HttpResponse response) {
public String getFlavor(RequestWrapper requestWrapper, @Nullable HttpResponse response) {
return null;
}

@Nullable
@Override
public String method(RequestWrapper requestWrapper) {
public String getMethod(RequestWrapper requestWrapper) {
Request<?> request = requestWrapper.getRequest();
switch (request.getMethod()) {
case Request.Method.GET:
Expand All @@ -70,7 +70,7 @@ public String method(RequestWrapper requestWrapper) {
}

@Override
public List<String> requestHeader(RequestWrapper requestWrapper, String name) {
public List<String> getRequestHeader(RequestWrapper requestWrapper, String name) {
Request<?> request = requestWrapper.getRequest();
try {
Map<String, String> headers = request.getHeaders();
Expand All @@ -95,13 +95,13 @@ private List<String> findCaseInsensitive(String name, Map<String, String> header
}

@Override
public Integer statusCode(
public Integer getStatusCode(
RequestWrapper requestWrapper, HttpResponse response, @Nullable Throwable error) {
return response.getStatusCode();
}

@Override
public List<String> responseHeader(
public List<String> getResponseHeader(
RequestWrapper requestWrapper, @Nullable HttpResponse response, String name) {
if (response == null) {
return emptyList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@ enum VolleyNetClientAttributesGetter
INSTANCE;

@Override
public String transport(RequestWrapper requestWrapper, @Nullable HttpResponse httpResponse) {
public String getTransport(RequestWrapper requestWrapper, @Nullable HttpResponse httpResponse) {
return SemanticAttributes.NetTransportValues.IP_TCP;
}

@Nullable
@Override
public String peerName(RequestWrapper requestWrapper) {
public String getPeerName(RequestWrapper requestWrapper) {
return UrlParser.getHost(requestWrapper.getRequest().getUrl());
}

@Nullable
@Override
public Integer peerPort(RequestWrapper requestWrapper) {
public Integer getPeerPort(RequestWrapper requestWrapper) {
return UrlParser.getPort(requestWrapper.getRequest().getUrl());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientAttributesExtractorBuilder;
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor;
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor;
import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor;
import java.util.ArrayList;
import java.util.List;

Expand All @@ -41,7 +40,8 @@ public final class VolleyTracingBuilder {
private final HttpClientAttributesExtractorBuilder<RequestWrapper, HttpResponse>
httpClientAttributesExtractorBuilder =
HttpClientAttributesExtractor.builder(
VolleyHttpClientAttributesGetter.INSTANCE);
VolleyHttpClientAttributesGetter.INSTANCE,
VolleyNetClientAttributesGetter.INSTANCE);

VolleyTracingBuilder(OpenTelemetry openTelemetry) {
this.openTelemetry = openTelemetry;
Expand Down Expand Up @@ -83,8 +83,6 @@ public VolleyTracingBuilder setCapturedResponseHeaders(List<String> responseHead
public VolleyTracing build() {
VolleyHttpClientAttributesGetter httpAttributesGetter =
VolleyHttpClientAttributesGetter.INSTANCE;
VolleyNetClientAttributesGetter netAttributesGetter =
VolleyNetClientAttributesGetter.INSTANCE;
SpanStatusExtractor<RequestWrapper, HttpResponse> spanStatusExtractor =
HttpSpanStatusExtractor.create(httpAttributesGetter);
SpanNameExtractor<RequestWrapper> spanNameExtractor =
Expand All @@ -95,8 +93,6 @@ public VolleyTracing build() {
openTelemetry, INSTRUMENTATION_NAME, spanNameExtractor)
.setSpanStatusExtractor(spanStatusExtractor)
.addAttributesExtractor(httpClientAttributesExtractorBuilder.build())
.addAttributesExtractor(
NetClientAttributesExtractor.create(netAttributesGetter))
.addAttributesExtractor(
new VolleyResponseAttributesExtractor(
new ServerTimingHeaderParser()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ public void testRequestHeader() throws Exception {

VolleyHttpClientAttributesGetter testClass = VolleyHttpClientAttributesGetter.INSTANCE;

List<String> values = testClass.requestHeader(requestWrapper, "content-type");
List<String> values = testClass.getRequestHeader(requestWrapper, "content-type");
assertThat(values).containsExactly("application/json");

List<String> fooValues = testClass.requestHeader(requestWrapper, "FOO");
List<String> fooValues = testClass.getRequestHeader(requestWrapper, "FOO");
assertThat(fooValues).containsExactly("bar", "baz", "beep");
List<String> ayeValues = testClass.requestHeader(requestWrapper, "aYe");
List<String> ayeValues = testClass.getRequestHeader(requestWrapper, "aYe");
assertThat(ayeValues).contains("b", "beeee");
}

Expand All @@ -81,17 +81,17 @@ public void testResponseHeader() {

VolleyHttpClientAttributesGetter testClass = VolleyHttpClientAttributesGetter.INSTANCE;

List<String> values = testClass.responseHeader(request, response, "content-type");
List<String> values = testClass.getResponseHeader(request, response, "content-type");
assertThat(values).containsExactly("application/json");

List<String> fooValues = testClass.responseHeader(request, response, "FOO");
List<String> fooValues = testClass.getResponseHeader(request, response, "FOO");
assertThat(fooValues).containsExactly("bar", "baz");
}

@Test
public void testNullResponse() {
VolleyHttpClientAttributesGetter testClass = VolleyHttpClientAttributesGetter.INSTANCE;
List<String> values = testClass.responseHeader(null, null, "content-type");
List<String> values = testClass.getResponseHeader(null, null, "content-type");
assertThat(values).isEmpty();
}
}
2 changes: 1 addition & 1 deletion splunk-otel-android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ android {

val otelVersion = "1.23.1"
val otelAlphaVersion = "$otelVersion-alpha"
val otelInstrumentationAlphaVersion = "1.23.0-alpha"
val otelInstrumentationAlphaVersion = "1.24.0-alpha-SNAPSHOT"

dependencies {
implementation("androidx.appcompat:appcompat:1.6.1")
Expand Down

0 comments on commit 88ef1b3

Please sign in to comment.