nicusX commented on code in PR #1:
URL: 
https://github.com/apache/flink-connector-prometheus/pull/1#discussion_r1477028925


##########
prometheus-connector/src/main/java/org/apache/flink/connector/prometheus/sink/errorhandling/SinkWriterErrorHandlingBehaviorConfiguration.java:
##########
@@ -0,0 +1,105 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You 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 org.apache.flink.connector.prometheus.sink.errorhandling;
+
+import java.io.Serializable;
+import java.util.Optional;
+
+import static 
org.apache.flink.connector.prometheus.sink.errorhandling.OnErrorBehavior.FAIL;
+
+/**
+ * Configure the error-handling behavior of the writer, for different types of 
error. Also defines
+ * default behaviors.
+ */
+public class SinkWriterErrorHandlingBehaviorConfiguration implements 
Serializable {
+
+    public static final OnErrorBehavior ON_MAX_RETRY_EXCEEDED_DEFAULT_BEHAVIOR 
= FAIL;
+    public static final OnErrorBehavior 
ON_HTTP_CLIENT_IO_FAIL_DEFAULT_BEHAVIOR = FAIL;
+    public static final OnErrorBehavior 
ON_PROMETHEUS_NON_RETRIABLE_ERROR_DEFAULT_BEHAVIOR = FAIL;
+
+    /** Behaviour when the max retries is exceeded on Prometheus retriable 
errors. */
+    private final OnErrorBehavior onMaxRetryExceeded;
+
+    /** Behaviour when the HTTP client fails, for an I/O problem. */
+    private final OnErrorBehavior onHttpClientIOFail;
+
+    /** Behaviour when Prometheus Remote-Write respond with a non-retriable 
error. */
+    private final OnErrorBehavior onPrometheusNonRetriableError;
+
+    public SinkWriterErrorHandlingBehaviorConfiguration(
+            OnErrorBehavior onMaxRetryExceeded,
+            OnErrorBehavior onHttpClientIOFail,
+            OnErrorBehavior onPrometheusNonRetriableError) {
+        this.onMaxRetryExceeded = onMaxRetryExceeded;
+        this.onHttpClientIOFail = onHttpClientIOFail;
+        this.onPrometheusNonRetriableError = onPrometheusNonRetriableError;
+    }
+
+    public OnErrorBehavior getOnMaxRetryExceeded() {
+        return onMaxRetryExceeded;
+    }
+
+    public OnErrorBehavior getOnHttpClientIOFail() {
+        return onHttpClientIOFail;
+    }
+
+    public OnErrorBehavior getOnPrometheusNonRetriableError() {
+        return onPrometheusNonRetriableError;
+    }
+
+    /** Builder for PrometheusSinkWriterErrorHandlingConfiguration. */
+    public static class Builder {
+        private OnErrorBehavior onMaxRetryExceeded = null;
+        private OnErrorBehavior onHttpClientIOFail = null;
+        private OnErrorBehavior onPrometheusNonRetriableError = null;
+
+        public Builder() {}
+
+        public Builder onMaxRetryExceeded(OnErrorBehavior onErrorBehavior) {
+            this.onMaxRetryExceeded = onErrorBehavior;
+            return this;
+        }
+
+        public Builder onHttpClientIOFail(OnErrorBehavior onErrorBehavior) {
+            this.onHttpClientIOFail = onErrorBehavior;
+            return this;
+        }
+
+        public Builder onPrometheusNonRetriableError(OnErrorBehavior 
onErrorBehavior) {
+            this.onPrometheusNonRetriableError = onErrorBehavior;
+            return this;

Review Comment:
   Absolutely not. For Prometheus, non-retriable errors are malformed or 
out-of-order writes. This may happen because of input data, and the writer may 
want to just log, drop, and continue. This is actually the default behaviour of 
most of tools writing to Prometheus. 



-- 
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