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

Extract library instrumentation for lettuce 5.1 #2533

Merged
merged 1 commit into from
Mar 10, 2021
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 @@ -76,7 +76,8 @@ public void setNetPeer(Span span, String peerName, String peerIp, int port) {
setNetPeer(span::setAttribute, peerName, peerIp, port);
}

public void setNetPeer(SpanAttributeSetter span, String peerName, String peerIp, int port) {
public void setNetPeer(
SpanAttributeSetter span, @Nullable String peerName, @Nullable String peerIp, int port) {
if (peerName != null && !peerName.equals(peerIp)) {
span.setAttribute(SemanticAttributes.NET_PEER_NAME, peerName);
}
Expand Down Expand Up @@ -109,6 +110,6 @@ private String mapToPeerService(String endpoint) {
*/
@FunctionalInterface
public interface SpanAttributeSetter {
<T> void setAttribute(AttributeKey<T> key, @Nullable T value);
<T> void setAttribute(AttributeKey<T> key, T value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ muzzle {
dependencies {
compileOnly group: 'io.lettuce', name: 'lettuce-core', version: '5.0.0.RELEASE'

implementation project(':instrumentation:lettuce:lettuce-common:javaagent')
implementation project(':instrumentation:lettuce:lettuce-common:library')

testImplementation group: 'com.github.kstyrc', name: 'embedded-redis', version: '0.6'
testImplementation group: 'io.lettuce', name: 'lettuce-core', version: '5.0.0.RELEASE'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import io.lettuce.core.RedisURI;
import io.lettuce.core.protocol.RedisCommand;
import io.opentelemetry.instrumentation.api.db.RedisCommandSanitizer;
import io.opentelemetry.javaagent.instrumentation.lettuce.LettuceArgSplitter;
import io.opentelemetry.instrumentation.lettuce.common.LettuceArgSplitter;
import java.util.Collections;
import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ muzzle {
dependencies {
library group: 'io.lettuce', name: 'lettuce-core', version: '5.1.0.RELEASE'

implementation project(':instrumentation:lettuce:lettuce-common:javaagent')
implementation project(':instrumentation:lettuce:lettuce-5.1:library')

testImplementation project(':instrumentation:lettuce:lettuce-5.1:testing')

testImplementation group: 'com.github.kstyrc', name: 'embedded-redis', version: '0.6'
// Only 5.2+ will have command arguments in the db.statement tag.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static class DefaultClientResourcesAdvice {

@Advice.OnMethodExit(suppress = Throwable.class)
public static void methodEnter(@Advice.Return DefaultClientResources.Builder builder) {
builder.tracing(OpenTelemetryTracing.INSTANCE);
builder.tracing(TracingHolder.TRACING);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.javaagent.instrumentation.lettuce.v5_1;

import io.lettuce.core.tracing.Tracing;
import io.opentelemetry.api.GlobalOpenTelemetry;
import io.opentelemetry.instrumentation.lettuce.v5_1.LettuceTracing;

public final class TracingHolder {

public static final Tracing TRACING =
LettuceTracing.create(GlobalOpenTelemetry.get()).newTracing();

private TracingHolder() {}
}
Loading