-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1883 from newrelic/1780_subscribeon_fix
Resolves various thread hop problems with Spring Reactor call chaining.
- Loading branch information
Showing
4 changed files
with
157 additions
and
1 deletion.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...y-reactor-0.9.0/src/main/java/reactor/core/publisher/FluxMapFuseable_Instrumentation.java
This file contains 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
49 changes: 49 additions & 0 deletions
49
...y-reactor-0.9.0/src/main/java/reactor/core/publisher/MonoSubscribeOn_Instrumentation.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* | ||
* * Copyright 2024 New Relic Corporation. All rights reserved. | ||
* * SPDX-License-Identifier: Apache-2.0 | ||
* | ||
*/ | ||
|
||
package reactor.core.publisher; | ||
|
||
import com.newrelic.api.agent.NewRelic; | ||
import com.newrelic.api.agent.Token; | ||
import com.newrelic.api.agent.weaver.MatchType; | ||
import com.newrelic.api.agent.weaver.NewField; | ||
import com.newrelic.api.agent.weaver.Weave; | ||
import com.newrelic.api.agent.weaver.WeaveAllConstructors; | ||
import com.newrelic.api.agent.weaver.Weaver; | ||
|
||
@Weave(type = MatchType.ExactClass, originalName = "reactor.core.publisher.MonoSubscribeOn") | ||
abstract class MonoSubscribeOn_Instrumentation { | ||
|
||
@Weave(type = MatchType.ExactClass, originalName = "reactor.core.publisher.MonoSubscribeOn$SubscribeOnSubscriber") | ||
static final class SubscribeOnSubscriber_Instrumentation { | ||
@NewField | ||
private Token token; | ||
|
||
@WeaveAllConstructors | ||
SubscribeOnSubscriber_Instrumentation() { | ||
if (NewRelic.getAgent().getTransaction() != null && token == null) { | ||
token = NewRelic.getAgent().getTransaction().getToken(); | ||
} | ||
} | ||
|
||
public void run () { | ||
if (token != null) { | ||
Boolean result = token.linkAndExpire(); | ||
token = null; | ||
} | ||
Weaver.callOriginal(); | ||
} | ||
|
||
public void cancel () { | ||
if (token != null) { | ||
token.linkAndExpire(); | ||
token = null; | ||
} | ||
Weaver.callOriginal(); | ||
} | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
...n/reactor-3.3.0/src/main/java/reactor/core/publisher/FluxMapFuseable_Instrumentation.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* | ||
* * Copyright 2024 New Relic Corporation. All rights reserved. | ||
* * SPDX-License-Identifier: Apache-2.0 | ||
* | ||
*/ | ||
|
||
package reactor.core.publisher; | ||
|
||
import com.newrelic.agent.bridge.AgentBridge; | ||
import com.newrelic.api.agent.NewRelic; | ||
import com.newrelic.api.agent.Token; | ||
import com.newrelic.api.agent.weaver.MatchType; | ||
import com.newrelic.api.agent.weaver.NewField; | ||
import com.newrelic.api.agent.weaver.Weave; | ||
import com.newrelic.api.agent.weaver.WeaveAllConstructors; | ||
import com.newrelic.api.agent.weaver.Weaver; | ||
|
||
@Weave(type = MatchType.ExactClass, originalName = "reactor.core.publisher.FluxMapFuseable") | ||
abstract class FluxMapFuseable_Instrumentation { | ||
|
||
@Weave(type = MatchType.ExactClass, originalName = "reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber") | ||
static final class MapFuseableSubscriber_Instrumentation<T, R> { | ||
@NewField | ||
private Token token; | ||
|
||
@WeaveAllConstructors | ||
MapFuseableSubscriber_Instrumentation() { | ||
if (AgentBridge.getAgent().getTransaction(false) != null && token == null) { | ||
token = NewRelic.getAgent().getTransaction().getToken(); | ||
} | ||
} | ||
|
||
public void onComplete() { | ||
if (token != null) { | ||
token.linkAndExpire(); | ||
token = null; | ||
} | ||
Weaver.callOriginal(); | ||
} | ||
|
||
public void onNext(T t) { | ||
if (token != null) { | ||
token.linkAndExpire(); | ||
token = null; | ||
} | ||
Weaver.callOriginal(); | ||
} | ||
|
||
public void onError(Throwable t) { | ||
if (token != null) { | ||
token.linkAndExpire(); | ||
token = null; | ||
} | ||
Weaver.callOriginal(); | ||
} | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
...n/reactor-3.3.0/src/main/java/reactor/core/publisher/MonoSubscribeOn_Instrumentation.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* | ||
* * Copyright 2024 New Relic Corporation. All rights reserved. | ||
* * SPDX-License-Identifier: Apache-2.0 | ||
* | ||
*/ | ||
|
||
package reactor.core.publisher; | ||
|
||
import com.newrelic.api.agent.NewRelic; | ||
import com.newrelic.api.agent.Token; | ||
import com.newrelic.api.agent.weaver.MatchType; | ||
import com.newrelic.api.agent.weaver.NewField; | ||
import com.newrelic.api.agent.weaver.Weave; | ||
import com.newrelic.api.agent.weaver.WeaveAllConstructors; | ||
import com.newrelic.api.agent.weaver.Weaver; | ||
|
||
@Weave(type = MatchType.ExactClass, originalName = "reactor.core.publisher.MonoSubscribeOn") | ||
abstract class MonoSubscribeOn_Instrumentation { | ||
|
||
@Weave(type = MatchType.ExactClass, originalName = "reactor.core.publisher.MonoSubscribeOn$SubscribeOnSubscriber") | ||
static final class SubscribeOnSubscriber_Instrumentation { | ||
@NewField | ||
private Token token; | ||
|
||
@WeaveAllConstructors | ||
SubscribeOnSubscriber_Instrumentation() { | ||
if (NewRelic.getAgent().getTransaction() != null && token == null) { | ||
token = NewRelic.getAgent().getTransaction().getToken(); | ||
} | ||
} | ||
|
||
public void run () { | ||
if (token != null) { | ||
Boolean result = token.linkAndExpire(); | ||
token = null; | ||
} | ||
Weaver.callOriginal(); | ||
} | ||
|
||
public void cancel () { | ||
if (token != null) { | ||
token.linkAndExpire(); | ||
token = null; | ||
} | ||
Weaver.callOriginal(); | ||
} | ||
} | ||
} |