|
8 | 8 | import static io.opentelemetry.api.incubator.config.DeclarativeConfigProperties.empty;
|
9 | 9 |
|
10 | 10 | import io.opentelemetry.api.incubator.config.ConfigProvider;
|
| 11 | +import io.opentelemetry.api.incubator.config.DeclarativeConfigException; |
11 | 12 | import io.opentelemetry.api.incubator.config.DeclarativeConfigProperties;
|
12 | 13 | import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
|
13 | 14 | import java.time.Duration;
|
@@ -64,13 +65,23 @@ public final class DeclarativeConfigPropertiesBridge implements ConfigProperties
|
64 | 65 |
|
65 | 66 | static {
|
66 | 67 | JAVA_MAPPING_RULES.put("otel.instrumentation.common.default-enabled", "common.default.enabled");
|
| 68 | + JAVA_MAPPING_RULES.put("otel.javaagent.logging.application.logs-buffer-max-records", "agent.logging.output.application.logs_buffer_max_records"); |
67 | 69 |
|
68 | 70 | // not supported in SDK yet (this is strictly typed)
|
69 |
| -// GENERAL_MAPPING_RULES.put("otel.instrumentation.http.known-methods", "http.known_methods"); |
70 |
| - GENERAL_MAPPING_RULES.put("otel.instrumentation.http.client.capture-request-headers", "http.client.request_captured_headers"); |
71 |
| - GENERAL_MAPPING_RULES.put("otel.instrumentation.http.client.capture-response-headers", "http.client.response_captured_headers"); |
72 |
| - GENERAL_MAPPING_RULES.put("otel.instrumentation.http.server.capture-request-headers", "http.server.request_captured_headers"); |
73 |
| - GENERAL_MAPPING_RULES.put("otel.instrumentation.http.server.capture-response-headers", "http.server.response_captured_headers"); |
| 71 | + // GENERAL_MAPPING_RULES.put("otel.instrumentation.http.known-methods", |
| 72 | + // "http.known_methods"); |
| 73 | + GENERAL_MAPPING_RULES.put( |
| 74 | + "otel.instrumentation.http.client.capture-request-headers", |
| 75 | + "http.client.request_captured_headers"); |
| 76 | + GENERAL_MAPPING_RULES.put( |
| 77 | + "otel.instrumentation.http.client.capture-response-headers", |
| 78 | + "http.client.response_captured_headers"); |
| 79 | + GENERAL_MAPPING_RULES.put( |
| 80 | + "otel.instrumentation.http.server.capture-request-headers", |
| 81 | + "http.server.request_captured_headers"); |
| 82 | + GENERAL_MAPPING_RULES.put( |
| 83 | + "otel.instrumentation.http.server.capture-response-headers", |
| 84 | + "http.server.response_captured_headers"); |
74 | 85 | }
|
75 | 86 |
|
76 | 87 | private static Map<String, String> getPeerServiceMapping(
|
@@ -99,6 +110,10 @@ public DeclarativeConfigPropertiesBridge(ConfigProvider configProvider) {
|
99 | 110 | @Nullable
|
100 | 111 | @Override
|
101 | 112 | public String getString(String propertyName) {
|
| 113 | + if ("otel.javaagent.logging".equals(propertyName)) { |
| 114 | + return agentLoggerName(); |
| 115 | + } |
| 116 | + |
102 | 117 | return getPropertyValue(propertyName, DeclarativeConfigProperties::getString);
|
103 | 118 | }
|
104 | 119 |
|
@@ -215,4 +230,28 @@ private static String getJavaPath(String property) {
|
215 | 230 | }
|
216 | 231 | return null;
|
217 | 232 | }
|
| 233 | + |
| 234 | + private String agentLoggerName() { |
| 235 | + DeclarativeConfigProperties logOutput = getLogOutput(); |
| 236 | + DeclarativeConfigProperties application = logOutput.getStructured("application"); |
| 237 | + DeclarativeConfigProperties simple = logOutput.getStructured("simple"); |
| 238 | + if (application != null) { |
| 239 | + if (simple != null) { |
| 240 | + throw new DeclarativeConfigException( |
| 241 | + "Both 'application' and 'simple' log output are configured. " |
| 242 | + + "Please choose one of them."); |
| 243 | + } |
| 244 | + return "application"; |
| 245 | + } |
| 246 | + // simple is the default |
| 247 | + return "simple"; |
| 248 | + } |
| 249 | + |
| 250 | + private DeclarativeConfigProperties getLogOutput() { |
| 251 | + return getAgent().getStructured("logging", empty()).getStructured("output", empty()); |
| 252 | + } |
| 253 | + |
| 254 | + private DeclarativeConfigProperties getAgent() { |
| 255 | + return instrumentationJavaNode.getStructured("agent", empty()); |
| 256 | + } |
218 | 257 | }
|
0 commit comments