Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions docs/instrumentation-list.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3743,12 +3743,35 @@ libraries:
type: STRING
hystrix:
- name: hystrix-1.4
description: This instrumentation enables the generation of INTERNAL spans for
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure whether having INTERNAL here provides value

Hystrix command executions and fallbacks.
source_path: instrumentation/hystrix-1.4
scope:
name: io.opentelemetry.hystrix-1.4
target_versions:
javaagent:
- com.netflix.hystrix:hystrix-core:[1.4.0,)
configurations:
- name: otel.instrumentation.hystrix.experimental-span-attributes
description: Enables capturing the experimental `hystrix.command`, `hystrix.circuit_open`
and `hystrix.group` span attributes.
type: boolean
default: false
telemetry:
- when: default
spans:
- span_kind: INTERNAL
attributes: []
- when: otel.instrumentation.hystrix.experimental-span-attributes=true
spans:
- span_kind: INTERNAL
attributes:
- name: hystrix.circuit_open
type: BOOLEAN
- name: hystrix.command
type: STRING
- name: hystrix.group
type: STRING
influxdb:
- name: influxdb-2.4
source_path: instrumentation/influxdb-2.4
Expand Down
2 changes: 2 additions & 0 deletions instrumentation-docs/instrumentations.sh
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ readonly INSTRUMENTATIONS=(
"hibernate:hibernate-6.0:javaagent:testExperimental"
"hibernate:hibernate-procedure-call-4.3:javaagent:test"
"hibernate:hibernate-procedure-call-4.3:javaagent:testExperimental"
"hystrix-1.4:javaagent:test"
"hystrix-1.4:javaagent:testExperimental"
)

# Some instrumentation test suites don't run ARM, so we use colima to run them in an x86_64
Expand Down
32 changes: 23 additions & 9 deletions instrumentation/hystrix-1.4/javaagent/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,27 @@ dependencies {
library("io.reactivex:rxjava:1.0.8")
}

