Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for missing spring list properties #12819

Merged
merged 7 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,138 @@ public void setResource(Resource resource) {
}
}

/**
* This class is internal and is hence not for public use. Its APIs are unstable and can change at
* any time.
*/
public static final class HasExporters {
private List<String> exporter = Collections.emptyList();

public List<String> getExporter() {
return exporter;
}

public void setExporter(List<String> exporter) {
this.exporter = exporter;
}
}

/**
* This class is internal and is hence not for public use. Its APIs are unstable and can change at
* any time.
*/
public static final class Instrumentation {
/**
* This class is internal and is hence not for public use. Its APIs are unstable and can change
* at any time.
*/
public static final class Http {
/**
* This class is internal and is hence not for public use. Its APIs are unstable and can
* change at any time.
*/
public static final class Client {
private List<String> captureRequestHeaders = Collections.emptyList();
private List<String> captureResponseHeaders = Collections.emptyList();

public List<String> getCaptureRequestHeaders() {
return captureRequestHeaders;
}

public void setCaptureRequestHeaders(List<String> captureRequestHeaders) {
this.captureRequestHeaders = captureRequestHeaders;
}

public List<String> getCaptureResponseHeaders() {
return captureResponseHeaders;
}

public void setCaptureResponseHeaders(List<String> captureResponseHeaders) {
this.captureResponseHeaders = captureResponseHeaders;
}
}

/**
* This class is internal and is hence not for public use. Its APIs are unstable and can
* change at any time.
*/
public static final class Server {
private List<String> captureRequestHeaders = Collections.emptyList();
private List<String> captureResponseHeaders = Collections.emptyList();

public List<String> getCaptureRequestHeaders() {
return captureRequestHeaders;
}

public void setCaptureRequestHeaders(List<String> captureRequestHeaders) {
this.captureRequestHeaders = captureRequestHeaders;
}

public List<String> getCaptureResponseHeaders() {
return captureResponseHeaders;
}

public void setCaptureResponseHeaders(List<String> captureResponseHeaders) {
this.captureResponseHeaders = captureResponseHeaders;
}
}

private Client client = new Client();

private Server server = new Server();

private List<String> knownMethods = Collections.emptyList();

public Client getClient() {
return client;
}

public void setClient(Client client) {
this.client = client;
}

public Server getServer() {
return server;
}

public void setServer(Server server) {
this.server = server;
}

public List<String> getKnownMethods() {
return knownMethods;
}

public void setKnownMethods(List<String> knownMethods) {
this.knownMethods = knownMethods;
}
}

private Http http = new Http();

public Http getHttp() {
return http;
}

public void setHttp(Http http) {
this.http = http;
}
}

private List<String> propagators = Collections.emptyList();

private Java java = new Java();

private Experimental experimental = new Experimental();

private HasExporters logs = new HasExporters();

private HasExporters metrics = new HasExporters();

private HasExporters traces = new HasExporters();

private Instrumentation instrumentation = new Instrumentation();

public List<String> getPropagators() {
return propagators;
}
Expand All @@ -225,6 +351,38 @@ public void setExperimental(Experimental experimental) {
this.experimental = experimental;
}

public HasExporters getLogs() {
return logs;
}

public void setLogs(HasExporters logs) {
this.logs = logs;
}

public HasExporters getMetrics() {
return metrics;
}

public void setMetrics(HasExporters metrics) {
this.metrics = metrics;
}

public HasExporters getTraces() {
return traces;
}

public void setTraces(HasExporters traces) {
this.traces = traces;
}

public Instrumentation getInstrumentation() {
return instrumentation;
}

public void setInstrumentation(Instrumentation instrumentation) {
this.instrumentation = instrumentation;
}

