Skip to content

Commit

Permalink
add test for experimental kafka span attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
zeitlinger committed May 15, 2024
1 parent 54cddcc commit 8271414
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ public ConfigProperties configProperties() {
@ConditionalOnBean(OpenTelemetry.class)
@ConditionalOnMissingBean({ConfigProperties.class})
public static class FallbackConfigProperties {

@Bean("configProperties")
public ConfigProperties configProperties() {
return DefaultConfigProperties.create(Collections.emptyMap());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import io.opentelemetry.instrumentation.spring.autoconfigure.internal.ConditionalOnEnabledInstrumentation;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.kafka.DefaultKafkaProducerFactoryCustomizer;
import org.springframework.context.annotation.Bean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ void setUpContext() {
KafkaInstrumentationAutoConfiguration.class,
KafkaConfig.class))
.withPropertyValues(
"otel.instrumentation.kafka.experimental-span-attributes=true",
"spring.kafka.bootstrap-servers=" + kafka.getBootstrapServers(),
"spring.kafka.consumer.auto-offset-reset=earliest",
"spring.kafka.consumer.linger-ms=10",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.satisfies;

import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.semconv.incubating.MessagingIncubatingAttributes;
import org.apache.kafka.clients.admin.NewTopic;
Expand Down Expand Up @@ -97,6 +98,9 @@ void shouldInstrumentProducerAndConsumer() {
equalTo(
MessagingIncubatingAttributes.MESSAGING_KAFKA_CONSUMER_GROUP,
"testListener"),
satisfies(
AttributeKey.longKey("kafka.record.queue_time_ms"),
AbstractLongAssert::isNotNegative),
satisfies(
MessagingIncubatingAttributes.MESSAGING_CLIENT_ID,
stringAssert -> stringAssert.startsWith("consumer"))),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
otel:
instrumentation:
kafka:
experimental-span-attributes: true
logback-appender:
experimental:
capture-code-attributes: true
Expand Down

0 comments on commit 8271414

Please sign in to comment.