Repository navigation
Add Jedis pipeline span batch support #19054
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
Changes from 19 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
cf16c7c
Add Jedis pipeline span aggregation
trask 1a07c7b
Drop batching from jedis-1.4; partition jedis-1.4/2.0 at the 2.0 (Res…
trask 10cdbf3
Address review comment: simplify jedis-1.4 classLoaderMatcher comment
trask 088bf0e
Address review comment: revert unnecessary jedis-1.4 JedisRequest/Jed…
trask 7d4674f
Address review comment: move pipeline-capture comment inside the if
trask ad70298
Address review comment: name jedis-3.0 captured-requests VirtualField…
trask e82f9cd
Address review comment: type jedis-3.0 pipeline context with Pipeline…
trask b39d8fe
Address review comment: rephrase pipeline thread-local comment
trask 7b83125
Address review comment: document why empty pipelines are not reported…
trask 234816d
Address review comment: precompute operation name and query text in j…
trask 9de6620
Address review comment: drop stale double-spans comment in jedis-3.0 …
trask 7ebff14
Address review comment: name jedis-4.0 captured-requests VirtualField…
trask 795aa64
Address review comment: precompute operation name and query text in j…
trask 95b1a92
Address review: tighten pipeline typing where safe, refine comments
trask fa5ea6c
Add MULTI batch spans for Redis transactions (jedis 2.0/3.0/4.0)
trask 3bc21f1
Add transaction discard() regression tests (jedis 2.0/3.0/4.0)
trask 7b37832
Deprecate jedis-1.4 module and disable under v3-preview
trask e93a80c
Store List<JedisRequest> directly in VirtualField instead of Captured…
trask 52dbebe
Address Jedis review feedback
trask f863cf1
Align Jedis batch query text limits
trask d8c3f15
Merge remote-tracking branch 'upstream/main' into jedis-batch-spans
trask 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
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
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 |
|---|---|---|
|
|
@@ -5,6 +5,161 @@ | |
|
|
||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Copied from --- a/instrumentation/jedis/jedis-1.4/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/AbstractJedisTest.java
+++ b/instrumentation/jedis/jedis-1.4/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/jedis/v1_4/JedisClientTest.java
@@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
-package io.opentelemetry.javaagent.instrumentation.jedis;
+package io.opentelemetry.javaagent.instrumentation.jedis.v1_4;
import static io.opentelemetry.instrumentation.api.internal.SemconvStability.emitStableDatabaseSemconv;
import static io.opentelemetry.instrumentation.testing.junit.db.DbClientMetricsTestUtil.assertDurationMetric;
@@ -32,7 +32,7 @@ import org.testcontainers.containers.GenericContainer;
import redis.clients.jedis.Jedis;
@SuppressWarnings("deprecation") // using deprecated semconv
-public abstract class AbstractJedisTest {
+class JedisClientTest {
@RegisterExtension
private static final InstrumentationExtension testing = AgentInstrumentationExtension.create();
|
||
| package io.opentelemetry.javaagent.instrumentation.jedis.v1_4; | ||
|
|
||
| import io.opentelemetry.javaagent.instrumentation.jedis.AbstractJedisTest; | ||
| import static io.opentelemetry.instrumentation.api.internal.SemconvStability.emitStableDatabaseSemconv; | ||
| import static io.opentelemetry.instrumentation.testing.junit.db.DbClientMetricsTestUtil.assertDurationMetric; | ||
| import static io.opentelemetry.instrumentation.testing.junit.db.SemconvStabilityUtil.maybeStable; | ||
| import static io.opentelemetry.instrumentation.testing.junit.service.SemconvServiceStabilityUtil.maybeStablePeerService; | ||
| import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo; | ||
| import static io.opentelemetry.semconv.ServerAttributes.SERVER_ADDRESS; | ||
| import static io.opentelemetry.semconv.ServerAttributes.SERVER_PORT; | ||
| import static io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DB_OPERATION; | ||
| import static io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DB_OPERATION_NAME; | ||
| import static io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DB_STATEMENT; | ||
| import static io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DB_SYSTEM; | ||
| import static io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DB_SYSTEM_NAME; | ||
| import static io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DbSystemNameIncubatingValues.REDIS; | ||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| class JedisClientTest extends AbstractJedisTest {} | ||
| import io.opentelemetry.api.trace.SpanKind; | ||
| import io.opentelemetry.instrumentation.testing.internal.AutoCleanupExtension; | ||
| import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension; | ||
| import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension; | ||
| 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; | ||
|
|
||
| @SuppressWarnings("deprecation") // using deprecated semconv | ||
| class JedisClientTest { | ||
| @RegisterExtension | ||
| private static final InstrumentationExtension testing = AgentInstrumentationExtension.create(); | ||
|
|
||
| @RegisterExtension | ||
| private static final AutoCleanupExtension cleanup = AutoCleanupExtension.create(); | ||
|
|
||
| private static final GenericContainer<?> redisServer = | ||
| new GenericContainer<>("redis:6.2.3-alpine").withExposedPorts(6379); | ||
|
|
||
| private static String host; | ||
|
|
||
| private static int port; | ||
|
|
||
| private static Jedis jedis; | ||
|
|
||
| @BeforeAll | ||
| static void setup() { | ||
| redisServer.start(); | ||
| cleanup.deferAfterAll(redisServer::stop); | ||
| host = redisServer.getHost(); | ||
| port = redisServer.getMappedPort(6379); | ||
| jedis = new Jedis(host, port); | ||
| cleanup.deferAfterAll(jedis::disconnect); | ||
| } | ||
|
|
||
| @BeforeEach | ||
| void reset() { | ||
| jedis.select(0); | ||
| jedis.flushAll(); | ||
| testing.clearData(); | ||
| } | ||
|
|
||
| @Test | ||
| void setCommand() { | ||
| jedis.set("foo", "bar"); | ||
|
|
||
| testing.waitAndAssertTraces( | ||
| trace -> | ||
| trace.hasSpansSatisfyingExactly( | ||
| span -> | ||
| span.hasName(emitStableDatabaseSemconv() ? "SET " + host + ":" + port : "SET") | ||
| .hasKind(SpanKind.CLIENT) | ||
| .hasAttributesSatisfyingExactly( | ||
| equalTo(maybeStable(DB_SYSTEM), REDIS), | ||
| equalTo(maybeStable(DB_STATEMENT), "SET foo ?"), | ||
| equalTo(maybeStable(DB_OPERATION), "SET"), | ||
| equalTo(maybeStablePeerService(), "test-peer-service"), | ||
| equalTo(SERVER_ADDRESS, host), | ||
| equalTo(SERVER_PORT, port)))); | ||
|
|
||
| assertDurationMetric( | ||
| testing, | ||
| "io.opentelemetry.jedis-1.4", | ||
| DB_SYSTEM_NAME, | ||
| DB_OPERATION_NAME, | ||
| SERVER_ADDRESS, | ||
| SERVER_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(emitStableDatabaseSemconv() ? "SET " + host + ":" + port : "SET") | ||
| .hasKind(SpanKind.CLIENT) | ||
| .hasAttributesSatisfyingExactly( | ||
| equalTo(maybeStable(DB_SYSTEM), REDIS), | ||
| equalTo(maybeStable(DB_STATEMENT), "SET foo ?"), | ||
| equalTo(maybeStable(DB_OPERATION), "SET"), | ||
| equalTo(maybeStablePeerService(), "test-peer-service"), | ||
| equalTo(SERVER_ADDRESS, host), | ||
| equalTo(SERVER_PORT, port))), | ||
| trace -> | ||
| trace.hasSpansSatisfyingExactly( | ||
| span -> | ||
| span.hasName(emitStableDatabaseSemconv() ? "GET " + host + ":" + port : "GET") | ||
| .hasKind(SpanKind.CLIENT) | ||
| .hasAttributesSatisfyingExactly( | ||
| equalTo(maybeStable(DB_SYSTEM), REDIS), | ||
| equalTo(maybeStable(DB_STATEMENT), "GET foo"), | ||
| equalTo(maybeStable(DB_OPERATION), "GET"), | ||
| equalTo(maybeStablePeerService(), "test-peer-service"), | ||
| equalTo(SERVER_ADDRESS, host), | ||
| equalTo(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(emitStableDatabaseSemconv() ? "SET " + host + ":" + port : "SET") | ||
| .hasKind(SpanKind.CLIENT) | ||
| .hasAttributesSatisfyingExactly( | ||
| equalTo(maybeStable(DB_SYSTEM), REDIS), | ||
| equalTo(maybeStable(DB_STATEMENT), "SET foo ?"), | ||
| equalTo(maybeStable(DB_OPERATION), "SET"), | ||
| equalTo(maybeStablePeerService(), "test-peer-service"), | ||
| equalTo(SERVER_ADDRESS, host), | ||
| equalTo(SERVER_PORT, port))), | ||
| trace -> | ||
| trace.hasSpansSatisfyingExactly( | ||
| span -> | ||
| span.hasName( | ||
| emitStableDatabaseSemconv() | ||
| ? "RANDOMKEY " + host + ":" + port | ||
| : "RANDOMKEY") | ||
| .hasKind(SpanKind.CLIENT) | ||
| .hasAttributesSatisfyingExactly( | ||
| equalTo(maybeStable(DB_SYSTEM), REDIS), | ||
| equalTo(maybeStable(DB_STATEMENT), "RANDOMKEY"), | ||
| equalTo(maybeStable(DB_OPERATION), "RANDOMKEY"), | ||
| equalTo(maybeStablePeerService(), "test-peer-service"), | ||
| equalTo(SERVER_ADDRESS, host), | ||
| equalTo(SERVER_PORT, port)))); | ||
| } | ||
| } | ||
10 changes: 0 additions & 10 deletions
10
...sion272/java/io/opentelemetry/javaagent/instrumentation/jedis/v2_7_2/JedisClientTest.java
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
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.