Skip to content

provide cassandra java driver 3.x plugin#3410

Merged
wu-sheng merged 14 commits intoapache:masterfrom
stone-wlg:features/cassandra-java-driver-3.x-plugin
Sep 12, 2019
Merged

provide cassandra java driver 3.x plugin#3410
wu-sheng merged 14 commits intoapache:masterfrom
stone-wlg:features/cassandra-java-driver-3.x-plugin

Conversation

@stone-wlg
Copy link
Contributor

Please answer these questions before submitting pull request

  • Why submit this pull request?
  • Bug fix
  • New feature provided
  • Improve performance
    _

New feature or improvement

@stone-wlg stone-wlg changed the title add cassandra java driver 3.x plugin provide cassandra java driver 3.x plugin Sep 4, 2019
@stone-wlg stone-wlg mentioned this pull request Sep 4, 2019
3 tasks
@kezhenxu94 kezhenxu94 added agent Language agent related. feature New feature plugin Plugin for agent or collector. Be used to extend the capabilities of default implementor. labels Sep 4, 2019
List<InetSocketAddress> inetSocketAddresses = (List<InetSocketAddress>) allArguments[1];
StringBuilder hosts = new StringBuilder();
for (InetSocketAddress inetSocketAddress : inetSocketAddresses) {
hosts.append(inetSocketAddress.getHostName() + ":" + inetSocketAddress.getPort() + ",");
Copy link
Member

Choose a reason for hiding this comment

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

It does not matter, but I suggest to do like that.
hosts.append(inetSocketAddress.getHostName()).append(":").append(inetSocketAddress.getPort()).append(",");

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, thanks.

@wu-sheng
Copy link
Member

wu-sheng commented Sep 7, 2019

@dmsolr Any update?

@zhaoyuguang Please run this codes test case again. I want to see any good luck this time.

@dmsolr
Copy link
Member

dmsolr commented Sep 7, 2019

@wu-sheng, I think you want to ping @stone-wlg , right?
I had a look deeply, I think it is okay.

@wu-sheng
Copy link
Member

wu-sheng commented Sep 7, 2019

@dmsolr I was really pinging you, to make sure you don't have a further review to do. Why are you still awake at this moment?

@wu-sheng
Copy link
Member

wu-sheng commented Sep 7, 2019

@stone-wlg Do you update this PR to support async execution? Do we have the accurate execution time now?

@dmsolr
Copy link
Member

dmsolr commented Sep 7, 2019

haha, a glace before sleep. @wu-sheng , have a good dream.

@stone-wlg
Copy link
Contributor Author

@stone-wlg Do you update this PR to support async execution? Do we have the accurate execution time now?

yes, we have.

@wu-sheng
Copy link
Member

wu-sheng commented Sep 8, 2019

yes, we have.

But I could not find span#prepareForAsync. Is there unnecessary now?

@stone-wlg
Copy link
Contributor Author

stone-wlg commented Sep 8, 2019

yes, we have.

But I could not find span#prepareForAsync. Is there unnecessary now?

No, the async key is the getUninterruptibly method. it likes lazy mode or cursor of database.

@wu-sheng
Copy link
Member

wu-sheng commented Sep 8, 2019

No, the key is the getUninterruptibly method. it likes lazy mode or cursor of database.

OK. That is another story. I am thinking about this too. But not related to this PR, could be done in a different way.

@stone-wlg
Copy link
Contributor Author

No, the key is the getUninterruptibly method. it likes lazy mode or cursor of database.

OK. That is another story. I am thinking about this too. But not related to this PR, could be done in a different way.

Currently, i intercept getUninterruptibly method by LOCAL METHOD in skywalking. So we can get accurate execution time whatever sync or async way.

@wu-sheng
Copy link
Member

wu-sheng commented Sep 8, 2019

Let's wait for test case and 6.4.0 shipped. We are only fixing bugs before 6.4.0 release.

@wu-sheng
Copy link
Member

wu-sheng commented Sep 8, 2019

Currently, i intercept getUninterruptibly method by LOCAL METHOD in skywalking. So we can get accurate execution time whatever sync or async way.

Make sense for now. I am thinking about a special tag for this kind of OP(cursor reading)

@stone-wlg
Copy link
Contributor Author

Let's wait for test case and 6.4.0 shipped. We are only fixing bugs before 6.4.0 release.

Let's wait for test case and 6.4.0 shipped. We are only fixing bugs before 6.4.0 release.

ok

@stone-wlg
Copy link
Contributor Author

Currently, i intercept getUninterruptibly method by LOCAL METHOD in skywalking. So we can get accurate execution time whatever sync or async way.

Make sense for now. I am thinking about a special tag for this kind of OP(cursor reading)

Got it.

@stone-wlg
Copy link
Contributor Author

@wu-sheng Currently, i am working monitor whatever log, metric and trace. i am thinking that is it necessary to add MQ(kafka) between skywalking agent and OAP? this is maybe another topic, i just want to know in a short word, thanks

@wu-sheng
Copy link
Member

wu-sheng commented Sep 8, 2019

Currently, i am working monitor whatever log, metric and trace. i am thinking that is it necessary to add MQ(kafka) between skywalking agent and OAP? this is maybe another topic, i just want to know in a short word, thanks

Most APM didn't do this, because it doesn't necessarily. If you want to discuss detail, feel free to open an issue, we could discuss there and move it to FAQ in case others want to know too.

Copy link
Member

@kezhenxu94 kezhenxu94 left a comment

Choose a reason for hiding this comment

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

Just for reminder, it seems that there are pairs of async and sync methods in Cassandra, so please consider both of them when you intercept methods (consider whether they have async counterparts or not).

To name a few:

  • com.datastax.driver.core.Cluster#connect() vs com.datastax.driver.core.Cluster#connectAsync()
  • com.datastax.driver.core.SessionManager#execute vs com.datastax.driver.core.SessionManager#executeAsync

P.S. seems that the sync version simply calls the async version and wait for the result, so it should be able to just intercept the async version, maybe I'm wrong? Just a hint :)

@Override
public ElementMatcher<MethodDescription> getMethodsMatcher() {
return named("execute").and(takesArgumentWithType(0, "com.datastax.driver.core.Statement"))
.or(named("executeAsync").and(takesArgumentWithType(0, "com.datastax.driver.core.Statement")));
Copy link
Member

Choose a reason for hiding this comment

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

executeAsync calls execute at the bottom, so you should be able to only intercept execute (minor issue)

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 think the key is the or method. Does it intercept both execute and executeAsync methods, or only intercept execute methods. right ?
but my test result is both.

@stone-wlg
Copy link
Contributor Author

Just for reminder, it seems that there are pairs of async and sync methods in Cassandra, so please consider both of them when you intercept methods (consider whether they have async counterparts or not).

To name a few:

  • com.datastax.driver.core.Cluster#connect() vs com.datastax.driver.core.Cluster#connectAsync()
  • com.datastax.driver.core.SessionManager#execute vs com.datastax.driver.core.SessionManager#executeAsync

P.S. seems that the sync version simply calls the async version and wait for the result, so it should be able to just intercept the async version, maybe I'm wrong? Just a hint :)

exactly. sync version call async version and wait for results.
So you mean that only intercept async version is enough, right?
there are 2 questions, as below

  1. if i intercept both sync and async as EXIT SPAN what is going on in skywalking?
  2. if i only intercept async version, there is a little bit confuse on UI. when user call sync version, but tracing on UI will display async version, is there a standard way to solve it?
    thanks.

@wu-sheng
Copy link
Member

if i intercept both sync and async as EXIT SPAN what is going on in skywalking?

Depend on what kind of codes you are written, basically, override happens. If sync calls async then, span set as sync name. Otherwise, async. Does async interceptor need #asyncFinish?

if i only intercept async version, there is a little bit confuse on UI. when user call sync version, but tracing on UI will display async version, is there a standard way to solve it?

If you only did this, you could just don't separate the sync and async in UI, then should be fine always. You could choose to do it separately or only async.

@stone-wlg
Copy link
Contributor Author

stone-wlg commented Sep 12, 2019

if i intercept both sync and async as EXIT SPAN what is going on in skywalking?

Depend on what kind of codes you are written, basically, override happens. If sync calls async then, span set as sync name. Otherwise, async. Does async interceptor need #asyncFinish?

if i only intercept async version, there is a little bit confuse on UI. when user call sync version, but tracing on UI will display async version, is there a standard way to solve it?

If you only did this, you could just don't separate the sync and async in UI, then should be fine always. You could choose to do it separately or only async.

Ok, override is what i want, and test result is LGTM.
image
image
async interceptor do not need #asyncFinish

@wu-sheng
Copy link
Member

@stone-wlg Your comment format is not clear. Could you reformat it?

@stone-wlg
Copy link
Contributor Author

@stone-wlg Your comment format is not clear. Could you reformat it?

OK

@wu-sheng
Copy link
Member

You need to update this PR and test cases.

@stone-wlg
Copy link
Contributor Author

You need to update this PR and test cases.

Ok, Done
currently only support 3.7.2 version

@wu-sheng
Copy link
Member

I think the plugins supporting more versions, right? Just in test case, we plan to merge one version.

@zhaoyuguang run tests again.

@kezhenxu94 recheck please.

@stone-wlg
Copy link
Contributor Author

stone-wlg commented Sep 12, 2019

versions

yes, i have tested 4 versions, all of them are passed on my pc.

@zhaoyuguang
Copy link
Member

I had triggered the auto tests, let's wait for the result

@SkyWalkingRobot
Copy link

Here is the test report and validate logs

kezhenxu94
kezhenxu94 previously approved these changes Sep 12, 2019
@wu-sheng
Copy link
Member

@stone-wlg Welcome to be 156th contributor. Look forward to more contributions from you.

* [Solr](https://github.com/apache/lucene-solr/)
* [SolrJ](https://github.com/apache/lucene-solr/tree/master/solr/solrj) 7.x
* [Cassandra](https://github.com/apache/cassandra) 3.x
* [cassandra-java-driver](https://github.com/datastax/java-driver) 3.7.2
Copy link
Member

Choose a reason for hiding this comment

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

One nit, we should list all you tested version, don't need to leave 3.7.2 due to test issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, done

@stone-wlg
Copy link
Contributor Author

@stone-wlg Welcome to be 156th contributor. Look forward to more contributions from you.

Thanks, 156 is a good number for me

@stone-wlg stone-wlg dismissed stale reviews from kezhenxu94 and wu-sheng via 90a02da September 12, 2019 19:47
@wu-sheng
Copy link
Member

/run e2e

@wu-sheng
Copy link
Member

/run ci

@wu-sheng
Copy link
Member

/run e2e

@wu-sheng wu-sheng merged commit bb0b3d3 into apache:master Sep 12, 2019
@wu-sheng
Copy link
Member

@stone-wlg
Copy link
Contributor Author

@stone-wlg The twitter belongs to you, https://twitter.com/ASFSkyWalking/status/1172288313559928832

Cool, thanks. Happy Mid-Autumn Festival

@wu-sheng wu-sheng added this to the 6.5.0 milestone Sep 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent Language agent related. feature New feature plugin Plugin for agent or collector. Be used to extend the capabilities of default implementor.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants