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

[#8930] Update lettuce reactive #8942

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion agent-testweb/bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

<properties>
<jedis.version>2.4.2</jedis.version>
<lettuce.version>5.1.2.RELEASE</lettuce.version>
<lettuce.version>6.1.5.RELEASE</lettuce.version>
<cassandra.driver.version>2.1.7.1</cassandra.driver.version>
<dubbo.version>2.5.3</dubbo.version>
<mongo.driver.version>3.9.0</mongo.driver.version>
Expand Down
1 change: 1 addition & 0 deletions agent-testweb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
<module>elasticsearch-8-plugin-testweb</module>
<module>postgresql-plugin-testweb</module>
<module>undertow-plugin-testweb</module>
<module>redis-lettuce-plugin-testweb</module>
</modules>

<dependencyManagement>
Expand Down
48 changes: 48 additions & 0 deletions agent-testweb/redis-lettuce-plugin-testweb/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.navercorp.pinpoint</groupId>
<artifactId>pinpoint-agent-testweb</artifactId>
<version>2.5.0-SNAPSHOT</version>
</parent>

<artifactId>pinpoint-redis-lettuce-plugin-testweb</artifactId>

<packaging>jar</packaging>

<properties>
<pinpoint.agent.jvmargument>
${pinpoint.agent.default.jvmargument}
</pinpoint.agent.jvmargument>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
<version>${spring.boot.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
<version>${spring.boot.version}</version>
</dependency>

<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
<version>3.0.7</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis-reactive</artifactId>
<version>2.6.2</version>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright 2022 NAVER Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.pinpoint.test.plugin;

import io.netty.handler.logging.LogLevel;
import org.springframework.cloud.gateway.config.HttpClientCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import reactor.netty.transport.logging.AdvancedByteBufFormat;

@Configuration
public class HttpClientConfig {
@Bean
public HttpClientCustomizer httpClientCustomizer() {
return httpClient -> httpClient.wiretap("reactor.netty.http.client.HttpClient", LogLevel.DEBUG, AdvancedByteBufFormat.TEXTUAL);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright 2020 NAVER Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.pinpoint.test.plugin;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class RedisLettucePluginTestStarter {

public static void main(String[] args) {
SpringApplication.run(RedisLettucePluginTestStarter.class, args);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright 2022 NAVER Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.pinpoint.test.plugin;

import org.springframework.cloud.gateway.filter.ratelimit.RedisRateLimiter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RedisRateLimiterConfig {
@Bean
public RedisRateLimiter redisRateLimiter() {
return new RedisRateLimiter(10, 10);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright 2022 NAVER Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.pinpoint.test.plugin;

import org.springframework.cloud.gateway.filter.ratelimit.KeyResolver;
import org.springframework.cloud.gateway.filter.ratelimit.RedisRateLimiter;
import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
import reactor.core.publisher.Mono;
import reactor.core.scheduler.Schedulers;

@Configuration
public class SimpleRoute {

@Bean
public RouteLocator route(RouteLocatorBuilder builder, RedisRateLimiter redisRateLimiter) {
KeyResolver keyResolver = exchange -> Mono.just("test-user");

return builder.routes()
.route("simple", r -> r.method(HttpMethod.GET).and().path("/simple")
.filters(f -> f
.addRequestHeader("foo", "bar")
.setPath("/headers")
// RequestRateLimiter 를 적용한 부분
.requestRateLimiter().configure(config -> {
config.setKeyResolver(keyResolver);
config.setRateLimiter(redisRateLimiter);
})
)
.uri("https://httpbin.org")
)
.build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Defined in commandlineArgument of agent-test pom.xml

server:
port: 18080

springdoc:
swagger-ui:
path: /

logging:
level:
reactor.netty.http.client: debug
org.springframework.cloud.gateway.filter.ratelimit: debug

spring:
redis:
cluster:
nodes:
- localhost:18001
- localhost:18002
- localhost:18003

Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,7 @@ public static AsyncContext getAsyncContext(Object object) {

public static void setAsyncContext(final AsyncContext asyncContext, final Object object) {
if (object instanceof AsyncContextAccessor) {
final AsyncContext argAsyncContext = AsyncContextAccessorUtils.getAsyncContext(object);
if (argAsyncContext == null) {
((AsyncContextAccessor) object)._$PINPOINT$_setAsyncContext(asyncContext);
}
((AsyncContextAccessor) object)._$PINPOINT$_setAsyncContext(asyncContext);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ public void after(Object target, Object[] args, Object result, Throwable throwab
}

protected void setReactorContextToTarget(final AsyncContext asyncContext, final Object target) {
final AsyncContext targetAsyncContext = ReactorContextAccessorUtils.getAsyncContext(target);
if (targetAsyncContext == null) {
ReactorContextAccessorUtils.setAsyncContext(asyncContext, target);
}
ReactorContextAccessorUtils.setAsyncContext(asyncContext, target);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,11 @@ public void after(Object target, Object[] args, Object result, Throwable throwab

// Trace reactor
protected void setReactorContextToTarget(final AsyncContext asyncContext, final Object target) {
final AsyncContext targetAsyncContext = ReactorContextAccessorUtils.getAsyncContext(target);
if (targetAsyncContext == null) {
ReactorContextAccessorUtils.setAsyncContext(asyncContext, target);
}
ReactorContextAccessorUtils.setAsyncContext(asyncContext, target);
}

// Trace subscribe() method
protected void setAsyncContextToTarget(AsyncContext asyncContext, Object target) {
final AsyncContext targetAsyncContext = AsyncContextAccessorUtils.getAsyncContext(target);
if (targetAsyncContext == null) {
AsyncContextAccessorUtils.setAsyncContext(asyncContext, target);
}
AsyncContextAccessorUtils.setAsyncContext(asyncContext, target);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,11 @@ protected AsyncContext getAsyncContextFromArgs(final Object target, final Object
}

protected void setAsyncContextToTarget(AsyncContext asyncContext, Object target) {
final AsyncContext targetAsyncContext = AsyncContextAccessorUtils.getAsyncContext(target);
if (targetAsyncContext == null) {
AsyncContextAccessorUtils.setAsyncContext(asyncContext, target);
}
AsyncContextAccessorUtils.setAsyncContext(asyncContext, target);
}

// Trace reactor
protected void setReactorContextToTarget(AsyncContext asyncContext, Object target) {
final AsyncContext targetAsyncContext = ReactorContextAccessorUtils.getAsyncContext(target);
if (targetAsyncContext == null) {
ReactorContextAccessorUtils.setAsyncContext(asyncContext, target);
}
ReactorContextAccessorUtils.setAsyncContext(asyncContext, target);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,11 @@ boolean checkSubscriberReactorContextAccessor(final Object target, final Object[
}

protected void setReactorContextToTarget(AsyncContext asyncContext, Object target) {
final AsyncContext targetAsyncContext = ReactorContextAccessorUtils.getAsyncContext(target);
if (targetAsyncContext == null) {
ReactorContextAccessorUtils.setAsyncContext(asyncContext, target);
}
ReactorContextAccessorUtils.setAsyncContext(asyncContext, target);
}

protected void setReactorContextToSubscriber(AsyncContext asyncContext, Object[] args) {
final AsyncContext subscriberAsyncContext = ReactorContextAccessorUtils.getAsyncContext(args, 0);
if (subscriberAsyncContext == null) {
ReactorContextAccessorUtils.setAsyncContext(asyncContext, args, 0);
}
ReactorContextAccessorUtils.setAsyncContext(asyncContext, args, 0);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,11 @@ private boolean checkSubscriberReactorContextAccessor(final Object target, final
}

protected void setReactorContextToTarget(AsyncContext asyncContext, Object target) {
final AsyncContext targetAsyncContext = ReactorContextAccessorUtils.getAsyncContext(target);
if (targetAsyncContext == null) {
ReactorContextAccessorUtils.setAsyncContext(asyncContext, target);
}
ReactorContextAccessorUtils.setAsyncContext(asyncContext, target);
}

protected void setReactorContextToSubscriber(AsyncContext asyncContext, Object[] args) {
final AsyncContext subscriberAsyncContext = ReactorContextAccessorUtils.getAsyncContext(args, 0);
if (subscriberAsyncContext == null) {
ReactorContextAccessorUtils.setAsyncContext(asyncContext, args, 0);
}
ReactorContextAccessorUtils.setAsyncContext(asyncContext, args, 0);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,7 @@ public static AsyncContext getAsyncContext(Object object) {

public static void setAsyncContext(final AsyncContext asyncContext, final Object object) {
if (object instanceof ReactorContextAccessor) {
final AsyncContext argAsyncContext = ReactorContextAccessorUtils.getAsyncContext(object);
if (argAsyncContext == null) {
((ReactorContextAccessor) object)._$PINPOINT$_setReactorContext(asyncContext);
}
((ReactorContextAccessor) object)._$PINPOINT$_setReactorContext(asyncContext);
}
}

Expand Down
2 changes: 1 addition & 1 deletion plugins/bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

<properties>
<jedis.version>2.4.2</jedis.version>
<lettuce.version>5.1.2.RELEASE</lettuce.version>
<lettuce.version>6.1.5.RELEASE</lettuce.version>
<cassandra.driver.version>2.1.7.1</cassandra.driver.version>
<dubbo.version>2.5.3</dubbo.version>
<mongo.driver.version>3.9.0</mongo.driver.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,7 @@ protected void setReactorContextToSubscriber(AsyncContext asyncContext, Object[]

private void setAsyncContext(final AsyncContext asyncContext, final Object object) {
if (object instanceof ReactorContextAccessor) {
final AsyncContext actualAsyncContext = ReactorContextAccessorUtils.getAsyncContext(object);
if (actualAsyncContext == null) {
ReactorContextAccessorUtils.setAsyncContext(asyncContext, object);
}
ReactorContextAccessorUtils.setAsyncContext(asyncContext, object);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@ public RunnableCoreSubscriberInterceptor(TraceContext traceContext, MethodDescri
protected void doInBeforeTrace(SpanEventRecorder recorder, AsyncContext asyncContext, Object target, Object[] args) {
final AsyncContext publisherAsyncContext = AsyncContextAccessorUtils.getAsyncContext(target);
if (publisherAsyncContext != null) {
final AsyncContext subscriberAsyncContext = AsyncContextAccessorUtils.getAsyncContext(args, 0);
if (subscriberAsyncContext == null) {
AsyncContextAccessorUtils.setAsyncContext(publisherAsyncContext, args, 0);
}
AsyncContextAccessorUtils.setAsyncContext(publisherAsyncContext, args, 0);
}
}

Expand Down
Loading