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


##########
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:
   Thanks, yes I have extracted all the endpoints from the doc and used them in 
the unit test



##########
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:
   Thanks, this is a good catch, have updated this



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to