-
Notifications
You must be signed in to change notification settings - Fork 890
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move client instrumentation from library to javaagent
- Loading branch information
Showing
13 changed files
with
125 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...ava/io/opentelemetry/javaagent/instrumentation/jsonrpc4j/v1_3/JsonRpcClientTelemetry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent.instrumentation.jsonrpc4j.v1_3; | ||
|
||
import io.opentelemetry.api.OpenTelemetry; | ||
import io.opentelemetry.context.propagation.ContextPropagators; | ||
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; | ||
|
||
public final class JsonRpcClientTelemetry { | ||
public static JsonRpcClientTelemetry create(OpenTelemetry openTelemetry) { | ||
return builder(openTelemetry).build(); | ||
} | ||
|
||
public static JsonRpcClientTelemetryBuilder builder(OpenTelemetry openTelemetry) { | ||
return new JsonRpcClientTelemetryBuilder(openTelemetry); | ||
} | ||
|
||
private final Instrumenter<JsonRpcClientRequest, JsonRpcClientResponse> clientInstrumenter; | ||
|
||
JsonRpcClientTelemetry( | ||
Instrumenter<JsonRpcClientRequest, JsonRpcClientResponse> clientInstrumenter, | ||
ContextPropagators propagators) { | ||
this.clientInstrumenter = clientInstrumenter; | ||
} | ||
|
||
public Instrumenter<JsonRpcClientRequest, JsonRpcClientResponse> getClientInstrumenter() { | ||
return clientInstrumenter; | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
...opentelemetry/javaagent/instrumentation/jsonrpc4j/v1_3/JsonRpcClientTelemetryBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent.instrumentation.jsonrpc4j.v1_3; | ||
|
||
import com.google.errorprone.annotations.CanIgnoreReturnValue; | ||
import io.opentelemetry.api.OpenTelemetry; | ||
import io.opentelemetry.instrumentation.api.incubator.semconv.rpc.RpcClientAttributesExtractor; | ||
import io.opentelemetry.instrumentation.api.incubator.semconv.rpc.RpcClientMetrics; | ||
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; | ||
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; | ||
import io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder; | ||
import io.opentelemetry.instrumentation.api.instrumenter.SpanKindExtractor; | ||
import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class JsonRpcClientTelemetryBuilder { | ||
|
||
private static final String INSTRUMENTATION_NAME = "io.opentelemetry.jsonrpc4j-1.3"; | ||
|
||
private final OpenTelemetry openTelemetry; | ||
|
||
private final List< | ||
AttributesExtractor<? super JsonRpcClientRequest, ? super JsonRpcClientResponse>> | ||
additionalClientExtractors = new ArrayList<>(); | ||
|
||
JsonRpcClientTelemetryBuilder(OpenTelemetry openTelemetry) { | ||
this.openTelemetry = openTelemetry; | ||
} | ||
|
||
/** | ||
* Adds an extra client-only {@link AttributesExtractor} to invoke to set attributes to | ||
* instrumented items. The {@link AttributesExtractor} will be executed after all default | ||
* extractors. | ||
*/ | ||
@CanIgnoreReturnValue | ||
public JsonRpcClientTelemetryBuilder addClientAttributeExtractor( | ||
AttributesExtractor<? super JsonRpcClientRequest, ? super JsonRpcClientResponse> | ||
attributesExtractor) { | ||
additionalClientExtractors.add(attributesExtractor); | ||
return this; | ||
} | ||
|
||
public JsonRpcClientTelemetry build() { | ||
SpanNameExtractor<JsonRpcClientRequest> clientSpanNameExtractor = | ||
new JsonRpcClientSpanNameExtractor(); | ||
|
||
InstrumenterBuilder<JsonRpcClientRequest, JsonRpcClientResponse> clientInstrumenterBuilder = | ||
Instrumenter.builder(openTelemetry, INSTRUMENTATION_NAME, clientSpanNameExtractor); | ||
|
||
JsonRpcClientAttributesGetter clientRpcAttributesGetter = | ||
JsonRpcClientAttributesGetter.INSTANCE; | ||
|
||
clientInstrumenterBuilder | ||
.addAttributesExtractor(RpcClientAttributesExtractor.create(clientRpcAttributesGetter)) | ||
.addAttributesExtractors(additionalClientExtractors) | ||
.addAttributesExtractor(new JsonRpcClientAttributesExtractor()) | ||
.addOperationMetrics(RpcClientMetrics.get()); | ||
|
||
return new JsonRpcClientTelemetry( | ||
clientInstrumenterBuilder.buildInstrumenter(SpanKindExtractor.alwaysClient()), | ||
openTelemetry.getPropagators()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters