Skip to content

added support to spring amqp batch#1716

Merged
eyalkoren merged 18 commits intoelastic:masterfrom
videnkz:feature-add-support-spring-amqp-batch
Nov 2, 2021
Merged

added support to spring amqp batch#1716
eyalkoren merged 18 commits intoelastic:masterfrom
videnkz:feature-add-support-spring-amqp-batch

Conversation

@videnkz
Copy link
Contributor

@videnkz videnkz commented Mar 26, 2021

closes #1706

What does this PR do?

Checklist

  • This is an enhancement of existing features, or a new feature in existing plugins
    • I have updated CHANGELOG.asciidoc
    • I have added tests that prove my fix is effective or that my feature works
@ghost
Copy link

ghost commented Mar 26, 2021

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2021-11-02T05:36:41.598+0000

  • Duration: 73 min 14 sec

  • Commit: 1fcac13

Test stats 🧪

Test Results
Failed 0
Passed 2492
Skipped 19
Total 2511

💚 Flaky test report

Tests succeeded.

🤖 GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

  • run benchmark tests : Run the benchmark test.

  • run compatibility tests : Run the JDK Compatibility test.

  • run integration tests : Run the APM-ITs.

@codecov-io
Copy link

Codecov Report

Merging #1716 (918f877) into master (1745351) will decrease coverage by 8.11%.
The diff coverage is 33.33%.

❗ Current head 918f877 differs from pull request most recent head 76f3336. Consider uploading reports for the commit 76f3336 to get more accurate results
Impacted file tree graph

@@             Coverage Diff              @@
##             master    #1716      +/-   ##
============================================
- Coverage     69.42%   61.30%   -8.12%     
- Complexity     2789     3621     +832     
============================================
  Files           291      401     +110     
  Lines         12413    18249    +5836     
  Branches       1616     2507     +891     
============================================
+ Hits           8618    11188    +2570     
- Misses         3214     6278    +3064     
- Partials        581      783     +202     
Impacted Files Coverage Δ Complexity Δ
...apm/agent/log/shader/AbstractLogShadingHelper.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
...astic/apm/agent/log4j1/Log4j1LogShadingHelper.java 22.22% <0.00%> (-2.78%) 4.00 <0.00> (ø)
...astic/apm/agent/log4j2/Log4j2LogShadingHelper.java 11.76% <0.00%> (-2.53%) 3.00 <0.00> (ø)
...stic/apm/agent/jms/JmsMessagePropertyAccessor.java 79.16% <50.00%> (ø) 7.00 <0.00> (?)
...o/elastic/apm/agent/mdc/MdcActivationListener.java 82.27% <100.00%> (ø) 16.00 <0.00> (?)
.../apm/agent/servlet/FilterChainInstrumentation.java 100.00% <0.00%> (ø) 5.00% <0.00%> (?%)
...itmq/SpringAmqpMessageListenerInstrumentation.java 14.28% <0.00%> (ø) 4.00% <0.00%> (?%)
...ava/co/elastic/apm/opentracing/ElasticApmTags.java 0.00% <0.00%> (ø) 0.00% <0.00%> (?%)
.../elastic/apm/agent/servlet/ServletGlobalState.java 75.00% <0.00%> (ø) 2.00% <0.00%> (?%)
...t/urlconnection/UrlConnectionPropertyAccessor.java 0.00% <0.00%> (ø) 0.00% <0.00%> (?%)
... and 109 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1745351...76f3336. Read the comment docs.

Copy link
Contributor

@eyalkoren eyalkoren left a comment

Choose a reason for hiding this comment

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

Nice! 👏
A few minor comments, overall looks really good!
I am pushing a small fix that will allow testing.

Comment on lines 51 to 53
if (message == null) {
return message;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

message shouldn't be null.
In such case, next() would throw NoSuchElementException, so you can just remove this check and rely on the original implementation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

deleted

Comment on lines 5 to 8
public interface MessageBatchHelper<MSG> {

List<MSG> wrapMessageBatchList(List<MSG> messageBatchList);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

There is no need for a generic interface, as long as the helpers are only being referenced by advices.
The advice classes can depend on helpers with specific AMQP dependencies (as opposed to the instrumentation classes)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

deleted

}

static class BaseAdvice {
protected static final MessageBatchHelper messageBatchHelper;
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 on the batch advice instead of the base advice?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved to SpringAmqpBatchMessageListenerInstrumentation$MessageListenerContainerWrappingAdvice

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

public interface SpringAmqpTransactionHelper {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this interface required? Can't we just use the single impl as is?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, this interface not required. Deleted

Comment on lines 55 to 57
if (messageProperties == null) {
return message;
}
Copy link
Contributor

@eyalkoren eyalkoren Jun 6, 2021

Choose a reason for hiding this comment

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

Why? We should create a transaction anyway - a root transaction if there is no traceparent property, or child transaction if there is. We already do that (create a transaction when there is no property). The same goes for SpringAmqpMessageListenerInstrumentation - we should allow null properties.
Please fix SpringAmqpTransactionHelper#createTransaction() instead to allow for null properties (and treat the same as if there are properties without context property).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@eyalkoren eyalkoren force-pushed the feature-add-support-spring-amqp-batch branch from 1eec8f3 to 0ccf528 Compare June 20, 2021 13:43
@eyalkoren
Copy link
Contributor

Thanks for applying the review comments ❤️

Please see my last commits - I only removed another interface, changed helper names, added to CHANGELOG and added a test for distributed tracing.

Please let me know if you disagree with any of this.

@SylvainJuge SylvainJuge added the new-feature New feature label Aug 30, 2021
@eyalkoren
Copy link
Contributor

run elasticsearch-ci/docs

@eyalkoren eyalkoren enabled auto-merge (squash) November 1, 2021 17:40
@eyalkoren
Copy link
Contributor

@kananindzya we removed our AssignTo annotations and migrated to use the new Byte Buddy AssignReturned annotations - see other instrumentations and please it can build and test pass.
Sorry about that 🙁

auto-merge was automatically disabled November 2, 2021 05:36

Head branch was pushed to by a user without write access

@videnkz
Copy link
Contributor Author

videnkz commented Nov 2, 2021

@kananindzya we removed our AssignTo annotations and migrated to use the new Byte Buddy AssignReturned annotations - see other instrumentations and please it can build and test pass. Sorry about that slightly_frowning_face

fixed

@eyalkoren
Copy link
Contributor

run elasticsearch-ci/docs

@eyalkoren eyalkoren enabled auto-merge (squash) November 2, 2021 08:51
@eyalkoren eyalkoren merged commit c0a4ee6 into elastic:master Nov 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4 participants