Github user zentol commented on a diff in the pull request: https://github.com/apache/flink/pull/3833#discussion_r116368672 --- Diff: flink-metrics/flink-metrics-prometheus/src/test/java/org/apache/flink/metrics/prometheus/PrometheusReporterTest.java --- @@ -0,0 +1,192 @@ +/* + * 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.metrics.prometheus; + +import com.mashape.unirest.http.HttpResponse; +import com.mashape.unirest.http.Unirest; +import com.mashape.unirest.http.exceptions.UnirestException; +import org.apache.flink.configuration.ConfigConstants; +import org.apache.flink.configuration.Configuration; +import org.apache.flink.configuration.MetricOptions; +import org.apache.flink.metrics.Counter; +import org.apache.flink.metrics.Gauge; +import org.apache.flink.metrics.Histogram; +import org.apache.flink.metrics.Meter; +import org.apache.flink.metrics.Metric; +import org.apache.flink.metrics.SimpleCounter; +import org.apache.flink.metrics.reporter.MetricReporter; +import org.apache.flink.metrics.util.TestMeter; +import org.apache.flink.runtime.metrics.MetricRegistry; +import org.apache.flink.runtime.metrics.MetricRegistryConfiguration; +import org.apache.flink.runtime.metrics.groups.FrontMetricGroup; +import org.apache.flink.runtime.metrics.groups.TaskManagerMetricGroup; +import org.apache.flink.runtime.metrics.util.TestingHistogram; +import org.apache.flink.util.TestLogger; +import org.junit.After; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +import java.util.Arrays; + +import static org.apache.flink.metrics.prometheus.PrometheusReporter.ARG_PORT; +import static org.apache.flink.runtime.metrics.scope.ScopeFormat.SCOPE_SEPARATOR; +import static org.hamcrest.Matchers.both; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.equalTo; +import static org.junit.Assert.assertThat; + +public class PrometheusReporterTest extends TestLogger { + private static final int NON_DEFAULT_PORT = 9429; + + private static final String HOST_NAME = "hostname"; + private static final String TASK_MANAGER = "tm"; + + private static final String HELP_PREFIX = "# HELP "; + private static final String TYPE_PREFIX = "# TYPE "; + private static final String DIMENSIONS = "host=\"" + HOST_NAME + "\",tm_id=\"" + TASK_MANAGER + "\""; + private static final String DEFAULT_LABELS = "{" + DIMENSIONS + ",}"; + private static final String SCOPE_PREFIX = "taskmanager_"; + + @Rule + public ExpectedException thrown = ExpectedException.none(); + + private MetricRegistry registry = prepareMetricRegistry(); --- End diff -- could be final.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---