Skip to content

Commit

Permalink
Runs spotless
Browse files Browse the repository at this point in the history
  • Loading branch information
anuragagarwal561994 committed Jan 28, 2023
1 parent b91a928 commit 7760022
Show file tree
Hide file tree
Showing 25 changed files with 138 additions and 43 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.javaagent.instrumentation.apachehttpasyncclient;

import static io.opentelemetry.javaagent.instrumentation.apachehttpclient.commons.BytesTransferMetrics.createOrGetWithParentContext;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.javaagent.instrumentation.apachehttpasyncclient;

import static io.opentelemetry.javaagent.instrumentation.apachehttpclient.commons.BytesTransferMetrics.createOrGetWithParentContext;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.javaagent.instrumentation.apachehttpasyncclient;

import static io.opentelemetry.javaagent.instrumentation.apachehttpasyncclient.ApacheHttpAsyncClientSingletons.helper;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.javaagent.instrumentation.apachehttpasyncclient;

import static io.opentelemetry.javaagent.instrumentation.apachehttpasyncclient.ApacheHttpAsyncClientSingletons.helper;
Expand Down Expand Up @@ -60,9 +65,7 @@ public HttpRequest generateRequest() throws IOException, HttpException {

@Override
public void produceContent(ContentEncoder encoder, IOControl ioctrl) throws IOException {
delegate.produceContent(
new WrappedContentEncoder(parentContext, encoder),
ioctrl);
delegate.produceContent(new WrappedContentEncoder(parentContext, encoder), ioctrl);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.javaagent.instrumentation.apachehttpasyncclient;

import io.opentelemetry.context.Context;
Expand Down Expand Up @@ -26,9 +31,7 @@ public void responseReceived(HttpResponse httpResponse) throws IOException, Http
@Override
public void consumeContent(ContentDecoder contentDecoder, IOControl ioControl)
throws IOException {
delegate.consumeContent(
new WrappedContentDecoder(parentContext,
contentDecoder), ioControl);
delegate.consumeContent(new WrappedContentDecoder(parentContext, contentDecoder), ioControl);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.javaagent.instrumentation.apachehttpclient.v5_0;

import io.opentelemetry.javaagent.instrumentation.apachehttpclient.commons.OtelHttpContextManager;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.javaagent.instrumentation.apachehttpclient.v5_0;

import io.opentelemetry.context.Context;
Expand All @@ -6,7 +11,8 @@
import org.apache.hc.core5.http.HttpRequest;
import org.apache.hc.core5.http.HttpResponse;

public final class ApacheHttpClientInernalEntityStorage extends OtelHttpInternalEntityStorage<HttpRequest, HttpResponse> {
public final class ApacheHttpClientInernalEntityStorage
extends OtelHttpInternalEntityStorage<HttpRequest, HttpResponse> {
private static final ApacheHttpClientInernalEntityStorage INSTANCE;

static {
Expand All @@ -16,8 +22,7 @@ public final class ApacheHttpClientInernalEntityStorage extends OtelHttpInternal
private ApacheHttpClientInernalEntityStorage() {
super(
VirtualField.find(Context.class, HttpRequest.class),
VirtualField.find(Context.class, HttpResponse.class)
);
VirtualField.find(Context.class, HttpResponse.class));
}

public static OtelHttpInternalEntityStorage<HttpRequest, HttpResponse> storage() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
public final class ApacheHttpClientInstrumentationHelper {
private final Instrumenter<OtelHttpRequest, OtelHttpResponse> instrumenter;

public ApacheHttpClientInstrumentationHelper(Instrumenter<OtelHttpRequest, OtelHttpResponse> instrumenter) {
public ApacheHttpClientInstrumentationHelper(
Instrumenter<OtelHttpRequest, OtelHttpResponse> instrumenter) {
this.instrumenter = instrumenter;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.javaagent.instrumentation.apachehttpclient.v5_0;

import io.opentelemetry.javaagent.instrumentation.apachehttpclient.commons.OtelHttpResponse;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.javaagent.instrumentation.apachehttpclient.v5_0;

import static io.opentelemetry.javaagent.instrumentation.apachehttpclient.commons.BytesTransferMetrics.createOrGetWithParentContext;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.javaagent.instrumentation.apachehttpclient.v5_0;

import static io.opentelemetry.javaagent.instrumentation.apachehttpclient.v5_0.ApacheHttpClientContextManager.httpContextManager;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.javaagent.instrumentation.apachehttpclient.v5_0;

import static io.opentelemetry.javaagent.instrumentation.apachehttpclient.v5_0.ApacheHttpClientContextManager.httpContextManager;
Expand Down Expand Up @@ -26,8 +31,7 @@ public WrappedRequestChannel(
}

@Override
public void sendRequest(
HttpRequest request, EntityDetails entityDetails, HttpContext httpContext)
public void sendRequest(HttpRequest request, EntityDetails entityDetails, HttpContext httpContext)
throws HttpException, IOException {
ApacheHttpClientRequest otelRequest = new ApacheHttpClientRequest(parentContext, request);
Context context = helper().startInstrumentation(parentContext, request, otelRequest);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.javaagent.instrumentation.apachehttpclient.v5_0;

import io.opentelemetry.context.Context;
Expand All @@ -14,8 +19,7 @@ public final class WrappedRequestProducer implements AsyncRequestProducer {
private final WrappedFutureCallback<?> callback;

public WrappedRequestProducer(
Context parentContext, AsyncRequestProducer delegate,
WrappedFutureCallback<?> callback) {
Context parentContext, AsyncRequestProducer delegate, WrappedFutureCallback<?> callback) {
this.parentContext = parentContext;
this.delegate = delegate;
this.callback = callback;
Expand All @@ -30,8 +34,7 @@ public void failed(Exception ex) {
public void sendRequest(RequestChannel channel, HttpContext context)
throws HttpException, IOException {
RequestChannel requestChannel;
requestChannel = new WrappedRequestChannel(channel,
parentContext, callback);
requestChannel = new WrappedRequestChannel(channel, parentContext, callback);
delegate.sendRequest(requestChannel, context);
}

Expand All @@ -47,8 +50,7 @@ public int available() {

@Override
public void produce(DataStreamChannel channel) throws IOException {
delegate.produce(
new WrappedDataStreamChannel(parentContext, channel));
delegate.produce(new WrappedDataStreamChannel(parentContext, channel));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.javaagent.instrumentation.apachehttpclient.v5_0;

import static io.opentelemetry.javaagent.instrumentation.apachehttpclient.commons.BytesTransferMetrics.createOrGetWithParentContext;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.javaagent.instrumentation.apachehttpclient.v4_0.commons;

import io.opentelemetry.javaagent.instrumentation.apachehttpclient.commons.OtelHttpContextManager;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.javaagent.instrumentation.apachehttpclient.v4_0.commons;

import io.opentelemetry.context.Context;
Expand All @@ -6,7 +11,8 @@
import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;

public final class ApacheHttpClientInernalEntityStorage extends OtelHttpInternalEntityStorage<HttpRequest, HttpResponse> {
public final class ApacheHttpClientInernalEntityStorage
extends OtelHttpInternalEntityStorage<HttpRequest, HttpResponse> {
private static final ApacheHttpClientInernalEntityStorage INSTANCE;

static {
Expand All @@ -16,8 +22,7 @@ public final class ApacheHttpClientInernalEntityStorage extends OtelHttpInternal
private ApacheHttpClientInernalEntityStorage() {
super(
VirtualField.find(Context.class, HttpRequest.class),
VirtualField.find(Context.class, HttpResponse.class)
);
VirtualField.find(Context.class, HttpResponse.class));
}

public static OtelHttpInternalEntityStorage<HttpRequest, HttpResponse> storage() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ private static OtelHttpRequest getFinalRequest(ApacheHttpClientRequest request,
return request;
}

private static <T> OtelHttpResponse getFinalResponse(T result, Context context) {
private static <T> OtelHttpResponse getFinalResponse(T result, Context context) {
HttpResponse internalResponse = storage().getInternalResponse(context);
if (internalResponse != null) {
return new ApacheHttpClientResponse(internalResponse);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.javaagent.instrumentation.apachehttpclient.v4_0.commons;

import io.opentelemetry.javaagent.instrumentation.apachehttpclient.commons.OtelHttpResponse;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
import java.util.List;
import javax.annotation.Nullable;

public final class ApacheHttpClientHttpAttributesGetter implements HttpClientAttributesGetter<OtelHttpRequest, OtelHttpResponse> {
public final class ApacheHttpClientHttpAttributesGetter
implements HttpClientAttributesGetter<OtelHttpRequest, OtelHttpResponse> {
@Override
public String getMethod(OtelHttpRequest request) {
return request.getMethod();
Expand All @@ -26,7 +27,8 @@ public List<String> getRequestHeader(OtelHttpRequest request, String name) {
}

@Override
public Integer getStatusCode(OtelHttpRequest request, OtelHttpResponse response, @Nullable Throwable error) {
public Integer getStatusCode(
OtelHttpRequest request, OtelHttpResponse response, @Nullable Throwable error) {
return response.statusCode();
}

Expand All @@ -37,14 +39,15 @@ public String getFlavor(OtelHttpRequest request, @Nullable OtelHttpResponse resp
if (flavor == null && response != null) {
String responseFlavour = response.getFlavour();
if (responseFlavour != null) {
flavor = responseFlavour;
flavor = responseFlavour;
}
}
return flavor;
}

@Override
public List<String> getResponseHeader(OtelHttpRequest request, OtelHttpResponse response, String name) {
public List<String> getResponseHeader(
OtelHttpRequest request, OtelHttpResponse response, String name) {
return response.getHeader(name);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@ public static Instrumenter<OtelHttpRequest, OtelHttpResponse> create(String inst
netAttributesGetter = new ApacheHttpClientNetAttributesGetter();

return Instrumenter.<OtelHttpRequest, OtelHttpResponse>builder(
GlobalOpenTelemetry.get(),
instrumentationName,
HttpSpanNameExtractor.create(httpAttributesGetter))
.setSpanStatusExtractor(HttpSpanStatusExtractor.create(httpAttributesGetter))
.addAttributesExtractor(
HttpClientAttributesExtractor.builder(httpAttributesGetter, netAttributesGetter)
.setCapturedRequestHeaders(CommonConfig.get().getClientRequestHeaders())
.setCapturedResponseHeaders(CommonConfig.get().getClientResponseHeaders())
.build())
.addAttributesExtractor(
PeerServiceAttributesExtractor.create(
netAttributesGetter, CommonConfig.get().getPeerServiceMapping()))
.addAttributesExtractor(new ApacheHttpClientContentLengthAttributesGetter())
.addOperationMetrics(HttpClientMetrics.get())
.buildClientInstrumenter(new HttpHeaderSetter());
GlobalOpenTelemetry.get(),
instrumentationName,
HttpSpanNameExtractor.create(httpAttributesGetter))
.setSpanStatusExtractor(HttpSpanStatusExtractor.create(httpAttributesGetter))
.addAttributesExtractor(
HttpClientAttributesExtractor.builder(httpAttributesGetter, netAttributesGetter)
.setCapturedRequestHeaders(CommonConfig.get().getClientRequestHeaders())
.setCapturedResponseHeaders(CommonConfig.get().getClientResponseHeaders())
.build())
.addAttributesExtractor(
PeerServiceAttributesExtractor.create(
netAttributesGetter, CommonConfig.get().getPeerServiceMapping()))
.addAttributesExtractor(new ApacheHttpClientContentLengthAttributesGetter())
.addOperationMetrics(HttpClientMetrics.get())
.buildClientInstrumenter(new HttpHeaderSetter());
}

private ApacheHttpClientInstrumenter() {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.javaagent.instrumentation.apachehttpclient.commons;

import io.opentelemetry.context.Context;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.javaagent.instrumentation.apachehttpclient.commons;

import static io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge.currentContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ public abstract class OtelHttpInternalEntityStorage<REQ, RES> {
private final VirtualField<Context, RES> responseStorage;

protected OtelHttpInternalEntityStorage(
VirtualField<Context, REQ> requestStorage,
VirtualField<Context, RES> responseStorage) {
VirtualField<Context, REQ> requestStorage, VirtualField<Context, RES> responseStorage) {
this.requestStorage = requestStorage;
this.responseStorage = responseStorage;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.javaagent.instrumentation.apachehttpclient.commons;

import java.net.InetSocketAddress;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.javaagent.instrumentation.apachehttpclient.commons;

import java.util.List;
Expand Down

0 comments on commit 7760022

Please sign in to comment.