Search in sources :

Example 1 with NullEnricher

use of org.cloudfoundry.promregator.auth.NullEnricher in project promregator by promregator.

the class MetricsFetcherSimulatorTest method testCall.

@Test
void testCall() throws Exception {
    AbstractMetricFamilySamplesEnricher mfse = new CFAllLabelsMetricFamilySamplesEnricher("testOrgName", "testSpaceName", "testapp", "testinstance1:0");
    Gauge up = Gauge.build("up_test", "help test").labelNames(CFAllLabelsMetricFamilySamplesEnricher.getEnrichingLabelNames()).create();
    Child upChild = up.labels(mfse.getEnrichedLabelValues(new LinkedList<>()).toArray(new String[0]));
    MetricsFetcherSimulator subject = new MetricsFetcherSimulator("accessUrl", new NullEnricher(), mfse, Mockito.mock(MetricsFetcherMetrics.class), upChild);
    HashMap<String, MetricFamilySamples> result = subject.call();
    Assertions.assertEquals(3, result.size());
}
Also used : NullEnricher(org.cloudfoundry.promregator.auth.NullEnricher) AbstractMetricFamilySamplesEnricher(org.cloudfoundry.promregator.rewrite.AbstractMetricFamilySamplesEnricher) MetricFamilySamples(io.prometheus.client.Collector.MetricFamilySamples) CFAllLabelsMetricFamilySamplesEnricher(org.cloudfoundry.promregator.rewrite.CFAllLabelsMetricFamilySamplesEnricher) Child(io.prometheus.client.Gauge.Child) Gauge(io.prometheus.client.Gauge) Test(org.junit.jupiter.api.Test)

Example 2 with NullEnricher

use of org.cloudfoundry.promregator.auth.NullEnricher in project promregator by promregator.

the class PromregatorApplication method authenticationEnricher.

@Bean
public AuthenticationEnricher authenticationEnricher(PromregatorConfiguration promregatorConfiguration) {
    AuthenticationEnricher ae = null;
    String type = promregatorConfiguration.getAuthenticator().getType();
    if ("OAuth2XSUAA".equalsIgnoreCase(type)) {
        ae = new OAuth2XSUAAEnricher(promregatorConfiguration.getAuthenticator().getOauth2xsuaa());
    } else if ("none".equalsIgnoreCase(type) || "null".equalsIgnoreCase(type)) {
        ae = new NullEnricher();
    } else if ("basic".equalsIgnoreCase(type)) {
        ae = new BasicAuthenticationEnricher(promregatorConfiguration.getAuthenticator().getBasic());
    } else {
        log.warn(String.format("Authenticator type %s is unknown; skipping", type));
    }
    return ae;
}
Also used : OAuth2XSUAAEnricher(org.cloudfoundry.promregator.auth.OAuth2XSUAAEnricher) NullEnricher(org.cloudfoundry.promregator.auth.NullEnricher) BasicAuthenticationEnricher(org.cloudfoundry.promregator.auth.BasicAuthenticationEnricher) AuthenticationEnricher(org.cloudfoundry.promregator.auth.AuthenticationEnricher) BasicAuthenticationEnricher(org.cloudfoundry.promregator.auth.BasicAuthenticationEnricher) Bean(org.springframework.context.annotation.Bean)

Aggregations

NullEnricher (org.cloudfoundry.promregator.auth.NullEnricher)2 MetricFamilySamples (io.prometheus.client.Collector.MetricFamilySamples)1 Gauge (io.prometheus.client.Gauge)1 Child (io.prometheus.client.Gauge.Child)1 AuthenticationEnricher (org.cloudfoundry.promregator.auth.AuthenticationEnricher)1 BasicAuthenticationEnricher (org.cloudfoundry.promregator.auth.BasicAuthenticationEnricher)1 OAuth2XSUAAEnricher (org.cloudfoundry.promregator.auth.OAuth2XSUAAEnricher)1 AbstractMetricFamilySamplesEnricher (org.cloudfoundry.promregator.rewrite.AbstractMetricFamilySamplesEnricher)1 CFAllLabelsMetricFamilySamplesEnricher (org.cloudfoundry.promregator.rewrite.CFAllLabelsMetricFamilySamplesEnricher)1 Test (org.junit.jupiter.api.Test)1 Bean (org.springframework.context.annotation.Bean)1