tasks.withType<Test>().configureEach {
// TODO run tests both with and without experimental span attributes
jvmArgs("-Dotel.instrumentation.hystrix.experimental-span-attributes=true")
// Disable so failure testing below doesn't inadvertently change the behavior.
jvmArgs("-Dhystrix.command.default.circuitBreaker.enabled=false")
jvmArgs("-Dio.opentelemetry.javaagent.shaded.io.opentelemetry.context.enableStrictContext=false")

// Uncomment for debugging:
// jvmArgs("-Dhystrix.command.default.execution.timeout.enabled=false")
tasks {
withType<Test>().configureEach {
// Disable so failure testing below doesn't inadvertently change the behavior.
jvmArgs("-Dhystrix.command.default.circuitBreaker.enabled=false")
jvmArgs("-Dio.opentelemetry.javaagent.shaded.io.opentelemetry.context.enableStrictContext=false")

systemProperty("collectMetadata", findProperty("collectMetadata")?.toString() ?: "false")

// Uncomment for debugging:
// jvmArgs("-Dhystrix.command.default.execution.timeout.enabled=false")
}

val testExperimental by registering(Test::class) {
testClassesDirs = sourceSets.test.get().output.classesDirs
classpath = sourceSets.test.get().runtimeClasspath

jvmArgs("-Dotel.instrumentation.hystrix.experimental-span-attributes=true")
systemProperty("metadataConfig", "otel.instrumentation.hystrix.experimental-span-attributes=true")
}

check {
dependsOn(testExperimental)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.javaagent.instrumentation.hystrix;

import static io.opentelemetry.api.common.AttributeKey.booleanKey;
import static io.opentelemetry.api.common.AttributeKey.stringKey;

import io.opentelemetry.api.common.AttributeKey;
import javax.annotation.Nullable;

class ExperimentalTestHelper {
private static final boolean isEnabled =
Boolean.getBoolean("otel.instrumentation.hystrix.experimental-span-attributes");

static final AttributeKey<String> HYSTRIX_COMMAND = stringKey("hystrix.command");
static final AttributeKey<String> HYSTRIX_GROUP = stringKey("hystrix.group");
static final AttributeKey<Boolean> HYSTRIX_CIRCUIT_OPEN = booleanKey("hystrix.circuit_open");

@Nullable
static String experimental(String value) {
if (isEnabled) {
return value;
}
return null;
}

@Nullable
static Boolean experimental(Boolean value) {
if (isEnabled) {
return value;
}
return null;
}

private ExperimentalTestHelper() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@

package io.opentelemetry.javaagent.instrumentation.hystrix;

import static io.opentelemetry.api.common.AttributeKey.booleanKey;
import static io.opentelemetry.api.common.AttributeKey.stringKey;
import static io.opentelemetry.javaagent.instrumentation.hystrix.ExperimentalTestHelper.HYSTRIX_CIRCUIT_OPEN;
import static io.opentelemetry.javaagent.instrumentation.hystrix.ExperimentalTestHelper.HYSTRIX_COMMAND;
import static io.opentelemetry.javaagent.instrumentation.hystrix.ExperimentalTestHelper.HYSTRIX_GROUP;
import static io.opentelemetry.javaagent.instrumentation.hystrix.ExperimentalTestHelper.experimental;
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo;
import static org.assertj.core.api.Assertions.assertThat;

Expand All @@ -24,7 +26,7 @@
class HystrixObservableChainTest {

@RegisterExtension
protected static final InstrumentationExtension testing = AgentInstrumentationExtension.create();
static final InstrumentationExtension testing = AgentInstrumentationExtension.create();

@Test
@SuppressWarnings("RxReturnValueIgnored")
Expand Down Expand Up @@ -93,9 +95,9 @@ protected Observable<String> construct() {
span.hasName("ExampleGroup.TestCommand.execute")
.hasParent(trace.getSpan(0))
.hasAttributesSatisfyingExactly(
equalTo(stringKey("hystrix.command"), "TestCommand"),
equalTo(stringKey("hystrix.group"), "ExampleGroup"),
equalTo(booleanKey("hystrix.circuit_open"), false)),
equalTo(HYSTRIX_COMMAND, experimental("TestCommand")),
equalTo(HYSTRIX_GROUP, experimental("ExampleGroup")),
equalTo(HYSTRIX_CIRCUIT_OPEN, experimental(false))),
span ->
span.hasName("tracedMethod")
.hasParent(trace.getSpan(1))
Expand All @@ -104,9 +106,9 @@ protected Observable<String> construct() {
span.hasName("OtherGroup.AnotherTestCommand.execute")
.hasParent(trace.getSpan(1))
.hasAttributesSatisfyingExactly(
equalTo(stringKey("hystrix.command"), "AnotherTestCommand"),
equalTo(stringKey("hystrix.group"), "OtherGroup"),
equalTo(booleanKey("hystrix.circuit_open"), false)),
equalTo(HYSTRIX_COMMAND, experimental("AnotherTestCommand")),
equalTo(HYSTRIX_GROUP, experimental("OtherGroup")),
equalTo(HYSTRIX_CIRCUIT_OPEN, experimental(false))),
span ->
span.hasName("anotherTracedMethod")
.hasParent(trace.getSpan(3))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@

package io.opentelemetry.javaagent.instrumentation.hystrix;

import static io.opentelemetry.api.common.AttributeKey.booleanKey;
import static io.opentelemetry.api.common.AttributeKey.stringKey;
import static io.opentelemetry.javaagent.instrumentation.hystrix.ExperimentalTestHelper.HYSTRIX_CIRCUIT_OPEN;
import static io.opentelemetry.javaagent.instrumentation.hystrix.ExperimentalTestHelper.HYSTRIX_COMMAND;
import static io.opentelemetry.javaagent.instrumentation.hystrix.ExperimentalTestHelper.HYSTRIX_GROUP;
import static io.opentelemetry.javaagent.instrumentation.hystrix.ExperimentalTestHelper.experimental;
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.catchException;
Expand Down Expand Up @@ -36,7 +38,7 @@
class HystrixObservableTest {

@RegisterExtension
protected static final InstrumentationExtension testing = AgentInstrumentationExtension.create();
static final InstrumentationExtension testing = AgentInstrumentationExtension.create();

@ParameterizedTest
@MethodSource("provideCommandActionArguments")
Expand Down Expand Up @@ -83,9 +85,9 @@ protected Observable<String> construct() {
span.hasName("ExampleGroup.TestCommand.execute")
.hasParent(trace.getSpan(0))
.hasAttributesSatisfyingExactly(
equalTo(stringKey("hystrix.command"), "TestCommand"),
equalTo(stringKey("hystrix.group"), "ExampleGroup"),
equalTo(booleanKey("hystrix.circuit_open"), false)),
equalTo(HYSTRIX_COMMAND, experimental("TestCommand")),
equalTo(HYSTRIX_GROUP, experimental("ExampleGroup")),
equalTo(HYSTRIX_CIRCUIT_OPEN, experimental(false))),
span ->
span.hasName("tracedMethod")
.hasParent(trace.getSpan(1))
Expand Down Expand Up @@ -292,9 +294,9 @@ protected Observable<String> resumeWithFallback() {
span.hasName("ExampleGroup.TestCommand.fallback")
.hasParent(trace.getSpan(1))
.hasAttributesSatisfyingExactly(
equalTo(stringKey("hystrix.command"), "TestCommand"),
equalTo(stringKey("hystrix.group"), "ExampleGroup"),
equalTo(booleanKey("hystrix.circuit_open"), false))));
equalTo(HYSTRIX_COMMAND, experimental("TestCommand")),
equalTo(HYSTRIX_GROUP, experimental("ExampleGroup")),
equalTo(HYSTRIX_CIRCUIT_OPEN, experimental(false)))));
}

private static Stream<Arguments> provideCommandFallbackArguments() {
Expand Down Expand Up @@ -383,17 +385,17 @@ protected Observable<String> construct() {
.hasStatus(StatusData.error())
.hasException(exception.getCause())
.hasAttributesSatisfyingExactly(
equalTo(stringKey("hystrix.command"), "TestCommand"),
equalTo(stringKey("hystrix.group"), "FailingGroup"),
equalTo(booleanKey("hystrix.circuit_open"), false)),
equalTo(HYSTRIX_COMMAND, experimental("TestCommand")),
equalTo(HYSTRIX_GROUP, experimental("FailingGroup")),
equalTo(HYSTRIX_CIRCUIT_OPEN, experimental(false))),
span ->
span.hasName("FailingGroup.TestCommand.fallback")
.hasParent(trace.getSpan(1))
.hasException(hystrixRuntimeException.getFallbackException())
.hasAttributesSatisfyingExactly(
equalTo(stringKey("hystrix.command"), "TestCommand"),
equalTo(stringKey("hystrix.group"), "FailingGroup"),
equalTo(booleanKey("hystrix.circuit_open"), false))));
equalTo(HYSTRIX_COMMAND, experimental("TestCommand")),
equalTo(HYSTRIX_GROUP, experimental("FailingGroup")),
equalTo(HYSTRIX_CIRCUIT_OPEN, experimental(false)))));
}

