Skip to content

Instrument cassandra executeReactive method#6441

Merged
trask merged 22 commits into
open-telemetry:mainfrom
SimoneGiusso:instrumenting-executereactive-cassandra-method
Mar 8, 2023
Merged

Instrument cassandra executeReactive method#6441
trask merged 22 commits into
open-telemetry:mainfrom
SimoneGiusso:instrumenting-executereactive-cassandra-method

Conversation

@SimoneGiusso

@SimoneGiusso SimoneGiusso commented Aug 8, 2022

Copy link
Copy Markdown
Contributor

It follows the issue I opened some days ago.

The executeReactive method use the same processor used by executeAsync (see here) and wrap the callback in the DefaultReactiveResultSet publisher.

Here I'm simply overriding the executeReactive method doing the same thing: call the already instrumented executeAsync method and wrapping the callback using the DefaultReactiveResultSet publisher.

I did an upgrade of the java-driver-core library to have TracingCqlSession.java extending the ReactiveSession. I have to probably rename the cassandra-4.0 module in cassandra-4.14 but I'll let you confirm this. -> Cassandra-4.4 is enough.

@SimoneGiusso SimoneGiusso requested a review from a team August 8, 2022 06:21
@linux-foundation-easycla

linux-foundation-easycla Bot commented Aug 8, 2022

Copy link
Copy Markdown

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: SimoneGiusso / name: Simone Giusso (cf9763c)

@SimoneGiusso SimoneGiusso force-pushed the instrumenting-executereactive-cassandra-method branch 2 times, most recently from 1000fdc to 139043d Compare August 8, 2022 08:20
@trask

trask commented Aug 8, 2022

Copy link
Copy Markdown
Member

thx @SimoneGiusso!

I have to probably rename the cassandra-4.0 module in cassandra-4.14 but I'll let you confirm this.

we probably don't want to drop support for earlier cassandra 4.x versions, see our reasoning under the "Javaagent instrumentation" section here:
https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/VERSIONING.md#dropping-support-for-older-library-versions

instead, go ahead and create a new module cassandra-4.14 that contains just the reactive instrumentation. it's a little odd to have overlapping instrumentation modules (4.0 will still apply to 4.14), but we have a couple of other cases like this (e.g. mongo) and it's the best approach we have come up with to handle this kind of case

@SimoneGiusso

Copy link
Copy Markdown
Contributor Author

