Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename library entrypoints to Telemetry #5624

Merged
merged 3 commits into from
Mar 22, 2022
Merged
Changes from 1 commit
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
Next Next commit
Rename library entrypoints to Telemetry
anuraaga committed Mar 18, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit a30ba7bbf637e201516a6ad333eb1b6bc6505cd2
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
package io.opentelemetry.javaagent.instrumentation.apachedubbo.v2_7;

import io.opentelemetry.api.GlobalOpenTelemetry;
import io.opentelemetry.instrumentation.apachedubbo.v2_7.DubboTracing;
import io.opentelemetry.instrumentation.apachedubbo.v2_7.DubboTelemetry;
import org.apache.dubbo.common.extension.Activate;
import org.apache.dubbo.rpc.Filter;
import org.apache.dubbo.rpc.Invocation;
@@ -19,7 +19,7 @@ public class OpenTelemetryFilter implements Filter {
private final Filter delegate;

public OpenTelemetryFilter() {
delegate = DubboTracing.create(GlobalOpenTelemetry.get()).newFilter();
delegate = DubboTelemetry.create(GlobalOpenTelemetry.get()).newFilter();
}

@Override
Original file line number Diff line number Diff line change
@@ -10,23 +10,25 @@
import org.apache.dubbo.rpc.Filter;
import org.apache.dubbo.rpc.Result;

/** Entrypoint for tracing Apache Dubbo servers and clients. */
public final class DubboTracing {
/** Entrypoint for instrumenting Apache Dubbo servers and clients. */
public final class DubboTelemetry {

/** Returns a new {@link DubboTracing} configured with the given {@link OpenTelemetry}. */
public static DubboTracing create(OpenTelemetry openTelemetry) {
/** Returns a new {@link DubboTelemetry} configured with the given {@link OpenTelemetry}. */
public static DubboTelemetry create(OpenTelemetry openTelemetry) {
return builder(openTelemetry).build();
}

/** Returns a new {@link DubboTracingBuilder} configured with the given {@link OpenTelemetry}. */
public static DubboTracingBuilder builder(OpenTelemetry openTelemetry) {
return new DubboTracingBuilder(openTelemetry);
/**
* Returns a new {@link DubboTelemetryBuilder} configured with the given {@link OpenTelemetry}.
*/
public static DubboTelemetryBuilder builder(OpenTelemetry openTelemetry) {
return new DubboTelemetryBuilder(openTelemetry);
}

private final Instrumenter<DubboRequest, Result> serverInstrumenter;
private final Instrumenter<DubboRequest, Result> clientInstrumenter;

DubboTracing(
DubboTelemetry(
Instrumenter<DubboRequest, Result> serverInstrumenter,
Instrumenter<DubboRequest, Result> clientInstrumenter) {
this.serverInstrumenter = serverInstrumenter;
Original file line number Diff line number Diff line change
@@ -24,8 +24,8 @@
import javax.annotation.Nullable;
import org.apache.dubbo.rpc.Result;

/** A builder of {@link DubboTracing}. */
public final class DubboTracingBuilder {
/** A builder of {@link DubboTelemetry}. */
public final class DubboTelemetryBuilder {

private static final String INSTRUMENTATION_NAME = "io.opentelemetry.apache-dubbo-2.7";

@@ -34,7 +34,7 @@ public final class DubboTracingBuilder {
private final List<AttributesExtractor<DubboRequest, Result>> attributesExtractors =
new ArrayList<>();

DubboTracingBuilder(OpenTelemetry openTelemetry) {
DubboTelemetryBuilder(OpenTelemetry openTelemetry) {
this.openTelemetry = openTelemetry;
}

@@ -47,14 +47,16 @@ public void setPeerService(String peerService) {
* Adds an additional {@link AttributesExtractor} to invoke to set attributes to instrumented
* items.
*/
public DubboTracingBuilder addAttributesExtractor(
public DubboTelemetryBuilder addAttributesExtractor(
AttributesExtractor<DubboRequest, Result> attributesExtractor) {
attributesExtractors.add(attributesExtractor);
return this;
}

/** Returns a new {@link DubboTracing} with the settings of this {@link DubboTracingBuilder}. */
public DubboTracing build() {
/**
* Returns a new {@link DubboTelemetry} with the settings of this {@link DubboTelemetryBuilder}.
*/
public DubboTelemetry build() {
DubboRpcAttributesGetter rpcAttributesGetter = DubboRpcAttributesGetter.INSTANCE;
SpanNameExtractor<DubboRequest> spanNameExtractor =
RpcSpanNameExtractor.create(rpcAttributesGetter);
@@ -83,7 +85,7 @@ public DubboTracing build() {
PeerServiceAttributesExtractor.create(netClientAttributesGetter));
}

return new DubboTracing(
return new DubboTelemetry(
serverInstrumenterBuilder.newServerInstrumenter(DubboHeadersGetter.INSTANCE),
clientInstrumenterBuilder.newClientInstrumenter(DubboHeadersSetter.INSTANCE));
}
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ public final class OpenTelemetryFilter implements Filter {
private final Filter delegate;

public OpenTelemetryFilter() {
delegate = DubboTracing.create(GlobalOpenTelemetry.get()).newFilter();
delegate = DubboTelemetry.create(GlobalOpenTelemetry.get()).newFilter();
}

@Override
Original file line number Diff line number Diff line change
@@ -12,28 +12,29 @@
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;

/** Entrypoint for tracing Apache HTTP Client. */
public final class ApacheHttpClientTracing {
/** Entrypoint for instrumenting Apache HTTP Client. */
public final class ApacheHttpClientTelemetry {

/**
* Returns a new {@link ApacheHttpClientTracing} configured with the given {@link OpenTelemetry}.
* Returns a new {@link ApacheHttpClientTelemetry} configured with the given {@link
* OpenTelemetry}.
*/
public static ApacheHttpClientTracing create(OpenTelemetry openTelemetry) {
public static ApacheHttpClientTelemetry create(OpenTelemetry openTelemetry) {
return builder(openTelemetry).build();
}

/**
* Returns a new {@link ApacheHttpClientTracingBuilder} configured with the given {@link
* Returns a new {@link ApacheHttpClientTelemetryBuilder} configured with the given {@link
* OpenTelemetry}.
*/
public static ApacheHttpClientTracingBuilder builder(OpenTelemetry openTelemetry) {
return new ApacheHttpClientTracingBuilder(openTelemetry);
public static ApacheHttpClientTelemetryBuilder builder(OpenTelemetry openTelemetry) {
return new ApacheHttpClientTelemetryBuilder(openTelemetry);
}

private final Instrumenter<ApacheHttpClientRequest, HttpResponse> instrumenter;
private final ContextPropagators propagators;

ApacheHttpClientTracing(
ApacheHttpClientTelemetry(
Instrumenter<ApacheHttpClientRequest, HttpResponse> instrumenter,
ContextPropagators propagators) {
this.instrumenter = instrumenter;
Original file line number Diff line number Diff line change
@@ -18,8 +18,8 @@
import java.util.List;
import org.apache.http.HttpResponse;

/** A builder for {@link ApacheHttpClientTracing}. */
public final class ApacheHttpClientTracingBuilder {
/** A builder for {@link ApacheHttpClientTelemetry}. */
public final class ApacheHttpClientTelemetryBuilder {

private static final String INSTRUMENTATION_NAME = "io.opentelemetry.apache-httpclient-4.3";

@@ -31,15 +31,15 @@ public final class ApacheHttpClientTracingBuilder {
httpAttributesExtractorBuilder =
HttpClientAttributesExtractor.builder(ApacheHttpClientHttpAttributesGetter.INSTANCE);

ApacheHttpClientTracingBuilder(OpenTelemetry openTelemetry) {
ApacheHttpClientTelemetryBuilder(OpenTelemetry openTelemetry) {
this.openTelemetry = openTelemetry;
}

/**
* Adds an additional {@link AttributesExtractor} to invoke to set attributes to instrumented
* items. The {@link AttributesExtractor} will be executed after all default extractors.
*/
public ApacheHttpClientTracingBuilder addAttributeExtractor(
public ApacheHttpClientTelemetryBuilder addAttributeExtractor(
AttributesExtractor<? super ApacheHttpClientRequest, ? super HttpResponse>
attributesExtractor) {
additionalExtractors.add(attributesExtractor);
@@ -51,7 +51,7 @@ public ApacheHttpClientTracingBuilder addAttributeExtractor(
*
* @param requestHeaders A list of HTTP header names.
*/
public ApacheHttpClientTracingBuilder setCapturedRequestHeaders(List<String> requestHeaders) {
public ApacheHttpClientTelemetryBuilder setCapturedRequestHeaders(List<String> requestHeaders) {
httpAttributesExtractorBuilder.setCapturedRequestHeaders(requestHeaders);
return this;
}
@@ -61,16 +61,16 @@ public ApacheHttpClientTracingBuilder setCapturedRequestHeaders(List<String> req
*
* @param responseHeaders A list of HTTP header names.
*/
public ApacheHttpClientTracingBuilder setCapturedResponseHeaders(List<String> responseHeaders) {
public ApacheHttpClientTelemetryBuilder setCapturedResponseHeaders(List<String> responseHeaders) {
httpAttributesExtractorBuilder.setCapturedResponseHeaders(responseHeaders);
return this;
}

/**
* Returns a new {@link ApacheHttpClientTracing} configured with this {@link
* ApacheHttpClientTracingBuilder}.
* Returns a new {@link ApacheHttpClientTelemetry} configured with this {@link
* ApacheHttpClientTelemetryBuilder}.
*/
public ApacheHttpClientTracing build() {
public ApacheHttpClientTelemetry build() {
ApacheHttpClientHttpAttributesGetter httpAttributesGetter =
ApacheHttpClientHttpAttributesGetter.INSTANCE;
ApacheHttpClientNetAttributesGetter netAttributesGetter =
@@ -88,6 +88,6 @@ public ApacheHttpClientTracing build() {
// We manually inject because we need to inject internal requests for redirects.
.newInstrumenter(SpanKindExtractor.alwaysClient());

return new ApacheHttpClientTracing(instrumenter, openTelemetry.getPropagators());
return new ApacheHttpClientTelemetry(instrumenter, openTelemetry.getPropagators());
}
}
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ import org.apache.http.impl.client.CloseableHttpClient
class ApacheClientHostAbsoluteUriRequestContextTest extends AbstractApacheClientHostAbsoluteUriRequestContextTest implements LibraryTestTrait {
@Override
protected CloseableHttpClient createClient(boolean readTimeout) {
def builder = ApacheHttpClientTracing.create(openTelemetry).newHttpClientBuilder()
def builder = ApacheHttpClientTelemetry.create(openTelemetry).newHttpClientBuilder()
def requestConfigBuilder = RequestConfig.custom()
.setMaxRedirects(maxRedirects())
.setConnectTimeout(CONNECT_TIMEOUT_MS)
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ import org.apache.http.impl.client.CloseableHttpClient
class ApacheClientHostAbsoluteUriRequestTest extends AbstractApacheClientHostAbsoluteUriRequestTest implements LibraryTestTrait {
@Override
protected CloseableHttpClient createClient(boolean readTimeout) {
def builder = ApacheHttpClientTracing.create(openTelemetry).newHttpClientBuilder()
def builder = ApacheHttpClientTelemetry.create(openTelemetry).newHttpClientBuilder()
def requestConfigBuilder = RequestConfig.custom()
.setMaxRedirects(maxRedirects())
.setConnectTimeout(CONNECT_TIMEOUT_MS)
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ import org.apache.http.impl.client.CloseableHttpClient
class ApacheClientHostRequestContextTest extends AbstractApacheClientHostRequestContextTest implements LibraryTestTrait {
@Override
protected CloseableHttpClient createClient(boolean readTimeout) {
def builder = ApacheHttpClientTracing.create(openTelemetry).newHttpClientBuilder()
def builder = ApacheHttpClientTelemetry.create(openTelemetry).newHttpClientBuilder()
def requestConfigBuilder = RequestConfig.custom()
.setMaxRedirects(maxRedirects())
.setConnectTimeout(CONNECT_TIMEOUT_MS)
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ import org.apache.http.impl.client.CloseableHttpClient
class ApacheClientHostRequestTest extends AbstractApacheClientHostRequestTest implements LibraryTestTrait {
@Override
protected CloseableHttpClient createClient(boolean readTimeout) {
def builder = ApacheHttpClientTracing.create(openTelemetry).newHttpClientBuilder()
def builder = ApacheHttpClientTelemetry.create(openTelemetry).newHttpClientBuilder()
def requestConfigBuilder = RequestConfig.custom()
.setMaxRedirects(maxRedirects())
.setConnectTimeout(CONNECT_TIMEOUT_MS)
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ import org.apache.http.impl.client.CloseableHttpClient
class ApacheClientUriRequestContextTest extends AbstractApacheClientUriRequestContextTest implements LibraryTestTrait {
@Override
protected CloseableHttpClient createClient(boolean readTimeout) {
def builder = ApacheHttpClientTracing.create(openTelemetry).newHttpClientBuilder()
def builder = ApacheHttpClientTelemetry.create(openTelemetry).newHttpClientBuilder()
def requestConfigBuilder = RequestConfig.custom()
.setMaxRedirects(maxRedirects())
.setConnectTimeout(CONNECT_TIMEOUT_MS)
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ import org.apache.http.impl.client.CloseableHttpClient
class ApacheClientUriRequestTest extends AbstractApacheClientUriRequestTest implements LibraryTestTrait {
@Override
protected CloseableHttpClient createClient(boolean readTimeout) {
def builder = ApacheHttpClientTracing.create(openTelemetry).newHttpClientBuilder()
def builder = ApacheHttpClientTelemetry.create(openTelemetry).newHttpClientBuilder()
def requestConfigBuilder = RequestConfig.custom()
.setMaxRedirects(maxRedirects())
.setConnectTimeout(CONNECT_TIMEOUT_MS)
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@
import com.linecorp.armeria.client.HttpClient;
import com.linecorp.armeria.server.HttpService;
import io.opentelemetry.api.GlobalOpenTelemetry;
import io.opentelemetry.instrumentation.armeria.v1_3.ArmeriaTracing;
import io.opentelemetry.instrumentation.armeria.v1_3.ArmeriaTelemetry;
import java.util.function.Function;

// Holds singleton references to decorators to match against during suppression.
@@ -19,7 +19,7 @@ public final class ArmeriaSingletons {
public static final Function<? super HttpService, ? extends HttpService> SERVER_DECORATOR;

static {
ArmeriaTracing tracing = ArmeriaTracing.create(GlobalOpenTelemetry.get());
ArmeriaTelemetry tracing = ArmeriaTelemetry.create(GlobalOpenTelemetry.get());

CLIENT_DECORATOR = tracing.newClientDecorator();
SERVER_DECORATOR = tracing.newServiceDecorator();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ArmeriaTelemetry tracing = ArmeriaTelemetry.create(GlobalOpenTelemetry.get());
CLIENT_DECORATOR = tracing.newClientDecorator();
SERVER_DECORATOR = tracing.newServiceDecorator();
ArmeriaTelemetry telemetry = ArmeriaTelemetry.create(GlobalOpenTelemetry.get());
CLIENT_DECORATOR = telemetry.newClientDecorator();
SERVER_DECORATOR = telemetry.newServiceDecorator();

Original file line number Diff line number Diff line change
@@ -14,22 +14,22 @@
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
import java.util.function.Function;

/** Entrypoint for tracing Armeria services or clients. */
public final class ArmeriaTracing {
/** Entrypoint for instrumenting Armeria services or clients. */
public final class ArmeriaTelemetry {

/** Returns a new {@link ArmeriaTracing} configured with the given {@link OpenTelemetry}. */
public static ArmeriaTracing create(OpenTelemetry openTelemetry) {
/** Returns a new {@link ArmeriaTelemetry} configured with the given {@link OpenTelemetry}. */
public static ArmeriaTelemetry create(OpenTelemetry openTelemetry) {
return builder(openTelemetry).build();
}

public static ArmeriaTracingBuilder builder(OpenTelemetry openTelemetry) {
return new ArmeriaTracingBuilder(openTelemetry);
public static ArmeriaTelemetryBuilder builder(OpenTelemetry openTelemetry) {
return new ArmeriaTelemetryBuilder(openTelemetry);
}

private final Instrumenter<ClientRequestContext, RequestLog> clientInstrumenter;
private final Instrumenter<ServiceRequestContext, RequestLog> serverInstrumenter;

ArmeriaTracing(
ArmeriaTelemetry(
Instrumenter<ClientRequestContext, RequestLog> clientInstrumenter,
Instrumenter<ServiceRequestContext, RequestLog> serverInstrumenter) {
this.clientInstrumenter = clientInstrumenter;
Loading