All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.opentelemetry.javaagent.instrumentation.hystrix.ExperimentalAttributesExtractor Maven / Gradle / Ivy

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) {}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy