-
Notifications
You must be signed in to change notification settings - Fork 870
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support reactor netty HttpClient.from construction (#2650)
- Loading branch information
Showing
8 changed files
with
138 additions
and
79 deletions.
There are no files selected for viewing
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
50 changes: 50 additions & 0 deletions
50
...ion/reactor-netty-0.9/javaagent/src/test/groovy/AbstractReactorNettyHttpClientTest.groovy
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,50 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import io.opentelemetry.instrumentation.test.AgentTestTrait | ||
import io.opentelemetry.instrumentation.test.base.HttpClientTest | ||
import reactor.netty.http.client.HttpClient | ||
import reactor.netty.http.client.HttpClientResponse | ||
|
||
abstract class AbstractReactorNettyHttpClientTest extends HttpClientTest implements AgentTestTrait { | ||
|
||
@Override | ||
boolean testRedirects() { | ||
false | ||
} | ||
|
||
@Override | ||
boolean testConnectionFailure() { | ||
false | ||
} | ||
|
||
@Override | ||
boolean testRemoteConnection() { | ||
false | ||
} | ||
|
||
@Override | ||
String userAgent() { | ||
return "ReactorNetty" | ||
} | ||
|
||
@Override | ||
int doRequest(String method, URI uri, Map<String, String> headers = [:], Closure callback = null) { | ||
HttpClientResponse resp = createHttpClient() | ||
.followRedirect(true) | ||
.headers({ h -> headers.each { k, v -> h.add(k, v) } }) | ||
.baseUrl(server.address.toString()) | ||
."${method.toLowerCase()}"() | ||
.uri(uri.toString()) | ||
.response() | ||
.block() | ||
if (callback != null) { | ||
callback.call() | ||
} | ||
return resp.status().code() | ||
} | ||
|
||
abstract HttpClient createHttpClient() | ||
} |
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
14 changes: 14 additions & 0 deletions
14
...on/reactor-netty-0.9/javaagent/src/test/groovy/ReactorNettyHttpClientUsingFromTest.groovy
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,14 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import reactor.netty.http.client.HttpClient | ||
import reactor.netty.tcp.TcpClient | ||
|
||
class ReactorNettyHttpClientUsingFromTest extends AbstractReactorNettyHttpClientTest { | ||
|
||
HttpClient createHttpClient() { | ||
return HttpClient.from(TcpClient.create()) | ||
} | ||
} |
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
50 changes: 50 additions & 0 deletions
50
...ion/reactor-netty-1.0/javaagent/src/test/groovy/AbstractReactorNettyHttpClientTest.groovy
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,50 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import io.opentelemetry.instrumentation.test.AgentTestTrait | ||
import io.opentelemetry.instrumentation.test.base.HttpClientTest | ||
import reactor.netty.http.client.HttpClient | ||
import reactor.netty.http.client.HttpClientResponse | ||
|
||
abstract class AbstractReactorNettyHttpClientTest extends HttpClientTest implements AgentTestTrait { | ||
|
||
@Override | ||
boolean testRedirects() { | ||
false | ||
} | ||
|
||
@Override | ||
boolean testConnectionFailure() { | ||
false | ||
} | ||
|
||
@Override | ||
boolean testRemoteConnection() { | ||
false | ||
} | ||
|
||
@Override | ||
String userAgent() { | ||
return "ReactorNetty" | ||
} | ||
|
||
@Override | ||
int doRequest(String method, URI uri, Map<String, String> headers = [:], Closure callback = null) { | ||
HttpClientResponse resp = createHttpClient() | ||
.followRedirect(true) | ||
.headers({ h -> headers.each { k, v -> h.add(k, v) } }) | ||
.baseUrl(server.address.toString()) | ||
."${method.toLowerCase()}"() | ||
.uri(uri.toString()) | ||
.response() | ||
.block() | ||
if (callback != null) { | ||
callback.call() | ||
} | ||
return resp.status().code() | ||
} | ||
|
||
abstract HttpClient createHttpClient() | ||
} |
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
14 changes: 14 additions & 0 deletions
14
...on/reactor-netty-1.0/javaagent/src/test/groovy/ReactorNettyHttpClientUsingFromTest.groovy
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,14 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import reactor.netty.http.client.HttpClient | ||
import reactor.netty.tcp.TcpClient | ||
|
||
class ReactorNettyHttpClientUsingFromTest extends AbstractReactorNettyHttpClientTest { | ||
|
||
HttpClient createHttpClient() { | ||
return HttpClient.from(TcpClient.create()) | ||
} | ||
} |