Skip to content
Draft
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
8 changes: 3 additions & 5 deletions custom/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ dependencies {
compileOnly("io.opentelemetry.javaagent:opentelemetry-javaagent-tooling")
compileOnly(libs.bundles.semconv)

implementation(libs.contribConsistentSampling) {
// exclude transitive dependency as it's provided through agent packaging
exclude(group = "io.opentelemetry", module = "opentelemetry-sdk-trace")
exclude(group = "io.opentelemetry", module = "opentelemetry-sdk-extension-autoconfigure-spi")
}
implementation(libs.contribSpanStacktrace) {
// exclude transitive dependency as it's provided through agent packaging
exclude(group = "io.opentelemetry", module = "opentelemetry-sdk")
Expand All @@ -45,6 +40,9 @@ dependencies {
exclude(group = "io.opentelemetry", module = "opentelemetry-sdk-extension-autoconfigure-spi")
}

// samplers, included in upstream agent
compileOnly("io.opentelemetry:opentelemetry-sdk-extension-incubator")

testImplementation(libs.contribSpanStacktrace)

// needs to be added in order to allow access to AgentListener interface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,7 @@ private static void resourceProviders(
private static void defaultSampler(
Map<String, String> config, ConfigProperties configProperties) {
// enable EDOT default sampler by default if not explicitly disabled
String sampler =
configProperties.getString(
TRACES_SAMPLER, "experimental_composite_parentbased_traceidratio");
String sampler = configProperties.getString(TRACES_SAMPLER, "elastic");
config.put(TRACES_SAMPLER, sampler);
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
package co.elastic.otel.config;

import co.elastic.otel.compositesampling.DynamicCompositeParentBasedTraceIdRatioBasedSampler;
import co.elastic.otel.sampling.ElasticSampler;
import com.google.auto.service.AutoService;
import io.opentelemetry.javaagent.extension.AgentListener;
import io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdk;
Expand Down Expand Up @@ -49,7 +49,7 @@ public void afterAgent(AutoConfiguredOpenTelemetrySdk autoConfiguredOpenTelemetr
logger.info(autoConfiguredOpenTelemetrySdk.toString());
}
if (autoConfiguredOpenTelemetrySdk.getOpenTelemetrySdk().getSdkTracerProvider().getSampler()
instanceof DynamicCompositeParentBasedTraceIdRatioBasedSampler) {
instanceof ElasticSampler) {
enableDynamicSamplingRate = true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,20 @@
*/
package co.elastic.otel.dynamicconfig;

import co.elastic.otel.compositesampling.DynamicCompositeParentBasedTraceIdRatioBasedSampler;
import co.elastic.otel.config.ConfigLoggingAgentListener;
import co.elastic.otel.dynamicconfig.internal.OpampManager;
import co.elastic.otel.logging.AgentLog;
import co.elastic.otel.sampling.ElasticSampler;
import io.opentelemetry.contrib.inferredspans.InferredSpans;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
import io.opentelemetry.sdk.trace.SdkTracerProviderBuilder;
import java.io.IOException;
import java.text.MessageFormat;
import java.time.Duration;
import java.time.format.DateTimeParseException;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.logging.Level;
Expand Down Expand Up @@ -151,7 +153,9 @@ public static class Configs {
new LoggingLevel(),
new SamplingRate(),
new InferSpans(),
new PollingInterval())
new PollingInterval(),
new HttpExcludeUrls(),
new HttpExcludeUserAgents())
.collect(Collectors.toMap(ConfigOption::getConfigName, option -> option));
}

Expand Down Expand Up @@ -199,9 +203,9 @@ public abstract static class ConfigOption {
protected final String configName;
protected final String defaultConfigStringValue;

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

public String getConfigName() {
Expand Down Expand Up @@ -331,11 +335,13 @@ public static final class SamplingRate extends ConfigOption {
void update(String configurationValue, OpampManager opampManager)
throws IllegalArgumentException {
if (!ConfigLoggingAgentListener.getEnableDynamicSamplingRate()) {
// TODO: why do we see this log message on startup ?
logger.warning("ignoring \"sampling_rate\" because non-default sampler in use");
return;
}
DynamicCompositeParentBasedTraceIdRatioBasedSampler.setRatio(
Double.parseDouble(configurationValue));
ElasticSampler.INSTANCE.toBuilder()
.withProbability(Double.parseDouble(configurationValue))
.buildAndSetGlobal();
}
}

Expand Down Expand Up @@ -372,4 +378,34 @@ void update(String configurationValue, OpampManager opampManager)
}
}
}

public static final class HttpExcludeUrls extends ConfigOption {
HttpExcludeUrls() {
super("http_ignore_urls", "");
}

@Override
void update(String configurationValue, OpampManager opampManager)
throws IllegalArgumentException {

List<String> patterns = Arrays.asList(configurationValue.split(","));
ElasticSampler.INSTANCE.toBuilder().withIgnoredUrlPatterns(patterns).buildAndSetGlobal();
}
}

public static final class HttpExcludeUserAgents extends ConfigOption {
HttpExcludeUserAgents() {
super("http_ignore_user_agents", "");
}

@Override
void update(String configurationValue, OpampManager opampManager)
throws IllegalArgumentException {

List<String> patterns = Arrays.asList(configurationValue.split(","));
ElasticSampler.INSTANCE.toBuilder()
.withIgnoredUserAgentPatterns(patterns)
.buildAndSetGlobal();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -165,17 +165,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.FINE, "onConnect({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.FINE, "onErrorResponse({0}, {1})", new Object[] {client, errorResponse});
}
}

Expand Down
Loading
Loading