Files
Moritz Halbritter 3f7cebd802 Polish "Allow configuring Micrometer Tracing MDC keys"
Derive logging.pattern.correlation from the configured MDC keys so that
log correlation keeps working when the keys are customized, instead of
silently rendering a blank correlation field.

Reject empty MDC keys and only clear Brave's default correlation fields
when the keys have been customized, so that applications using the
defaults are unaffected if Brave adds a default field.

Replace the tests that asserted on bean wiring with integration tests
covering the MDC contents, plus a smoke test for the log output.

See gh-50595
2026-08-25 13:54:00 +02:00

70 lines
2.9 KiB
Groovy

/*
* Copyright 2012-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
plugins {
id "java"
id "org.springframework.boot.docker-test"
}
description = "Spring Boot OpenTelemetry smoke test"
dependencies {
implementation(project(":starter:spring-boot-starter-web"))
implementation(project(":starter:spring-boot-starter-opentelemetry"))
testImplementation(project(":starter:spring-boot-starter-test"))
testImplementation(project(":test-support:spring-boot-test-support"))
testImplementation("io.micrometer:micrometer-registry-otlp")
dockerTestImplementation(project(":core:spring-boot-testcontainers"))
dockerTestImplementation(project(":starter:spring-boot-starter-test"))
dockerTestImplementation(project(":test-support:spring-boot-docker-test-support"))
dockerTestImplementation("org.awaitility:awaitility")
dockerTestImplementation("org.testcontainers:testcontainers-junit-jupiter")
}
tasks.named("test") {
environment "OTEL_EXPORTER_OTLP_ENDPOINT", "http://localhost:4318"
environment "OTEL_EXPORTER_OTLP_TRACES_ENDPOINT", "http://localhost:4319/custom/traces"
environment "OTEL_EXPORTER_OTLP_METRICS_ENDPOINT", "http://localhost:4320/custom/metrics"
environment "OTEL_EXPORTER_OTLP_LOGS_ENDPOINT", "http://localhost:4321/custom/logs"
environment "OTEL_RESOURCE_ATTRIBUTES", "service.name=my-service,service.version=1.0.0"
environment "OTEL_EXPORTER_OTLP_HEADERS", "Authorization=Bearer token123,X-Custom-Header=value1"
environment "OTEL_EXPORTER_OTLP_TRACES_HEADERS", "X-Trace-Header=trace-value"
environment "OTEL_EXPORTER_OTLP_COMPRESSION", "gzip"
environment "OTEL_EXPORTER_OTLP_TRACES_TIMEOUT", "5000"
environment "OTEL_EXPORTER_OTLP_PROTOCOL", "http/protobuf"
}
tasks.named("dockerTest") {
environment "OTEL_EXPORTER_OTLP_ENDPOINT", "https://localhost:12345"
environment "OTEL_EXPORTER_OTLP_CERTIFICATE", "${project.projectDir}/src/dockerTest/resources/certs/ca.crt"
environment "OTEL_EXPORTER_OTLP_HEADERS", "Authorization=Basic dGVzdHVzZXI6dGVzdHBhc3MxMjM=" // testuser:testpass123
environment "OTEL_RESOURCE_ATTRIBUTES", "service.name=my-service,service.version=1.0.0"
environment "OTEL_TRACES_SAMPLER", "traceidratio"
environment "OTEL_TRACES_SAMPLER_ARG", "1.0"
environment "OTEL_METRIC_EXPORT_INTERVAL", "1000"
}
tasks.named("compileTestJava") {
options.nullability.checking = "tests"
}
tasks.named("compileDockerTestJava") {
options.nullability.checking = "tests"
}