-
Notifications
You must be signed in to change notification settings - Fork 967
fix jedis plugin for 2.7.2 #10982
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
Merged
Merged
fix jedis plugin for 2.7.2 #10982
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
426988e
feat: add library instrumentation in reactor-netty
123liuziming 2fbfc8c
feat: support jedis 2.7.2
123liuziming 36f6d96
add ut for 2.7.2
123liuziming 75c4056
revert commit
123liuziming d013f44
Update DecoratorFunctions.java
123liuziming 1af9eb8
Update HttpResponseReceiverInstrumenter.java
123liuziming d360033
remove redundant import
123liuziming 2f618fe
fix
123liuziming 6f4889f
polish code
123liuziming File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
10 changes: 10 additions & 0 deletions
10
...sion272/java/io/opentelemetry/javaagent/instrumentation/jedis/v2_7_2/JedisClientTest.java
This file contains hidden or 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,10 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent.instrumentation.jedis.v2_7_2; | ||
|
||
import io.opentelemetry.javaagent.instrumentation.jedis.AbstractJedisTest; | ||
|
||
class JedisClientTest extends AbstractJedisTest {} |
This file contains hidden or 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,9 @@ | ||
plugins { | ||
id("otel.java-conventions") | ||
} | ||
|
||
dependencies { | ||
compileOnly("redis.clients:jedis:1.4.0") | ||
api(project(":testing-common")) | ||
implementation("org.testcontainers:testcontainers") | ||
} |
133 changes: 133 additions & 0 deletions
133
...ing/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/AbstractJedisTest.java
This file contains hidden or 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,133 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent.instrumentation.jedis; | ||
|
||
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import io.opentelemetry.api.trace.SpanKind; | ||
import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension; | ||
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension; | ||
import io.opentelemetry.semconv.SemanticAttributes; | ||
import org.junit.jupiter.api.AfterAll; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
import org.testcontainers.containers.GenericContainer; | ||
import redis.clients.jedis.Jedis; | ||
|
||
public abstract class AbstractJedisTest { | ||
@RegisterExtension | ||
private static final InstrumentationExtension testing = AgentInstrumentationExtension.create(); | ||
|
||
private static final GenericContainer<?> REDIS_SERVER = | ||
new GenericContainer<>("redis:6.2.3-alpine").withExposedPorts(6379); | ||
|
||
private static int port; | ||
|
||
private static Jedis jedis; | ||
|
||
@BeforeAll | ||
static void setup() { | ||
REDIS_SERVER.start(); | ||
port = REDIS_SERVER.getMappedPort(6379); | ||
jedis = new Jedis("localhost", port); | ||
} | ||
|
||
@AfterAll | ||
static void cleanup() { | ||
REDIS_SERVER.stop(); | ||
} | ||
|
||
@BeforeEach | ||
void reset() { | ||
jedis.flushAll(); | ||
testing.clearData(); | ||
} | ||
|
||
@Test | ||
void setCommand() { | ||
jedis.set("foo", "bar"); | ||
|
||
testing.waitAndAssertTraces( | ||
trace -> | ||
trace.hasSpansSatisfyingExactly( | ||
span -> | ||
span.hasName("SET") | ||
.hasKind(SpanKind.CLIENT) | ||
.hasAttributesSatisfyingExactly( | ||
equalTo(SemanticAttributes.DB_SYSTEM, "redis"), | ||
equalTo(SemanticAttributes.DB_STATEMENT, "SET foo ?"), | ||
equalTo(SemanticAttributes.DB_OPERATION, "SET"), | ||
equalTo(SemanticAttributes.SERVER_ADDRESS, "localhost"), | ||
equalTo(SemanticAttributes.SERVER_PORT, port)))); | ||
} | ||
|
||
@Test | ||
void getCommand() { | ||
jedis.set("foo", "bar"); | ||
String value = jedis.get("foo"); | ||
|
||
assertThat(value).isEqualTo("bar"); | ||
|
||
testing.waitAndAssertTraces( | ||
trace -> | ||
trace.hasSpansSatisfyingExactly( | ||
span -> | ||
span.hasName("SET") | ||
.hasKind(SpanKind.CLIENT) | ||
.hasAttributesSatisfyingExactly( | ||
equalTo(SemanticAttributes.DB_SYSTEM, "redis"), | ||
equalTo(SemanticAttributes.DB_STATEMENT, "SET foo ?"), | ||
equalTo(SemanticAttributes.DB_OPERATION, "SET"), | ||
equalTo(SemanticAttributes.SERVER_ADDRESS, "localhost"), | ||
equalTo(SemanticAttributes.SERVER_PORT, port))), | ||
trace -> | ||
trace.hasSpansSatisfyingExactly( | ||
span -> | ||
span.hasName("GET") | ||
.hasKind(SpanKind.CLIENT) | ||
.hasAttributesSatisfyingExactly( | ||
equalTo(SemanticAttributes.DB_SYSTEM, "redis"), | ||
equalTo(SemanticAttributes.DB_STATEMENT, "GET foo"), | ||
equalTo(SemanticAttributes.DB_OPERATION, "GET"), | ||
equalTo(SemanticAttributes.SERVER_ADDRESS, "localhost"), | ||
equalTo(SemanticAttributes.SERVER_PORT, port)))); | ||
} | ||
|
||
@Test | ||
void commandWithNoArguments() { | ||
jedis.set("foo", "bar"); | ||
String value = jedis.randomKey(); | ||
|
||
assertThat(value).isEqualTo("foo"); | ||
|
||
testing.waitAndAssertTraces( | ||
trace -> | ||
trace.hasSpansSatisfyingExactly( | ||
span -> | ||
span.hasName("SET") | ||
.hasKind(SpanKind.CLIENT) | ||
.hasAttributesSatisfyingExactly( | ||
equalTo(SemanticAttributes.DB_SYSTEM, "redis"), | ||
equalTo(SemanticAttributes.DB_STATEMENT, "SET foo ?"), | ||
equalTo(SemanticAttributes.DB_OPERATION, "SET"), | ||
equalTo(SemanticAttributes.SERVER_ADDRESS, "localhost"), | ||
equalTo(SemanticAttributes.SERVER_PORT, port))), | ||
trace -> | ||
trace.hasSpansSatisfyingExactly( | ||
span -> | ||
span.hasName("RANDOMKEY") | ||
.hasKind(SpanKind.CLIENT) | ||
.hasAttributesSatisfyingExactly( | ||
equalTo(SemanticAttributes.DB_SYSTEM, "redis"), | ||
equalTo(SemanticAttributes.DB_STATEMENT, "RANDOMKEY"), | ||
equalTo(SemanticAttributes.DB_OPERATION, "RANDOMKEY"), | ||
equalTo(SemanticAttributes.SERVER_ADDRESS, "localhost"), | ||
equalTo(SemanticAttributes.SERVER_PORT, port)))); | ||
} | ||
} |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.