Skip to content

Commit

Permalink
Extract library instrumentation for lettuce 5.1 (#2533)
Browse files Browse the repository at this point in the history
  • Loading branch information
Anuraag Agrawal authored Mar 10, 2021
1 parent 9ea6fcd commit cf6d9de
Show file tree
Hide file tree
Showing 26 changed files with 1,620 additions and 1,353 deletions.
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

0 comments on commit cf6d9de

Please sign in to comment.