Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
import org.jboss.netty.handler.codec.http.HttpRequest;

@AutoValue
public abstract class HttpRequestAndChannel {
public abstract class NettyRequest {

public static HttpRequestAndChannel create(HttpRequest request, Channel channel) {
return new AutoValue_HttpRequestAndChannel(request, channel);
public static NettyRequest create(HttpRequest request, Channel channel) {
return new AutoValue_NettyRequest(request, channel);
}

public abstract HttpRequest request();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
import io.opentelemetry.context.Context;
import io.opentelemetry.context.Scope;
import io.opentelemetry.instrumentation.api.util.VirtualField;
import io.opentelemetry.javaagent.instrumentation.netty.v3_8.HttpRequestAndChannel;
import io.opentelemetry.javaagent.instrumentation.netty.v3_8.NettyConnectionContext;
import io.opentelemetry.javaagent.instrumentation.netty.v3_8.NettyRequest;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.channel.MessageEvent;
Expand Down Expand Up @@ -42,8 +42,7 @@ public void writeRequested(ChannelHandlerContext ctx, MessageEvent event) throws
parentContext = Context.current();
}

HttpRequestAndChannel request =
HttpRequestAndChannel.create((HttpRequest) message, ctx.getChannel());
NettyRequest request = NettyRequest.create((HttpRequest) message, ctx.getChannel());
if (!instrumenter().shouldStart(parentContext, request)) {
super.writeRequested(ctx, event);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
package io.opentelemetry.javaagent.instrumentation.netty.v3_8.client;

import io.opentelemetry.context.propagation.TextMapSetter;
import io.opentelemetry.javaagent.instrumentation.netty.v3_8.HttpRequestAndChannel;
import io.opentelemetry.javaagent.instrumentation.netty.v3_8.NettyRequest;
import javax.annotation.Nullable;

enum HttpRequestHeadersSetter implements TextMapSetter<HttpRequestAndChannel> {
enum HttpRequestHeadersSetter implements TextMapSetter<NettyRequest> {
INSTANCE;

@Override
public void set(@Nullable HttpRequestAndChannel carrier, String key, String value) {
public void set(@Nullable NettyRequest carrier, String key, String value) {
carrier.request().headers().set(key, value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@

import com.google.auto.value.AutoValue;
import io.opentelemetry.context.Context;
import io.opentelemetry.javaagent.instrumentation.netty.v3_8.HttpRequestAndChannel;
import io.opentelemetry.javaagent.instrumentation.netty.v3_8.NettyRequest;
import javax.annotation.Nullable;

@AutoValue
abstract class NettyClientRequestAndContexts {

public static NettyClientRequestAndContexts create(
@Nullable Context parentContext, Context context, HttpRequestAndChannel request) {
@Nullable Context parentContext, Context context, NettyRequest request) {
return new AutoValue_NettyClientRequestAndContexts(parentContext, context, request);
}

abstract Context parentContext();

abstract Context context();

abstract HttpRequestAndChannel request();
abstract NettyRequest request();
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import io.opentelemetry.instrumentation.netty.common.internal.NettyErrorHolder;
import io.opentelemetry.javaagent.bootstrap.internal.AgentCommonConfig;
import io.opentelemetry.javaagent.bootstrap.internal.JavaagentHttpClientInstrumenters;
import io.opentelemetry.javaagent.instrumentation.netty.v3_8.HttpRequestAndChannel;
import io.opentelemetry.javaagent.instrumentation.netty.v3_8.NettyRequest;
import io.opentelemetry.semconv.SchemaUrls;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.handler.codec.http.HttpResponse;
Expand All @@ -23,7 +23,7 @@ public final class NettyClientSingletons {

private static final String INSTRUMENTATION_NAME = "io.opentelemetry.netty-3.8";

private static final Instrumenter<HttpRequestAndChannel, HttpResponse> INSTRUMENTER;
private static final Instrumenter<NettyRequest, HttpResponse> INSTRUMENTER;
private static final Instrumenter<NettyConnectionRequest, Channel> CONNECTION_INSTRUMENTER;

static {
Expand All @@ -50,7 +50,7 @@ public final class NettyClientSingletons {
.buildInstrumenter(SpanKindExtractor.alwaysClient());
}

public static Instrumenter<HttpRequestAndChannel, HttpResponse> instrumenter() {
public static Instrumenter<NettyRequest, HttpResponse> instrumenter() {
return INSTRUMENTER;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import static io.opentelemetry.javaagent.instrumentation.netty.v3_8.util.HttpSchemeUtil.getScheme;

import io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesGetter;
import io.opentelemetry.javaagent.instrumentation.netty.v3_8.HttpRequestAndChannel;
import io.opentelemetry.javaagent.instrumentation.netty.v3_8.NettyRequest;
import io.opentelemetry.javaagent.instrumentation.netty.v3_8.util.ChannelUtil;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
Expand All @@ -20,11 +20,11 @@
import org.jboss.netty.handler.codec.http.HttpVersion;

final class NettyHttpClientAttributesGetter
implements HttpClientAttributesGetter<HttpRequestAndChannel, HttpResponse> {
implements HttpClientAttributesGetter<NettyRequest, HttpResponse> {

@Override
@Nullable
public String getUrlFull(HttpRequestAndChannel requestAndChannel) {
public String getUrlFull(NettyRequest requestAndChannel) {
try {
String hostHeader = getHost(requestAndChannel);
String target = requestAndChannel.request().getUri();
Expand All @@ -38,48 +38,48 @@ public String getUrlFull(HttpRequestAndChannel requestAndChannel) {
}
}

private String getHost(HttpRequestAndChannel requestAndChannel) {
private String getHost(NettyRequest requestAndChannel) {
List<String> values = getHttpRequestHeader(requestAndChannel, "host");
return values.isEmpty() ? null : values.get(0);
}

@Override
public String getHttpRequestMethod(HttpRequestAndChannel requestAndChannel) {
public String getHttpRequestMethod(NettyRequest requestAndChannel) {
return requestAndChannel.request().getMethod().getName();
}

@Override
public List<String> getHttpRequestHeader(HttpRequestAndChannel requestAndChannel, String name) {
public List<String> getHttpRequestHeader(NettyRequest requestAndChannel, String name) {
return requestAndChannel.request().headers().getAll(name);
}

@Override
public Integer getHttpResponseStatusCode(
HttpRequestAndChannel requestAndChannel, HttpResponse response, @Nullable Throwable error) {
NettyRequest requestAndChannel, HttpResponse response, @Nullable Throwable error) {
return response.getStatus().getCode();
}

@Override
public List<String> getHttpResponseHeader(
HttpRequestAndChannel requestAndChannel, HttpResponse response, String name) {
NettyRequest requestAndChannel, HttpResponse response, String name) {
return response.headers().getAll(name);
}

@Override
public String getNetworkTransport(
HttpRequestAndChannel requestAndChannel, @Nullable HttpResponse response) {
NettyRequest requestAndChannel, @Nullable HttpResponse response) {
return ChannelUtil.getNetworkTransport(requestAndChannel.channel());
}

@Override
public String getNetworkProtocolName(
HttpRequestAndChannel requestAndChannel, @Nullable HttpResponse httpResponse) {
NettyRequest requestAndChannel, @Nullable HttpResponse httpResponse) {
return requestAndChannel.request().getProtocolVersion().getProtocolName();
}

@Override
public String getNetworkProtocolVersion(
HttpRequestAndChannel requestAndChannel, @Nullable HttpResponse httpResponse) {
NettyRequest requestAndChannel, @Nullable HttpResponse httpResponse) {
HttpVersion version = requestAndChannel.request().getProtocolVersion();
if (version.getMinorVersion() == 0) {
return Integer.toString(version.getMajorVersion());
Expand All @@ -89,20 +89,20 @@ public String getNetworkProtocolVersion(

@Nullable
@Override
public String getServerAddress(HttpRequestAndChannel requestAndChannel) {
public String getServerAddress(NettyRequest requestAndChannel) {
return null;
}

@Nullable
@Override
public Integer getServerPort(HttpRequestAndChannel requestAndChannel) {
public Integer getServerPort(NettyRequest requestAndChannel) {
return null;
}

@Override
@Nullable
public InetSocketAddress getNetworkPeerInetSocketAddress(
HttpRequestAndChannel requestAndChannel, @Nullable HttpResponse response) {
NettyRequest requestAndChannel, @Nullable HttpResponse response) {
SocketAddress address = requestAndChannel.channel().getRemoteAddress();
if (address instanceof InetSocketAddress) {
return (InetSocketAddress) address;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import io.opentelemetry.context.Context;
import io.opentelemetry.context.Scope;
import io.opentelemetry.instrumentation.api.util.VirtualField;
import io.opentelemetry.javaagent.instrumentation.netty.v3_8.HttpRequestAndChannel;
import io.opentelemetry.javaagent.instrumentation.netty.v3_8.NettyRequest;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.channel.MessageEvent;
Expand Down Expand Up @@ -38,8 +38,7 @@ public void messageReceived(ChannelHandlerContext ctx, MessageEvent event) throw
}

Context parentContext = Context.current();
HttpRequestAndChannel request =
HttpRequestAndChannel.create((HttpRequest) message, ctx.getChannel());
NettyRequest request = NettyRequest.create((HttpRequest) message, ctx.getChannel());
if (!instrumenter().shouldStart(parentContext, request)) {
super.messageReceived(ctx, event);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import io.opentelemetry.instrumentation.api.util.VirtualField;
import io.opentelemetry.instrumentation.netty.common.internal.NettyErrorHolder;
import io.opentelemetry.javaagent.bootstrap.http.HttpServerResponseCustomizerHolder;
import io.opentelemetry.javaagent.instrumentation.netty.v3_8.HttpRequestAndChannel;
import io.opentelemetry.javaagent.instrumentation.netty.v3_8.NettyRequest;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.channel.MessageEvent;
Expand All @@ -34,7 +34,7 @@ public void writeRequested(ChannelHandlerContext ctx, MessageEvent msg) throws E
}

Context context = requestAndContext.context();
HttpRequestAndChannel request = requestAndContext.request();
NettyRequest request = requestAndContext.request();
HttpResponse response = (HttpResponse) msg.getMessage();
customizeResponse(context, response);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,26 @@
package io.opentelemetry.javaagent.instrumentation.netty.v3_8.server;

import io.opentelemetry.context.propagation.TextMapGetter;
import io.opentelemetry.javaagent.instrumentation.netty.v3_8.HttpRequestAndChannel;
import io.opentelemetry.javaagent.instrumentation.netty.v3_8.NettyRequest;
import java.util.Iterator;
import javax.annotation.Nullable;

enum NettyHeadersGetter implements TextMapGetter<HttpRequestAndChannel> {
enum NettyHeadersGetter implements TextMapGetter<NettyRequest> {
INSTANCE;

@Override
public Iterable<String> keys(HttpRequestAndChannel requestAndChannel) {
public Iterable<String> keys(NettyRequest requestAndChannel) {
return requestAndChannel.request().headers().names();
}

@Nullable
@Override
public String get(@Nullable HttpRequestAndChannel requestAndChannel, String s) {
public String get(@Nullable NettyRequest requestAndChannel, String s) {
return requestAndChannel.request().headers().get(s);
}

@Override
public Iterator<String> getAll(@Nullable HttpRequestAndChannel carrier, String key) {
public Iterator<String> getAll(@Nullable NettyRequest carrier, String key) {
return carrier.request().headers().getAll(key).iterator();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
package io.opentelemetry.javaagent.instrumentation.netty.v3_8.server;

import io.opentelemetry.instrumentation.api.semconv.http.HttpServerAttributesGetter;
import io.opentelemetry.javaagent.instrumentation.netty.v3_8.HttpRequestAndChannel;
import io.opentelemetry.javaagent.instrumentation.netty.v3_8.NettyRequest;
import io.opentelemetry.javaagent.instrumentation.netty.v3_8.util.ChannelUtil;
import io.opentelemetry.javaagent.instrumentation.netty.v3_8.util.HttpSchemeUtil;
import java.net.InetSocketAddress;
Expand All @@ -17,64 +17,63 @@
import org.jboss.netty.handler.codec.http.HttpVersion;

final class NettyHttpServerAttributesGetter
implements HttpServerAttributesGetter<HttpRequestAndChannel, HttpResponse> {
implements HttpServerAttributesGetter<NettyRequest, HttpResponse> {

@Override
public String getHttpRequestMethod(HttpRequestAndChannel requestAndChannel) {
public String getHttpRequestMethod(NettyRequest requestAndChannel) {
return requestAndChannel.request().getMethod().getName();
}

@Override
public List<String> getHttpRequestHeader(HttpRequestAndChannel requestAndChannel, String name) {
public List<String> getHttpRequestHeader(NettyRequest requestAndChannel, String name) {
return requestAndChannel.request().headers().getAll(name);
}

@Override
public Integer getHttpResponseStatusCode(
HttpRequestAndChannel requestAndChannel, HttpResponse response, @Nullable Throwable error) {
NettyRequest requestAndChannel, HttpResponse response, @Nullable Throwable error) {
return response.getStatus().getCode();
}

@Override
public List<String> getHttpResponseHeader(
HttpRequestAndChannel requestAndChannel, HttpResponse response, String name) {
NettyRequest requestAndChannel, HttpResponse response, String name) {
return response.headers().getAll(name);
}

@Override
public String getUrlScheme(HttpRequestAndChannel requestAndChannel) {
public String getUrlScheme(NettyRequest requestAndChannel) {
return HttpSchemeUtil.getScheme(requestAndChannel);
}

@Override
public String getUrlPath(HttpRequestAndChannel requestAndChannel) {
public String getUrlPath(NettyRequest requestAndChannel) {
String fullPath = requestAndChannel.request().getUri();
int separatorPos = fullPath.indexOf('?');
return separatorPos == -1 ? fullPath : fullPath.substring(0, separatorPos);
}

@Override
public String getUrlQuery(HttpRequestAndChannel requestAndChannel) {
public String getUrlQuery(NettyRequest requestAndChannel) {
String fullPath = requestAndChannel.request().getUri();
int separatorPos = fullPath.indexOf('?');
return separatorPos == -1 ? null : fullPath.substring(separatorPos + 1);
}

@Override
public String getNetworkTransport(
HttpRequestAndChannel requestAndChannel, HttpResponse response) {
public String getNetworkTransport(NettyRequest requestAndChannel, HttpResponse response) {
return ChannelUtil.getNetworkTransport(requestAndChannel.channel());
}

@Override
public String getNetworkProtocolName(
HttpRequestAndChannel requestAndChannel, @Nullable HttpResponse response) {
NettyRequest requestAndChannel, @Nullable HttpResponse response) {
return requestAndChannel.request().getProtocolVersion().getProtocolName();
}

@Override
public String getNetworkProtocolVersion(
HttpRequestAndChannel requestAndChannel, @Nullable HttpResponse response) {
NettyRequest requestAndChannel, @Nullable HttpResponse response) {
HttpVersion version = requestAndChannel.request().getProtocolVersion();
if (version.getMinorVersion() == 0) {
return Integer.toString(version.getMajorVersion());
Expand All @@ -85,7 +84,7 @@ public String getNetworkProtocolVersion(
@Override
@Nullable
public InetSocketAddress getNetworkPeerInetSocketAddress(
HttpRequestAndChannel requestAndChannel, @Nullable HttpResponse response) {
NettyRequest requestAndChannel, @Nullable HttpResponse response) {
SocketAddress address = requestAndChannel.channel().getRemoteAddress();
if (address instanceof InetSocketAddress) {
return (InetSocketAddress) address;
Expand All @@ -96,7 +95,7 @@ public InetSocketAddress getNetworkPeerInetSocketAddress(
@Nullable
@Override
public InetSocketAddress getNetworkLocalInetSocketAddress(
HttpRequestAndChannel requestAndChannel, @Nullable HttpResponse response) {
NettyRequest requestAndChannel, @Nullable HttpResponse response) {
SocketAddress address = requestAndChannel.channel().getLocalAddress();
if (address instanceof InetSocketAddress) {
return (InetSocketAddress) address;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@

import com.google.auto.value.AutoValue;
import io.opentelemetry.context.Context;
import io.opentelemetry.javaagent.instrumentation.netty.v3_8.HttpRequestAndChannel;
import io.opentelemetry.javaagent.instrumentation.netty.v3_8.NettyRequest;

@AutoValue
abstract class NettyServerRequestAndContext {

static NettyServerRequestAndContext create(HttpRequestAndChannel request, Context context) {
static NettyServerRequestAndContext create(NettyRequest request, Context context) {
return new AutoValue_NettyServerRequestAndContext(request, context);
}

abstract HttpRequestAndChannel request();
abstract NettyRequest request();

abstract Context context();
}
Loading