Skip to content

Commit 5a2c60e

Browse files
committed
add test
1 parent 389b960 commit 5a2c60e

File tree

2 files changed

+6
-19
lines changed

2 files changed

+6
-19
lines changed

instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/EmbeddedConfigFile.java

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,13 @@ static OpenTelemetryConfigurationModel extractModel(ConfigurableEnvironment envi
4646
private static OpenTelemetryConfigurationModel getModel(
4747
ConfigurableEnvironment environment, OriginTrackedMapPropertySource source)
4848
throws IOException {
49-
String name = source.getName();
50-
System.out.println("Property Source: " + name); // todo remove
51-
Matcher matcher = PATTERN.matcher(name);
49+
Matcher matcher = PATTERN.matcher(source.getName());
5250
if (matcher.matches()) {
5351
String file = matcher.group(1);
54-
System.out.println("Found application.yaml: " + file);
5552

5653
try (InputStream resourceAsStream =
5754
environment.getClass().getClassLoader().getResourceAsStream(file)) {
58-
// Print the contents of the application.yaml file
5955
if (resourceAsStream != null) {
60-
// String content = new String(resourceAsStream.readAllBytes());
61-
// System.out.println("Contents of " + file + ":"); // todo remove
62-
// System.out.println(content); // todo remove
63-
6456
return extractOtelConfigFile(resourceAsStream);
6557
} else {
6658
throw new IllegalStateException("Unable to load " + file + " in the classpath.");
@@ -88,21 +80,11 @@ private static String parseOtelNode(InputStream in) {
8880
}
8981

9082
private static OpenTelemetryConfigurationModel extractOtelConfigFile(InputStream content) {
91-
//
92-
// https://github.com/open-telemetry/opentelemetry-configuration/blob/c205770a956713e512eddb056570a99737e3383a/examples/kitchen-sink.yaml#L11
93-
94-
// 1. read to yaml tree in jackson
95-
// ObjectMapper yamlMapper = new ObjectMapper(new YAMLFactory());
96-
// JsonNode rootNode = yamlMapper.readTree(content);
97-
9883
String node = parseOtelNode(content);
9984
if (node == null || node.isEmpty()) {
10085
throw new IllegalStateException("otel node is empty or null in the YAML file.");
10186
}
10287

103-
System.out.println("OpenTelemetry configuration file content:"); // todo remove
104-
System.out.println(node); // todo remove
105-
10688
return DeclarativeConfiguration.parse(
10789
new ByteArrayInputStream(node.getBytes(StandardCharsets.UTF_8)));
10890
}

smoke-tests-otel-starter/spring-boot-2/build.gradle.kts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ configurations.configureEach {
3838
testing {
3939
suites {
4040
val testDeclarativeConfig by registering(JvmTestSuite::class) {
41+
dependencies {
42+
implementation(project())
43+
implementation(project(":smoke-tests-otel-starter:spring-boot-common"))
44+
implementation("org.springframework.boot:spring-boot-starter-test:2.6.15")
45+
}
4146
}
4247
}
4348
}

0 commit comments

Comments
 (0)