public List<String> getJavaEnabledResourceProviders() {
return java.getEnabled().getResource().getProviders();
}
Expand All @@ -240,4 +398,36 @@ public List<String> getExperimentalMetricsViewConfig() {
public List<String> getExperimentalResourceDisabledKeys() {
return experimental.getResource().getDisabled().getKeys();
}

public List<String> getLogsExporter() {
return logs.getExporter();
}

public List<String> getMetricsExporter() {
return metrics.getExporter();
}

public List<String> getTracesExporter() {
return traces.getExporter();
}

public List<String> getHttpClientCaptureRequestHeaders() {
return instrumentation.getHttp().getClient().getCaptureRequestHeaders();
}

public List<String> getHttpClientCaptureResponseHeaders() {
return instrumentation.getHttp().getClient().getCaptureResponseHeaders();
}

public List<String> getHttpServerCaptureRequestHeaders() {
return instrumentation.getHttp().getServer().getCaptureRequestHeaders();
}

public List<String> getHttpServerCaptureResponseHeaders() {
return instrumentation.getHttp().getServer().getCaptureResponseHeaders();
}

public List<String> getHttpKnownMethods() {
return instrumentation.getHttp().getKnownMethods();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class SpringConfigProperties implements ConfigProperties {
private final OtelResourceProperties resourceProperties;
private final ConfigProperties otelSdkProperties;
private final ConfigProperties customizedListProperties;
private final Map<String, List<String>> listPropertyValues = new HashMap<>();
private final Map<String, List<String>> listPropertyValues;

static final String DISABLED_KEY = "otel.java.disabled.resource.providers";
static final String ENABLED_KEY = "otel.java.enabled.resource.providers";
Expand All @@ -52,15 +52,46 @@ public SpringConfigProperties(
this.customizedListProperties =
createCustomizedListProperties(otelSdkProperties, otelSpringProperties);

listPropertyValues.put(ENABLED_KEY, otelSpringProperties.getJavaEnabledResourceProviders());
listPropertyValues.put(DISABLED_KEY, otelSpringProperties.getJavaDisabledResourceProviders());
listPropertyValues.put(
listPropertyValues = createListPropertyValues(otelSpringProperties);
}

private static Map<String, List<String>> createListPropertyValues(
OtelSpringProperties otelSpringProperties) {
Map<String, List<String>> values = new HashMap<>();

// SDK
values.put(ENABLED_KEY, otelSpringProperties.getJavaEnabledResourceProviders());
values.put(DISABLED_KEY, otelSpringProperties.getJavaDisabledResourceProviders());
values.put(
"otel.experimental.metrics.view.config",
otelSpringProperties.getExperimentalMetricsViewConfig());
listPropertyValues.put(
values.put(
"otel.experimental.resource.disabled.keys",
otelSpringProperties.getExperimentalResourceDisabledKeys());
listPropertyValues.put("otel.propagators", otelSpringProperties.getPropagators());
values.put("otel.propagators", otelSpringProperties.getPropagators());

// exporters
values.put("otel.logs.exporter", otelSpringProperties.getLogsExporter());
values.put("otel.metrics.exporter", otelSpringProperties.getMetricsExporter());
values.put("otel.traces.exporter", otelSpringProperties.getTracesExporter());

// instrumentations
values.put(
"otel.instrumentation.http.client.capture-request-headers",
otelSpringProperties.getHttpClientCaptureRequestHeaders());
values.put(
"otel.instrumentation.http.client.capture-response-headers",
otelSpringProperties.getHttpClientCaptureResponseHeaders());
values.put(
"otel.instrumentation.http.server.capture-request-headers",
otelSpringProperties.getHttpServerCaptureRequestHeaders());
values.put(
"otel.instrumentation.http.server.capture-response-headers",
otelSpringProperties.getHttpServerCaptureResponseHeaders());
values.put(
"otel.instrumentation.http.known-methods", otelSpringProperties.getHttpKnownMethods());

return values;
}

private static Map<String, String> createMapForListProperty(
Expand Down Expand Up @@ -174,7 +205,9 @@ public List<String> getList(String name) {
if (!c.isEmpty()) {
return c;
}
return list;
if (!list.isEmpty()) {
return list;
}
}

return or(environment.getProperty(normalizedName, List.class), otelSdkProperties.getList(name));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,8 @@
},
{
"name": "otel.instrumentation.logback-appender.experimental.capture-mdc-attributes",
"type": "java.util.List<java.lang.String>",
"description": "MDC attributes to capture. Use the wildcard character <code>*</code> to capture all attributes."
"type": "java.lang.String",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what you mean.

From what I observe, @Value does not seem to work in LogbackAppenderApplicationListener.

org.springframework.boot.context.logging.LoggingApplicationListener does not use @Value .

"description": "MDC attributes to capture. Use the wildcard character <code>*</code> to capture all attributes. This is a comma-separated list of attribute names."
},
{
"name": "otel.instrumentation.logback-mdc.enabled",
Expand Down

This file was deleted.

Loading
Loading