Configure additional metric aggregators.
This commit is contained in:
parent
403aa5fd3e
commit
4cc5999f05
|
@ -97,5 +97,7 @@ gcm: # GCM Configuration
|
||||||
apiKey:
|
apiKey:
|
||||||
|
|
||||||
micrometer: # Micrometer metrics config
|
micrometer: # Micrometer metrics config
|
||||||
uri: "https://metrics.example.com/"
|
- name: "example"
|
||||||
apiToken:
|
- uri: "https://metrics.example.com/"
|
||||||
|
- apiKey:
|
||||||
|
- accountId:
|
||||||
|
|
|
@ -61,7 +61,7 @@ public class WhisperServerConfiguration extends Configuration {
|
||||||
@NotNull
|
@NotNull
|
||||||
@Valid
|
@Valid
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
private MicrometerConfiguration micrometer;
|
private List<MicrometerConfiguration> micrometer = new LinkedList<>();
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Valid
|
@Valid
|
||||||
|
@ -286,8 +286,14 @@ public class WhisperServerConfiguration extends Configuration {
|
||||||
return cdn;
|
return cdn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MicrometerConfiguration getMicrometerConfiguration() {
|
public Map<String, MicrometerConfiguration> getMicrometerConfiguration() {
|
||||||
return micrometer;
|
final Map<String, MicrometerConfiguration> micrometerConfigurationByName = new HashMap<>();
|
||||||
|
|
||||||
|
for (final MicrometerConfiguration micrometerConfiguration : micrometer) {
|
||||||
|
micrometerConfigurationByName.put(micrometerConfiguration.getName(), micrometerConfiguration);
|
||||||
|
}
|
||||||
|
|
||||||
|
return micrometerConfigurationByName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UnidentifiedDeliveryConfiguration getDeliveryCertificate() {
|
public UnidentifiedDeliveryConfiguration getDeliveryCertificate() {
|
||||||
|
|
|
@ -43,7 +43,11 @@ import io.dropwizard.setup.Bootstrap;
|
||||||
import io.dropwizard.setup.Environment;
|
import io.dropwizard.setup.Environment;
|
||||||
import io.lettuce.core.RedisURI;
|
import io.lettuce.core.RedisURI;
|
||||||
import io.lettuce.core.cluster.RedisClusterClient;
|
import io.lettuce.core.cluster.RedisClusterClient;
|
||||||
|
import io.micrometer.core.instrument.Clock;
|
||||||
import io.micrometer.core.instrument.Metrics;
|
import io.micrometer.core.instrument.Metrics;
|
||||||
|
import io.micrometer.newrelic.NewRelicConfig;
|
||||||
|
import io.micrometer.newrelic.NewRelicMeterRegistry;
|
||||||
|
import io.micrometer.wavefront.WavefrontConfig;
|
||||||
import io.micrometer.wavefront.WavefrontMeterRegistry;
|
import io.micrometer.wavefront.WavefrontMeterRegistry;
|
||||||
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
||||||
import org.eclipse.jetty.servlets.CrossOriginFilter;
|
import org.eclipse.jetty.servlets.CrossOriginFilter;
|
||||||
|
@ -157,6 +161,7 @@ import javax.servlet.ServletRegistration;
|
||||||
import java.security.Security;
|
import java.security.Security;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@ -210,21 +215,61 @@ public class WhisperServerService extends Application<WhisperServerConfiguration
|
||||||
{
|
{
|
||||||
SharedMetricRegistries.add(Constants.METRICS_NAME, environment.metrics());
|
SharedMetricRegistries.add(Constants.METRICS_NAME, environment.metrics());
|
||||||
|
|
||||||
|
final Map<String, MicrometerConfiguration> micrometerConfigurationByName = config.getMicrometerConfiguration();
|
||||||
|
|
||||||
{
|
{
|
||||||
// This is a workaround for an issue where the configured step duration isn't being honored by
|
// This is a workaround for an issue where the configured step duration isn't being honored by
|
||||||
// WavefrontMeterRegistry; we can simplify if https://github.com/micrometer-metrics/micrometer/pull/2173 gets
|
// WavefrontMeterRegistry; we can simplify if https://github.com/micrometer-metrics/micrometer/pull/2173 gets
|
||||||
// merged.
|
// merged.
|
||||||
final MicrometerConfiguration micrometerConfig = config.getMicrometerConfiguration();
|
final MicrometerConfiguration micrometerWavefrontConfig = micrometerConfigurationByName.get("wavefront");
|
||||||
|
|
||||||
final WavefrontSender wavefrontSender = WavefrontMeterRegistry.getDefaultSenderBuilder(micrometerConfig)
|
final WavefrontConfig wavefrontConfig = new WavefrontConfig() {
|
||||||
.flushIntervalSeconds((int)micrometerConfig.step().toSeconds())
|
@Override
|
||||||
|
public String get(final String key) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String uri() {
|
||||||
|
return micrometerWavefrontConfig.getUri();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String apiToken() {
|
||||||
|
return micrometerWavefrontConfig.getApiKey();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
final WavefrontSender wavefrontSender = WavefrontMeterRegistry.getDefaultSenderBuilder(wavefrontConfig)
|
||||||
|
.flushIntervalSeconds((int)wavefrontConfig.step().toSeconds())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
Metrics.addRegistry(WavefrontMeterRegistry.builder(micrometerConfig)
|
Metrics.addRegistry(WavefrontMeterRegistry.builder(wavefrontConfig)
|
||||||
.wavefrontSender(wavefrontSender)
|
.wavefrontSender(wavefrontSender)
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
final MicrometerConfiguration micrometerNewRelicConfig = micrometerConfigurationByName.get("newrelic");
|
||||||
|
|
||||||
|
Metrics.addRegistry(new NewRelicMeterRegistry(new NewRelicConfig() {
|
||||||
|
@Override
|
||||||
|
public String get(final String key) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String accountId() {
|
||||||
|
return micrometerNewRelicConfig.getAccountId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String apiKey() {
|
||||||
|
return micrometerNewRelicConfig.getApiKey();
|
||||||
|
}
|
||||||
|
}, Clock.SYSTEM));
|
||||||
|
}
|
||||||
|
|
||||||
environment.getObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
environment.getObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||||
environment.getObjectMapper().setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.NONE);
|
environment.getObjectMapper().setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.NONE);
|
||||||
environment.getObjectMapper().setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
|
environment.getObjectMapper().setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
|
||||||
|
|
|
@ -5,28 +5,35 @@ import io.micrometer.wavefront.WavefrontConfig;
|
||||||
|
|
||||||
import javax.validation.constraints.NotEmpty;
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
|
||||||
public class MicrometerConfiguration implements WavefrontConfig {
|
public class MicrometerConfiguration {
|
||||||
|
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
@NotEmpty
|
@NotEmpty
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@JsonProperty
|
||||||
private String uri;
|
private String uri;
|
||||||
|
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
@NotEmpty
|
@NotEmpty
|
||||||
private String apiToken;
|
private String apiKey;
|
||||||
|
|
||||||
@Override
|
@JsonProperty
|
||||||
public String get(final String key) {
|
private String accountId;
|
||||||
return null;
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public String getUri() {
|
||||||
public String uri() {
|
|
||||||
return uri;
|
return uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public String getApiKey() {
|
||||||
public String apiToken() {
|
return apiKey;
|
||||||
return apiToken;
|
}
|
||||||
|
|
||||||
|
public String getAccountId() {
|
||||||
|
return accountId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue