io.opentelemetry.javaagent.instrumentation.hystrix.ExperimentalAttributesExtractor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of opentelemetry-javaagent-hystrix-1.4 Show documentation
Show all versions of opentelemetry-javaagent-hystrix-1.4 Show documentation
Instrumentation of Java libraries using OpenTelemetry.
The newest version!
/*
* 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 io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import javax.annotation.Nullable;
final class ExperimentalAttributesExtractor implements AttributesExtractor {
private static final AttributeKey HYSTRIX_COMMAND = stringKey("hystrix.command");
private static final AttributeKey HYSTRIX_GROUP = stringKey("hystrix.group");
private static final AttributeKey HYSTRIX_CIRCUIT_OPEN =
booleanKey("hystrix.circuit_open");
@Override
public void onStart(
AttributesBuilder attributes, Context parentContext, HystrixRequest hystrixRequest) {
String commandName = hystrixRequest.command().getCommandKey().name();
String groupName = hystrixRequest.command().getCommandGroup().name();
boolean circuitOpen = hystrixRequest.command().isCircuitBreakerOpen();
attributes.put(HYSTRIX_COMMAND, commandName);
attributes.put(HYSTRIX_GROUP, groupName);
attributes.put(HYSTRIX_CIRCUIT_OPEN, circuitOpen);
}
@Override
public void onEnd(
AttributesBuilder attributes,
Context context,
HystrixRequest hystrixRequest,
@Nullable Void unused,
@Nullable Throwable error) {}
}