I see. I'll probably able to do this change in two weeks, when I'll be back from vacations (I won't bring my laptop with me).

@SimoneGiusso SimoneGiusso force-pushed the instrumenting-executereactive-cassandra-method branch from 139043d to 634755c Compare August 21, 2022 18:57
…sandraTelemetry & CassandraTelemetryBuilder files
Comment thread instrumentation/cassandra/cassandra-4.14/javaagent/build.gradle.kts Outdated
@trask

trask commented Oct 23, 2022

Copy link
Copy Markdown
Member

hi @SimoneGiusso! just checking in to see if you are still working on this? (looks like a great addition)

definitely let us know if you have any questions, thx!

@hansh0801

Copy link
Copy Markdown

track

@linux-foundation-easycla

linux-foundation-easycla Bot commented Nov 14, 2022

Copy link
Copy Markdown

CLA Signed

The committers listed above are authorized under a signed CLA.

@SimoneGiusso SimoneGiusso force-pushed the instrumenting-executereactive-cassandra-method branch from 7113aa6 to 926ed7e Compare November 14, 2022 21:07
@linux-foundation-easycla

linux-foundation-easycla Bot commented Nov 14, 2022

Copy link
Copy Markdown

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: SimoneGiusso / name: Simone Giusso (1aa92b9)

@SimoneGiusso SimoneGiusso force-pushed the instrumenting-executereactive-cassandra-method branch 2 times, most recently from 1aa92b9 to 128f0f6 Compare November 14, 2022 22:24
@github-actions github-actions Bot requested a review from theletterf November 15, 2022 19:36
@SimoneGiusso SimoneGiusso force-pushed the instrumenting-executereactive-cassandra-method branch from 2891ad0 to 128f0f6 Compare November 15, 2022 19:42
@SimoneGiusso SimoneGiusso force-pushed the instrumenting-executereactive-cassandra-method branch from 5e1eb0b to 18a26d3 Compare November 15, 2022 22:07
@SimoneGiusso SimoneGiusso force-pushed the instrumenting-executereactive-cassandra-method branch from 18a26d3 to 0ca0549 Compare November 15, 2022 22:12
@SimoneGiusso SimoneGiusso force-pushed the instrumenting-executereactive-cassandra-method branch from 46b2e88 to 8841346 Compare November 16, 2022 22:46
@SimoneGiusso SimoneGiusso force-pushed the instrumenting-executereactive-cassandra-method branch from 3bc4320 to 5f03349 Compare November 17, 2022 21:17

@trask trask left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

hey @SimoneGiusso,

the change below should get the tests running

Comment thread instrumentation/cassandra/testing/build.gradle.kts Outdated
@SimoneGiusso SimoneGiusso force-pushed the instrumenting-executereactive-cassandra-method branch from febca6e to 3e8ea44 Compare November 27, 2022 16:56
Comment on lines +173 to +175
public ReactiveResultSet executeReactive(Statement<?> statement) {
return new DefaultReactiveResultSet(() -> originalTracingCqlSession.executeAsync(statement));
}

@SimoneGiusso SimoneGiusso Nov 27, 2022

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is the core change to instrument the new reactive method.

…der the new library module (removing 'javaagent' from the package path)
@SimoneGiusso SimoneGiusso force-pushed the instrumenting-executereactive-cassandra-method branch from ab7274c to 74fd803 Compare November 27, 2022 18:11
@SimoneGiusso

SimoneGiusso commented Nov 27, 2022

Copy link
Copy Markdown
Contributor Author

Hi @trask and @mateuszrzeszutek.

To sum-up: we are instrumenting the executeReactive method (introduced in Cassandra 4.4). It consists in "simply" enrich the current *.v4_0.TracingCqlSession already implemented and add a new test for this method.

We have decided to not modify the current cassandra-4.0 module but to create a new cassandra-4.4 module. For this reason a new testing module has been created which groups all the common tests between these two modules (i.e. all the tests in the current cassandra-4.0).

The new entry point for both modules is the CassandraTelemetry class (following the @mateuszrzeszutek's suggestions). Two distinct classes are needed, one for each module, to create two distinct TracingCqlSession objects (see CassandraTelemetry.wrap(). Inheritance here has been used to:

  • Set the instrumenter's name.
  • Share the code to create the instrumenter (and avoid duplicating package private classes such as CassandraAttributesExtractor).

The new TracingCqlSession simply wrap the original TracingCqlSession and enables tracing of the executeReactive method. In other words cassandra-4.4 is offering what is already offered by cassandra-4.0, with the addition of this executeReactive method.

Could you please review the PR (I should applied the previous @mateuszrzeszutek's comments)? Fell free to ask questions.

Thanks!

@SimoneGiusso SimoneGiusso force-pushed the instrumenting-executereactive-cassandra-method branch from ccf1cd7 to 74fd803 Compare November 27, 2022 18:48
@hansh0801

Copy link
Copy Markdown

track

@SimoneGiusso

SimoneGiusso commented Jan 18, 2023

Copy link
Copy Markdown
Contributor Author

Hi, @trask @mateuszrzeszutek. Did you have some time to check this PR? I think we are close to merge this branch. All tests are passing and I should have applied almost all your suggestions.

@trask

trask commented Feb 24, 2023

Copy link
Copy Markdown
Member

hi @SimoneGiusso sorry for the long delay, we will try to get to this in the next week

@trask

trask commented Feb 27, 2023

Copy link
Copy Markdown
Member

hey @SimoneGiusso! I pushed some changes to your branch:

  • merged in the new cassandra Java tests
  • added testing for the library instrumentation
  • changed library instrumentation to target 4.4 instead of 4.0 (we generally want library instrumentation to target the latest, though this does mean now there's some code duplication between the 4.0 and 4.4 implementation, I think this is ok, I don't think we currently have a pattern for sharing code between a later library version and an earlier javaagent version)


public abstract class AbstractCassandra44Test extends AbstractCassandraTest {

// TODO add reactive tests here

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can you rewrite the couple of reactive groovy tests here in Java?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines +51 to +53
// TODO can this be rewritten using newer API?
@SuppressWarnings("deprecation")
Statement<?> statement = executionInfo.getStatement();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@SimoneGiusso can you look at this to see if there's a better way to do this in 4.4+

@SimoneGiusso SimoneGiusso Feb 27, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

They made ExecutionInfo compatible with any Request type, and the current deprecated method just do a cast. We can do the same.

8593fe4

@trask

trask commented Feb 27, 2023

Copy link
Copy Markdown
Member

it would be great to add a README for the new library instrumentation, see #6947, but we can merge without it too

@SimoneGiusso SimoneGiusso force-pushed the instrumenting-executereactive-cassandra-method branch from c7e7735 to 8593fe4 Compare February 27, 2023 22:26
@trask trask merged commit 1a7e0f3 into open-telemetry:main Mar 8, 2023
@trask

trask commented Mar 8, 2023

Copy link
Copy Markdown
Member

thx @SimoneGiusso!

@SimoneGiusso

Copy link
Copy Markdown
Contributor Author

Happy to contribute. Thank you for your help and reviews @trask!

@SimoneGiusso SimoneGiusso deleted the instrumenting-executereactive-cassandra-method branch March 15, 2023 19:39
@SimoneGiusso SimoneGiusso changed the title Instrumenting cassandra executeReactive method Instrument cassandra executeReactive method Aug 2, 2023
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.

5 participants