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

Add lettuce 5.2 instrumentation that uses lettuce's native tracing functionality. #535

Merged
merged 14 commits into from
Jun 18, 2020

Conversation

anuraaga
Copy link
Contributor

@anuraaga anuraaga commented Jun 16, 2020

If muzzle lets me through in one shot I'd be amazed :)

While Tracing was added in 5.1, including the command was added in 5.2, and it doesn't seeem worth branching on this since this is new instrumentation, I just went ahead and targeted 5.2.

Differences in tracing

  • connection and some system commands aren't traced.
  • net / command tags are filled in. A couple of events that lettuce provides are too
  • No corner cases, while I preserved the async/reactive tests, there isn't as much value since there is no special-casing for the APIs

Fixes #408
Fixes #504

instrumentation/lettuce/lettuce-5.2/lettuce-5.2.gradle Outdated Show resolved Hide resolved
when:
ConnectionFuture connectionFuture = testConnectionClient.connectAsync(StringCodec.UTF8,
new RedisURI(HOST, port, 3, TimeUnit.SECONDS))
StatefulConnection connection = connectionFuture.get()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can block indefinitely, not good

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't tests have a test timeout?

when:
ConnectionFuture connectionFuture = testConnectionClient.connectAsync(StringCodec.UTF8,
new RedisURI(HOST, incorrectPort, 3, TimeUnit.SECONDS))
StatefulConnection connection = connectionFuture.get()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

"net.peer.ip" "127.0.0.1"
"net.peer.port" port
"db.type" "redis"
"db.statement" "key<TESTSETKEY> value<TESTSETVAL>"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately the interface doesn't provide RedisURI, I have filed an issue for it

redis/lettuce#1312

I think user and db_index are less commonly used with redis and we can probably live without them for now.

Copy link
Member

@trask trask left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @anuraaga, this looks great!

for the muzzle issues, try locally:

./gradlew :instrumentation:lettuce:lettuce-5.0:muzzle
./gradlew :instrumentation:lettuce:lettuce-5.2:muzzle

and post back with any questions, i'll answer and add those questions/answers to the muzzle faq i'm building for #536

Comment on lines 150 to 156
@Nullable private final Span parent;

@Nullable private OpenTelemetryEndpoint endpoint;
@Nullable private String name;

@Nullable private List<Object> events;
@Nullable private List<String> tags;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do u think about replacing parent, endpoint, name and tags with Span.Builder?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately had to keep name since spanBuilder doesn't allow setting it, and some awkwardness for endpoint, but it seems to still be worth it.

Comment on lines 171 to 176
event(0) {
eventName "redis.encode.start"
}
event(1) {
eventName "redis.encode.end"
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these events worth capturing, given they are not part of the semantic conventions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tend to lean towards instrumenting what we can, and users can use a downstream mechanism, e.g. span processor, to remove fields they don't need. Might help someone and while data can be filtered, there's no way to work around the lack of instrumentation.

Copy link
Contributor Author

@anuraaga anuraaga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I realized that this instrumentation can be applied to 5.1 just fine, the new method on the SPI will just be ignored, so I reduced the version floor. It also made it simpler to restrict the instrumentation for 5.0 and 5.1.

instrumentation/lettuce/lettuce-5.2/lettuce-5.2.gradle Outdated Show resolved Hide resolved
Comment on lines 150 to 156
@Nullable private final Span parent;

@Nullable private OpenTelemetryEndpoint endpoint;
@Nullable private String name;

@Nullable private List<Object> events;
@Nullable private List<String> tags;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately had to keep name since spanBuilder doesn't allow setting it, and some awkwardness for endpoint, but it seems to still be worth it.

when:
ConnectionFuture connectionFuture = testConnectionClient.connectAsync(StringCodec.UTF8,
new RedisURI(HOST, port, 3, TimeUnit.SECONDS))
StatefulConnection connection = connectionFuture.get()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't tests have a test timeout?

Comment on lines 171 to 176
event(0) {
eventName "redis.encode.start"
}
event(1) {
eventName "redis.encode.end"
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tend to lean towards instrumenting what we can, and users can use a downstream mechanism, e.g. span processor, to remove fields they don't need. Might help someone and while data can be filtered, there's no way to work around the lack of instrumentation.

"net.peer.ip" "127.0.0.1"
"net.peer.port" port
"db.type" "redis"
"db.statement" "key<TESTSETKEY> value<TESTSETVAL>"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately the interface doesn't provide RedisURI, I have filed an issue for it

redis/lettuce#1312

I think user and db_index are less commonly used with redis and we can probably live without them for now.

}

dependencies {
compileOnly group: 'io.lettuce', name: 'lettuce-core', version: '5.2.0.RELEASE'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be 5.1.0.RELEASE?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah guess so

Anuraag Agrawal added 2 commits June 17, 2020 16:24
@anuraaga
Copy link
Contributor Author

Codenarc seems to have crossed a threshold due to the package name having an underscore. But I notice this pattern throughout the repo - can we disable this check?


Rule Name | Priority | Line # | Source Line / Message
-- | -- | -- | --
PackageName | 2 |   | [MSG]package=io.opentelemetry.auto.instrumentation.lettuce.v5_1
PackageName | 2 |   | [MSG]package=io.opentelemetry.auto.instrumentation.lettuce.v5_1
PackageName | 2 |   | [MSG]package=io.opentelemetry.auto.instrumentation.lettuce.v5_1
PackageName | 2 |   | [MSG]package=io.opentelemetry.auto.instrumentation.lettuce.v5_1
PackageName | 2 |   | [MSG]package=io.opentelemetry.auto.instrumentation.lettuce.v5_1
PackageName | 2 |   | [MSG]package=io.opentelemetry.auto.instrumentation.lettuce.v5_1
PackageName | 2 |   | [MSG]package=io.opentelemetry.auto.instrumentation.lettuce.v5_1
PackageName | 2 |   | [MSG]package=io.opentelemetry.auto.instrumentation.lettuce.v5_1


  | PackageName | Verifies  that the package name for a class matches a regular expression. By  default it checks that the package name consists of only lowercase  letters, separated by periods. The regex property specifies the regular expression used to validate the package name. The packageNameRequired property indicates whether a package name declaration is required for all classes.
-- | -- | --

@trask
Copy link
Member

trask commented Jun 17, 2020

nice muzzle work! 😄

Codenarc seems to have crossed a threshold due to the package name having an underscore. But I notice this pattern throughout the repo - can we disable this check?

yes, please do

@anuraaga
Copy link
Contributor Author

anuraaga commented Jun 18, 2020

Looks ready now :)

@iNikem iNikem merged commit 9a2a0b5 into open-telemetry:master Jun 18, 2020
iNikem pushed a commit to iNikem/opentelemetry-java-instrumentation that referenced this pull request Jun 19, 2020
…nctionality. (open-telemetry#535)

* Copy Lettuce 5.0 to start 5.1 instrumentation

* Begin tracing adapter implementation

Co-authored-by: Dustin Neray <[email protected]>

* Set floor to 5.2 instead

* Move around

* Finish

* Cleanups

* Instrument 5.1+ instead

* Cleanup

* 5.1

* Remove latestDepTest from lettuce-5.0 since we have a newer lettuce-5.1.

* Remove

* Remove package check

* Spotless

Co-authored-by: Dustin Neray <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

lettuce-5.0 tests run only on java 8 Capture redis key accessed in lettuce autoinstrumentation
3 participants