public boolean isSoapServerRecordResponseMessages() { return soapServerRecordResponseMessages.getValue(); } }
public int getDeleteSpansAfterDays() { return deleteSpansAfterDays.get(); } }
public void logConfiguration(ConfigurationRegistry configuration) { logger.info("# stagemonitor configuration, listing non-default values:"); boolean hasOnlyDefaultOptions = true; for (List<ConfigurationOption<?>> options : configuration.getConfigurationOptionsByCategory().values()) { for (ConfigurationOption<?> option : options) { if (!option.isDefault()) { hasOnlyDefaultOptions = false; logger.info("{}: {} (source: {})", option.getKey(), prepareOptionValueForLog(option), option.getNameOfCurrentConfigurationSource()); if (option.getTags().contains("deprecated")) { logger.warn("Detected usage of deprecated configuration option '{}'. " + "This option might be removed in the future. " + "Please refer to the documentation about alternatives.", option.getKey()); } if (!option.getKey().equals(option.getUsedKey())) { logger.warn("Detected usage of an old configuration key: '{}'. Please use '{}' instead.", option.getUsedKey(), option.getKey()); } } } } if (hasOnlyDefaultOptions) { logger.warn("stagemonitor has not been configured. Have a look at " + "https://github.com/stagemonitor/stagemonitor/wiki/How-should-I-configure-stagemonitor%3F " + "and " + "https://github.com/stagemonitor/stagemonitor/wiki/Configuration-Options " + "for further instructions"); } }
private void add(final ConfigurationOption<?> configurationOption) { configurationOption.setConfiguration(this); configurationOption.setConfigurationSources(configurationSources); final String key = configurationOption.getKey(); addConfigurationOptionByKey(configurationOption, key); for (String alternateKey : configurationOption.getAliasKeys()) { addConfigurationOptionByKey(configurationOption, alternateKey); } addConfigurationOptionByCategory(configurationOption.getConfigurationCategory(), configurationOption); }
private void logConfigWithNonDefaultValue(Logger logger, ConfigurationOption<?> option) { logger.debug("{}: '{}' (source: {})", option.getKey(), option.isSensitive() ? "XXXX" : option.getValueAsSafeString(), option.getNameOfCurrentConfigurationSource()); if (option.getTags().contains("deprecated")) { logger.warn("Detected usage of deprecated configuration option '{}'. " + "This option might be removed in the future. " + "Please refer to the documentation about alternatives.", option.getKey()); } if (!option.getKey().equals(option.getUsedKey())) { logger.warn("Detected usage of an old configuration key: '{}'. Please use '{}' instead.", option.getUsedKey(), option.getKey()); } if (option.getValue() instanceof TimeDuration && !TimeDuration.DURATION_PATTERN.matcher(option.getValueAsString()).matches()) { logger.warn("DEPRECATION WARNING: {}: '{}' (source: {}) is not using a time unit. Please use one of 'ms', 's' or 'm'.", option.getKey(), option.getValueAsString(), option.getNameOfCurrentConfigurationSource()); } }
public void addCheck(Check check) throws IOException { final LinkedHashMap<String, Check> newValue = new LinkedHashMap<String, Check>(getChecks()); newValue.put(check.getId(), check); checks.update(newValue, SimpleSource.NAME); }
.stream() .flatMap(Collection::stream) .filter(opt -> !opt.getTags().isEmpty()) .forEach(opt -> opt.getTags() .forEach(tag -> configurationOptionsByTags.add(tag, opt))); markdown.append("* ").append(linkToHeadline(pluginName)).append('\n'); for (ConfigurationOption<?> option : entry.getValue()) { markdown.append(" * ").append(linkToHeadline(option.getLabel())).append('\n'); markdown.append("## `").append(entry.getKey()).append("` \n"); for (ConfigurationOption<?> option : entry.getValue()) { markdown.append(" * ").append(linkToHeadline(option.getLabel())).append('\n'); }} markdown.append("\n"); markdown.append("# ").append(entry.getKey()).append("\n\n"); for (ConfigurationOption<?> configurationOption : entry.getValue()) { markdown.append("## ").append(configurationOption.getLabel()).append("\n\n"); if (configurationOption.getDescription() != null) { markdown.append(configurationOption.getDescription()).append("\n\n"); markdown.append("Key: `").append(configurationOption.getKey()).append("`\n\n"); markdown.append("Default Value: "); final String defaultValue = configurationOption.getDefaultValueAsString(); if (defaultValue == null) { markdown.append("`null`\n\n"); if (!configurationOption.getTags().isEmpty()) {
@Test void testLogDeprecationWarningWhenNotSpecifyingTimeUnit() throws Exception { assertThat(config.duration.get().getMillis()).isEqualTo(1); assertThat(config.duration.getValueAsString()).isEqualTo("1"); startupInfo.logConfiguration(configurationRegistry, logger); verify(logger).warn("DEPRECATION WARNING: {}: '{}' (source: {}) is not using a time unit. Please use one of 'ms', 's' or 'm'.", "duration", "1", SimpleSource.NAME); }
sampler = ProbabilitySampler.of(coreConfiguration.getSampleRate().get()); coreConfiguration.getSampleRate().addChangeListener(new ConfigurationOption.ChangeListener<Double>() { @Override public void onChange(ConfigurationOption<?> configurationOption, Double oldValue, Double newValue) {
@Test public void testChangeListener() throws Exception { AtomicBoolean changeListenerInvoked = new AtomicBoolean(false); exampleConfiguration.getOptionalExample() .addChangeListener((configurationOption, oldValue, newValue) -> changeListenerInvoked.set(true)); // saves a value into a specific configuration source exampleConfiguration.getOptionalExample().update(Optional.of("foo"), SimpleSource.NAME); assertThat(changeListenerInvoked).isTrue(); }
public String getSubscriptionsByIdsAsJson() { return subscriptions.getValueAsString(); }
public void registerDefaultRateLimitSpansPercentChangeListener(ConfigurationOption.ChangeListener<Double> changeListener) { defaultRateLimitSpansPercent.addChangeListener(changeListener); }
@Test public void testOnConfigurationChanged() throws Exception { AtomicBoolean changeListenerFired = new AtomicBoolean(false); final ConfigurationOption<String> configurationOption = ConfigurationOption.stringOption() .key("foo") .dynamic(true) .addChangeListener((opt, oldValue, newValue) -> { assertEquals("foo", opt.getKey()); assertEquals("old", oldValue); assertEquals("new", newValue); changeListenerFired.set(true); throw new RuntimeException("This is an expected test exception. " + "It is thrown to test whether Configuration can cope with change listeners that throw an exception."); }).buildWithDefault("old"); final ConfigurationOptionProvider optionProvider = TestConfigurationOptionProvider.of(configurationOption); final SimpleSource configurationSource = new SimpleSource("test"); final ConfigurationRegistry config = ConfigurationRegistry.builder() .addOptionProvider(optionProvider) .addConfigSource(configurationSource) .build(); config.save("foo", "new", "test"); assertTrue(changeListenerFired.get()); }
@Test public void testWithOptions_valid() { final ConfigurationOption<String> option = ConfigurationOption.stringOption() .key("test.options") .addValidOptions("foo", "bar") .buildWithDefault("foo"); final ConfigurationRegistry configuration = createConfiguration(Collections.singletonList(option), SimpleSource.forTest("test.options", "bar")); assertThat(configuration.getConfigurationOptionByKey("test.options").getValueAsString()).isEqualTo("bar"); assertThatThrownBy(() -> configuration.save("test.options", "baz", "Test Configuration Source")) .isInstanceOf(IllegalArgumentException.class) .hasMessageContaining("Invalid option"); }
@Test public void testValidationFailedPerTypeOption() throws Exception { assertThatThrownBy(() -> tracingPlugin.getRateLimitSpansPerMinutePercentPerTypeOption() .update(singletonMap("jdbc", 10.0), SimpleSource.NAME)) .isInstanceOf(IllegalArgumentException.class); assertThat(tracingPlugin.getRateLimitSpansPerMinutePercentPerTypeOption().getValue()).isEqualTo(emptyMap()); }
@Test public void testReportSpanGenericType() throws Exception { when(spanContext.getOperationType()).thenReturn("jdbc"); tracingPlugin.getDefaultRateLimitSpansPercentOption().update(0d, SimpleSource.NAME); tracingPlugin.getRateLimitSpansPerMinutePercentPerTypeOption().update(singletonMap("http", 1d), SimpleSource.NAME); interceptor.interceptReport(context); assertFalse(context.isReport()); }
public String getChecksAsJson() { return checks.getValueAsString(); }
public void registerDebugClientSpanScriptOptionChangedListener(ConfigurationOption.ChangeListener<Boolean> listener) { debugClientSpanScript.addChangeListener(listener); }
Integer getZipkinMaxQueuedBytes() { return zipkinMaxQueuedBytes.getValue(); } }