forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request quarkusio#18699 from cyrille-leclerc/features/supp…
…ort-otlp-grpc-headers [OpenTelemetry OTLP Exporter extension] Add support for gRPC headers
- Loading branch information
Showing
8 changed files
with
153 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
...lemetry/runtime/src/test/java/io/quarkus/opentelemetry/runtime/OpenTelemetryUtilTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package io.quarkus.opentelemetry.runtime; | ||
|
||
import java.util.AbstractMap; | ||
import java.util.Arrays; | ||
import java.util.Collections; | ||
import java.util.Map; | ||
|
||
import org.assertj.core.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class OpenTelemetryUtilTest { | ||
|
||
@Test | ||
public void testConvertKeyValueListToMap() { | ||
Map<String, String> actual = OpenTelemetryUtil | ||
.convertKeyValueListToMap(Arrays.asList( | ||
"service.name=myservice", | ||
"service.version=1.0", | ||
"deployment.environment=production")); | ||
Assertions.assertThat(actual).containsExactly( | ||
new AbstractMap.SimpleEntry<>("service.name", "myservice"), | ||
new AbstractMap.SimpleEntry<>("service.version", "1.0"), | ||
new AbstractMap.SimpleEntry<>("deployment.environment", "production")); | ||
} | ||
|
||
@Test | ||
public void testConvertKeyValueListToMap_skip_empty_values() { | ||
Map<String, String> actual = OpenTelemetryUtil | ||
.convertKeyValueListToMap(Arrays.asList( | ||
"service.name=myservice", | ||
"service.version=1.0", | ||
"deployment.environment=production", | ||
"")); | ||
Assertions.assertThat(actual).containsExactly( | ||
new AbstractMap.SimpleEntry<>("service.name", "myservice"), | ||
new AbstractMap.SimpleEntry<>("service.version", "1.0"), | ||
new AbstractMap.SimpleEntry<>("deployment.environment", "production")); | ||
} | ||
|
||
@Test | ||
public void testConvertKeyValueListToMap_last_value_takes_precedence() { | ||
Map<String, String> actual = OpenTelemetryUtil | ||
.convertKeyValueListToMap(Arrays.asList( | ||
"service.name=myservice to be overwritten", | ||
"service.version=1.0", | ||
"deployment.environment=production", | ||
"service.name=myservice", | ||
"")); | ||
Assertions.assertThat(actual).containsExactly( | ||
new AbstractMap.SimpleEntry<>("service.name", "myservice"), | ||
new AbstractMap.SimpleEntry<>("service.version", "1.0"), | ||
new AbstractMap.SimpleEntry<>("deployment.environment", "production")); | ||
} | ||
|
||
@Test | ||
public void testConvertKeyValueListToMap_empty_value() { | ||
Map<String, String> actual = OpenTelemetryUtil | ||
.convertKeyValueListToMap(Collections.emptyList()); | ||
Assertions.assertThat(actual).containsExactly(); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...emetry/runtime/src/test/java/io/quarkus/opentelemetry/runtime/tracing/TracerUtilTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package io.quarkus.opentelemetry.runtime.tracing; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import org.assertj.core.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import io.opentelemetry.api.common.Attributes; | ||
import io.opentelemetry.sdk.resources.Resource; | ||
import io.opentelemetry.semconv.resource.attributes.ResourceAttributes; | ||
|
||
public class TracerUtilTest { | ||
|
||
@Test | ||
public void testMapResourceAttributes() { | ||
List<String> resourceAttributes = Arrays.asList( | ||
"service.name=myservice", | ||
"service.namespace=mynamespace", | ||
"service.version=1.0", | ||
"deployment.environment=production"); | ||
Resource resource = TracerUtil.mapResourceAttributes(resourceAttributes); | ||
Attributes attributes = resource.getAttributes(); | ||
Assertions.assertThat(attributes.size()).isEqualTo(4); | ||
Assertions.assertThat(attributes.get(ResourceAttributes.SERVICE_NAME)).isEqualTo("myservice"); | ||
Assertions.assertThat(attributes.get(ResourceAttributes.SERVICE_NAMESPACE)).isEqualTo("mynamespace"); | ||
Assertions.assertThat(attributes.get(ResourceAttributes.SERVICE_VERSION)).isEqualTo("1.0"); | ||
Assertions.assertThat(attributes.get(ResourceAttributes.DEPLOYMENT_ENVIRONMENT)).isEqualTo("production"); | ||
} | ||
} |