foxus commented on code in PR #22:
URL: 
https://github.com/apache/flink-connector-prometheus/pull/22#discussion_r2065830625


##########
flink-connector-prometheus-request-signer-amp/src/test/java/org/apache/flink/connector/prometheus/sink/aws/AmazonManagedPrometheusWriteRequestSignerFactoryTest.java:
##########
@@ -0,0 +1,55 @@
+package org.apache.flink.connector.prometheus.sink.aws;
+
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.connector.prometheus.sink.PrometheusRequestSigner;
+import org.apache.flink.connector.prometheus.table.PrometheusConfig;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static 
org.apache.flink.connector.prometheus.table.PrometheusConnectorOption.METRIC_REMOTE_WRITE_URL;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+class AmazonManagedPrometheusWriteRequestSignerFactoryTest {
+    private AmazonManagedPrometheusWriteRequestSignerFactory factory;
+
+    @BeforeEach
+    public void setup() {
+        factory = new AmazonManagedPrometheusWriteRequestSignerFactory();
+    }
+
+    @Test
+    void testIdentifier() {
+        assertEquals(factory.requestSignerIdentifer(), 
"amazon-managed-prometheus");
+    }
+
+    @Test

Review Comment:
   Consider using a `DataProvider` to test all the endpoints listed in 
https://docs.aws.amazon.com/general/latest/gr/prometheus-service.html.



##########
flink-connector-prometheus-request-signer-amp/src/main/java/org/apache/flink/connector/prometheus/sink/aws/AmazonManagedPrometheusWriteRequestSignerFactory.java:
##########
@@ -0,0 +1,36 @@
+package org.apache.flink.connector.prometheus.sink.aws;
+
+import org.apache.flink.connector.prometheus.sink.PrometheusRequestSigner;
+import org.apache.flink.connector.prometheus.table.PrometheusConfig;
+import 
org.apache.flink.connector.prometheus.table.PrometheusDynamicRequestSignerFactory;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class AmazonManagedPrometheusWriteRequestSignerFactory
+        implements PrometheusDynamicRequestSignerFactory {
+    @Override
+    public String requestSignerIdentifer() {
+        return "amazon-managed-prometheus";
+    }
+
+    @Override
+    public PrometheusRequestSigner getRequestSigner(PrometheusConfig config) {
+        return new AmazonManagedPrometheusWriteRequestSigner(
+                config.getRemoteWriteEndpointUrl(),
+                
getAwsRegionFromEndpointUrl(config.getRemoteWriteEndpointUrl()));
+    }
+
+    private String getAwsRegionFromEndpointUrl(String endpointUrl) {
+        String regex = "aps-workspaces\\.([^.]+)\\.amazonaws\\.com";

Review Comment:
   I believe this is too prescriptive - there are FIPS endpoints which this 
will not match - consider reviewing 
https://docs.aws.amazon.com/general/latest/gr/prometheus-service.html and 
making this regex less specific.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to