Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion agent/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ plugins {
id("elastic-otel.agent-packaging-conventions")
id("elastic-otel.sign-and-publish-conventions")
id("elastic-otel.license-report-conventions")
alias(catalog.plugins.taskinfo)
}

description = "Elastic Distribution of OpenTelemetry Java Agent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,48 +207,47 @@ public static void applyConfiguration(

public abstract static class ConfigOption {
protected final String configName;
protected final String defaultConfigStringValue;
protected final String defaultValue;

protected ConfigOption(String configName1, String defaultConfigStringValue1) {
configName = configName1;
defaultConfigStringValue = defaultConfigStringValue1;
protected ConfigOption(String name, String defaultValue) {
this.configName = name;
this.defaultValue = defaultValue;
}

public String getConfigName() {
return configName;
}

protected boolean getBoolean(String configurationValue) {
protected boolean getBoolean(String value) {
String error =
"'"
+ getConfigName()
+ "' configuration option can only be 'true' or 'false' but is: {0}";
return getBoolean(configurationValue, error);
return getBoolean(value, error);
}

protected boolean getBoolean(String configurationValue, String error) {
if ("true".equalsIgnoreCase(configurationValue)) {
protected boolean getBoolean(String value, String error) {
if ("true".equalsIgnoreCase(value)) {
return true;
} else if ("false".equalsIgnoreCase(configurationValue)) {
} else if ("false".equalsIgnoreCase(value)) {
return false;
} else {
throw new IllegalArgumentException(MessageFormat.format(error, configurationValue));
throw new IllegalArgumentException(MessageFormat.format(error, value));
}
}

public void updateOrLog(String configurationValue, OpampManager opampManager) {
public void updateOrLog(String value, OpampManager opampManager) {
try {
update(configurationValue, opampManager);
} catch (IllegalArgumentException e) {
update(value, opampManager);
} catch (RuntimeException e) {
logger.warning(e.getMessage());
}
}

abstract void update(String configurationValue, OpampManager opampManager)
throws IllegalArgumentException;
abstract void update(String value, OpampManager opampManager);

public void updateToDefault(OpampManager opampManager) {
update(defaultConfigStringValue, opampManager);
update(defaultValue, opampManager);
}

protected DynamicConfiguration config() {
Expand All @@ -262,8 +261,7 @@ public static final class SendLogs extends ConfigOption {
}

@Override
void update(String configurationValue, OpampManager opampManager)
throws IllegalArgumentException {
void update(String configurationValue, OpampManager opampManager) {
config().setSendingLogs(getBoolean(configurationValue));
}
}
Expand All @@ -274,8 +272,7 @@ public static final class SendMetrics extends ConfigOption {
}

@Override
void update(String configurationValue, OpampManager opampManager)
throws IllegalArgumentException {
void update(String configurationValue, OpampManager opampManager) {
config().setSendingMetrics(getBoolean(configurationValue));
}
}
Expand All @@ -286,8 +283,7 @@ public static final class SendTraces extends ConfigOption {
}

@Override
void update(String configurationValue, OpampManager opampManager)
throws IllegalArgumentException {
void update(String configurationValue, OpampManager opampManager) {
config().setSendingSpans(getBoolean(configurationValue));
}
}
Expand All @@ -298,8 +294,7 @@ public static final class DeactivateAllInstrumentations extends ConfigOption {
}

@Override
void update(String configurationValue, OpampManager opampManager)
throws IllegalArgumentException {
void update(String configurationValue, OpampManager opampManager) {
if (getBoolean(configurationValue)) {
config().deactivateAllInstrumentations();
} else {
Expand All @@ -314,8 +309,7 @@ public static final class DeactivateInstrumentations extends ConfigOption {
}

@Override
void update(String configurationValue, OpampManager opampManager)
throws IllegalArgumentException {
void update(String configurationValue, OpampManager opampManager) {
config().deactivateInstrumentations(configurationValue);
}
}
Expand All @@ -326,8 +320,7 @@ public static final class LoggingLevel extends ConfigOption {
}

@Override
void update(String configurationValue, OpampManager opampManager)
throws IllegalArgumentException {
void update(String configurationValue, OpampManager opampManager) {
AgentLog.setLevel(configurationValue);
}
}
Expand All @@ -338,8 +331,7 @@ public static final class SamplingRate extends ConfigOption {
}

@Override
void update(String configurationValue, OpampManager opampManager)
throws IllegalArgumentException {
void update(String configurationValue, OpampManager opampManager) {
ConfigLoggingAgentListener.updateSamplingRate(Double.parseDouble(configurationValue));
}
}
Expand All @@ -350,8 +342,7 @@ public static final class InferSpans extends ConfigOption {
}

@Override
void update(String configurationValue, OpampManager opampManager)
throws IllegalArgumentException {
void update(String configurationValue, OpampManager opampManager) {
// TODO when setProfilerInterval() returns the old value, use that for 'true'
InferredSpans.setProfilerInterval(
configurationValue.equals("true")
Expand All @@ -366,8 +357,7 @@ public static final class PollingInterval extends ConfigOption {
}

@Override
void update(String configurationValue, OpampManager opampManager)
throws IllegalArgumentException {
void update(String configurationValue, OpampManager opampManager) {
try {
Duration duration = Duration.parse("PT" + configurationValue);
opampManager.setPollingDelay(duration);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,17 +174,17 @@ private Map<String, String> parseCentralConfiguration(ByteString centralConfig)

@Override
public void onConnect(OpampClient client) {
logger.log(Level.INFO, "onConnect({0})", client);
logger.log(Level.FINE, "onConnect({0})", client);
}

@Override
public void onConnectFailed(OpampClient client, @Nullable Throwable throwable) {
logger.log(Level.INFO, "onConnect({0}, {1})", new Object[] {client, throwable});
logger.log(Level.WARNING, "onConnectFailed({0}, {1})", new Object[] {client, throwable});
}

@Override
public void onErrorResponse(OpampClient client, @Nonnull ServerErrorResponse errorResponse) {
logger.log(Level.INFO, "onErrorResponse({0}, {1})", new Object[] {client, errorResponse});
logger.log(Level.WARNING, "onErrorResponse({0}, {1})", new Object[] {client, errorResponse});
}
}

Expand Down
1 change: 0 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ log4j2 = ["log4j2-core", "log4j2-slf4j"]
[plugins]

jib = { id = "com.google.cloud.tools.jib", version.ref = "jib" }
taskinfo = { id = "org.barfuin.gradle.taskinfo", version = '3.1.0' }
jmh = { id = "me.champeau.jmh", version = "0.7.3" }
nexusPublish = { id = "io.github.gradle-nexus.publish-plugin", version = '2.0.0' }
dockerJavaApplication = { id = "com.bmuschko.docker-java-application", version = "10.0.0" }
Expand Down
1 change: 0 additions & 1 deletion resources/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
plugins {
id("elastic-otel.java-conventions")
alias(catalog.plugins.taskinfo)
}

dependencies {
Expand Down
1 change: 0 additions & 1 deletion smoke-tests/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// TODO : convert to kotlin for consistency
plugins {
id("elastic-otel.java-conventions")
alias catalog.plugins.taskinfo
}

configurations {
Expand Down
1 change: 0 additions & 1 deletion smoke-tests/test-app-war/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
plugins {
id("elastic-otel.java-conventions")
alias(catalog.plugins.taskinfo)
war
}

Expand Down
1 change: 0 additions & 1 deletion smoke-tests/test-app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ plugins {
id("com.gradleup.shadow")
id("elastic-otel.java-conventions")
alias(catalog.plugins.jib)
alias(catalog.plugins.taskinfo)
}

val mainClass = "co.elastic.otel.test.AppMain"
Expand Down
Loading