Spring开机测微计datadog套接字连接错误
Spring boot micro meter datadog socket connection error
我正在努力为我的 spring boot 2 rest api 创建一些自定义指标。我已经添加了所需的千分尺和数据狗依赖项。我的办公室机器在代理后面工作。我通过 spring 引导插件设置了代理。
-Dhttp.proxyHost=xxxx.proxy.com
-Dhttp.proxyPort=xxxx
以下在我的 application.properties 文件中。
management.metrics.export.datadog.apiKey=我的钥匙
management.metrics.export.datadog.uri=https://app.datadoghq.com
management.metrics.export.datadog.enabled=true
management.metrics.export.datadog.step=10s
但是我收到套接字连接超时。
[datadog-metrics-publisher] 10 Apr 2020 16:51:39,552 WARN DatadogMeterRegistry [{}]: java.net.SocketTimeoutException: connect timed out
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:606)
at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:666)
at sun.net.NetworkClient.doConnect(NetworkClient.java:175)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:463)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:558)
at sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:264)
at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:367)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:191)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1162)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1056)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:177)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream0(HttpURLConnection.java:1340)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1315)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:264)
at io.micrometer.core.ipc.http.HttpUrlConnectionSender.send(HttpUrlConnectionSender.java:96)
at io.micrometer.core.ipc.http.HttpSender$Request$Builder.send(HttpSender.java:284)
at io.micrometer.datadog.DatadogMeterRegistry.publish(DatadogMeterRegistry.java:141)
at io.micrometer.core.instrument.push.PushMeterRegistry.publishSafely(PushMeterRegistry.java:48)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
据我调试,io.micrometer.core.ipc.http.HttpUrlConnectionSender.send 方法失败了,我不知道测微计数据狗如何获取代理详细信息。
千分尺文档说
management.metrics.export.datadog.uri=https://app.datadoghq.com # URI to ship metrics to. If you need to publish metrics to an internal proxy en-route to Datadog, you can define the location of the proxy with this.
但是我不明白这是什么意思?我应该用我的代理 url 替换这个 url 还是代理有任何特定的 uri 模式?我正在使用 spring 启动 2.2.4.RELEASE
如果您尝试连接到 Datadog 的 HTTPS URL(在您的示例中为 https://app.datadoghq.com
),那么您将需要设置 https.proxyHost
系统 属性使其生效 - http.proxyHost
用于 HTTP URLs[1]。这些是系统范围的设置,如果 Proxy
未传递给其构造函数,则默认 HttpSender
(HttpUrlConnectionSender
) 将使用这些设置。
The micrometer doc says
management.metrics.export.datadog.uri=https://app.datadoghq.com # URI to ship metrics to. If you need to publish metrics to an internal proxy en-route to Datadog, you can define the location of the proxy with this.
But I dont understand what it means? should I replace this url with my
proxy url or is there any specific uri pattern with the proxy?
这是指一种不同类型的代理,您可以将其配置为在内部网络上接收 Datadog 流量,并将其转发到网络外部的 Datadog。如果您使用的是 HTTP 代理,那么您应该使用系统属性或配置了 HTTP 代理的 HttpSender
(例如 HttpUrlConnectionSender
并将 Proxy
传递给其构造函数)。
您可以使用 Builder
为 DatadogMeterRegistry
配置自定义 HttpSender
。如果您在 @Configuration
class 中将其公开为 Bean
,Spring Boot 将在其自动配置中使用它。例如:
@Bean
public DatadogMeterRegistry datadogMeterRegistry(DatadogConfig config, Clock clock) {
HttpSender httpSender = new HttpUrlConnectionSender(config.connectTimeout(), config.readTimeout(), new Proxy(Proxy.Type.HTTP, new InetSocketAddress("myproxy", 8080)));
return DatadogMeterRegistry.builder(config).clock(clock).httpClient(httpSender).build();
}
[1] https://docs.oracle.com/javase/8/docs/technotes/guides/net/proxies.html
我正在努力为我的 spring boot 2 rest api 创建一些自定义指标。我已经添加了所需的千分尺和数据狗依赖项。我的办公室机器在代理后面工作。我通过 spring 引导插件设置了代理。
-Dhttp.proxyHost=xxxx.proxy.com
-Dhttp.proxyPort=xxxx
以下在我的 application.properties 文件中。 management.metrics.export.datadog.apiKey=我的钥匙
management.metrics.export.datadog.uri=https://app.datadoghq.com
management.metrics.export.datadog.enabled=true
management.metrics.export.datadog.step=10s
但是我收到套接字连接超时。
[datadog-metrics-publisher] 10 Apr 2020 16:51:39,552 WARN DatadogMeterRegistry [{}]: java.net.SocketTimeoutException: connect timed out
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:606)
at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:666)
at sun.net.NetworkClient.doConnect(NetworkClient.java:175)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:463)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:558)
at sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:264)
at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:367)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:191)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1162)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1056)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:177)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream0(HttpURLConnection.java:1340)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1315)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:264)
at io.micrometer.core.ipc.http.HttpUrlConnectionSender.send(HttpUrlConnectionSender.java:96)
at io.micrometer.core.ipc.http.HttpSender$Request$Builder.send(HttpSender.java:284)
at io.micrometer.datadog.DatadogMeterRegistry.publish(DatadogMeterRegistry.java:141)
at io.micrometer.core.instrument.push.PushMeterRegistry.publishSafely(PushMeterRegistry.java:48)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
据我调试,io.micrometer.core.ipc.http.HttpUrlConnectionSender.send 方法失败了,我不知道测微计数据狗如何获取代理详细信息。
千分尺文档说
management.metrics.export.datadog.uri=https://app.datadoghq.com # URI to ship metrics to. If you need to publish metrics to an internal proxy en-route to Datadog, you can define the location of the proxy with this.
但是我不明白这是什么意思?我应该用我的代理 url 替换这个 url 还是代理有任何特定的 uri 模式?我正在使用 spring 启动 2.2.4.RELEASE
如果您尝试连接到 Datadog 的 HTTPS URL(在您的示例中为 https://app.datadoghq.com
),那么您将需要设置 https.proxyHost
系统 属性使其生效 - http.proxyHost
用于 HTTP URLs[1]。这些是系统范围的设置,如果 Proxy
未传递给其构造函数,则默认 HttpSender
(HttpUrlConnectionSender
) 将使用这些设置。
The micrometer doc says
management.metrics.export.datadog.uri=https://app.datadoghq.com # URI to ship metrics to. If you need to publish metrics to an internal proxy en-route to Datadog, you can define the location of the proxy with this.
But I dont understand what it means? should I replace this url with my proxy url or is there any specific uri pattern with the proxy?
这是指一种不同类型的代理,您可以将其配置为在内部网络上接收 Datadog 流量,并将其转发到网络外部的 Datadog。如果您使用的是 HTTP 代理,那么您应该使用系统属性或配置了 HTTP 代理的 HttpSender
(例如 HttpUrlConnectionSender
并将 Proxy
传递给其构造函数)。
您可以使用 Builder
为 DatadogMeterRegistry
配置自定义 HttpSender
。如果您在 @Configuration
class 中将其公开为 Bean
,Spring Boot 将在其自动配置中使用它。例如:
@Bean
public DatadogMeterRegistry datadogMeterRegistry(DatadogConfig config, Clock clock) {
HttpSender httpSender = new HttpUrlConnectionSender(config.connectTimeout(), config.readTimeout(), new Proxy(Proxy.Type.HTTP, new InetSocketAddress("myproxy", 8080)));
return DatadogMeterRegistry.builder(config).clock(clock).httpClient(httpSender).build();
}
[1] https://docs.oracle.com/javase/8/docs/technotes/guides/net/proxies.html