private static Stream<Arguments> provideCommandNoFallbackResultsInErrorArguments() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@

package io.opentelemetry.javaagent.instrumentation.hystrix;

import static io.opentelemetry.api.common.AttributeKey.booleanKey;
import static io.opentelemetry.api.common.AttributeKey.stringKey;
import static io.opentelemetry.javaagent.instrumentation.hystrix.ExperimentalTestHelper.HYSTRIX_CIRCUIT_OPEN;
import static io.opentelemetry.javaagent.instrumentation.hystrix.ExperimentalTestHelper.HYSTRIX_COMMAND;
import static io.opentelemetry.javaagent.instrumentation.hystrix.ExperimentalTestHelper.HYSTRIX_GROUP;
import static io.opentelemetry.javaagent.instrumentation.hystrix.ExperimentalTestHelper.experimental;
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Named.named;
Expand All @@ -31,7 +33,7 @@
class HystrixTest {

@RegisterExtension
protected static final InstrumentationExtension testing = AgentInstrumentationExtension.create();
static final InstrumentationExtension testing = AgentInstrumentationExtension.create();

@ParameterizedTest
@MethodSource("provideCommandActionArguments")
Expand All @@ -42,7 +44,7 @@ class TestCommand extends HystrixCommand<String> {
}

@Override
protected String run() throws Exception {
protected String run() {
return tracedMethod();
}

Expand All @@ -65,9 +67,9 @@ private String tracedMethod() {
span.hasName("ExampleGroup.TestCommand.execute")
.hasParent(trace.getSpan(0))
.hasAttributesSatisfyingExactly(
equalTo(stringKey("hystrix.command"), "TestCommand"),
equalTo(stringKey("hystrix.group"), "ExampleGroup"),
equalTo(booleanKey("hystrix.circuit_open"), false)),
equalTo(HYSTRIX_COMMAND, experimental("TestCommand")),
equalTo(HYSTRIX_GROUP, experimental("ExampleGroup")),
equalTo(HYSTRIX_CIRCUIT_OPEN, experimental(false))),
span ->
span.hasName("tracedMethod")
.hasParent(trace.getSpan(1))
Expand Down Expand Up @@ -108,16 +110,16 @@ protected String getFallback() {
.hasStatus(StatusData.error())
.hasException(new IllegalArgumentException())
.hasAttributesSatisfyingExactly(
equalTo(stringKey("hystrix.command"), "TestCommand"),
equalTo(stringKey("hystrix.group"), "ExampleGroup"),
equalTo(booleanKey("hystrix.circuit_open"), false)),
equalTo(HYSTRIX_COMMAND, experimental("TestCommand")),
equalTo(HYSTRIX_GROUP, experimental("ExampleGroup")),
equalTo(HYSTRIX_CIRCUIT_OPEN, experimental(false))),
span ->
span.hasName("ExampleGroup.TestCommand.fallback")
.hasParent(trace.getSpan(1))
.hasAttributesSatisfyingExactly(
equalTo(stringKey("hystrix.command"), "TestCommand"),
equalTo(stringKey("hystrix.group"), "ExampleGroup"),
equalTo(booleanKey("hystrix.circuit_open"), false))));
equalTo(HYSTRIX_COMMAND, experimental("TestCommand")),
equalTo(HYSTRIX_GROUP, experimental("ExampleGroup")),
equalTo(HYSTRIX_CIRCUIT_OPEN, experimental(false)))));
}

private static Stream<Arguments> provideCommandActionArguments() {
Expand Down
7 changes: 7 additions & 0 deletions instrumentation/hystrix-1.4/metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
description: This instrumentation enables the generation of INTERNAL spans for Hystrix command executions and fallbacks.
configurations:
- name: otel.instrumentation.hystrix.experimental-span-attributes
description: Enables capturing the experimental `hystrix.command`, `hystrix.circuit_open` and `hystrix.group` span attributes.
type: boolean
default: false