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

io.opentelemetry.contrib.interceptor.InterceptableSpanExporter Maven / Gradle / Ivy

/*
 * Copyright The OpenTelemetry Authors
 * SPDX-License-Identifier: Apache-2.0
 */

package io.opentelemetry.contrib.interceptor;

import io.opentelemetry.contrib.interceptor.api.Interceptor;
import io.opentelemetry.sdk.common.CompletableResultCode;
import io.opentelemetry.sdk.trace.data.SpanData;
import io.opentelemetry.sdk.trace.export.SpanExporter;
import java.util.Collection;

/** Intercepts spans before delegating them to the real exporter. */
public final class InterceptableSpanExporter implements SpanExporter {
  private final SpanExporter delegate;
  private final Interceptor interceptor;

  public InterceptableSpanExporter(SpanExporter delegate, Interceptor interceptor) {
    this.delegate = delegate;
    this.interceptor = interceptor;
  }

  @Override
  public CompletableResultCode export(Collection spans) {
    return delegate.export(interceptor.interceptAll(spans));
  }

  @Override
  public CompletableResultCode flush() {
    return delegate.flush();
  }

  @Override
  public CompletableResultCode shutdown() {
    return delegate.shutdown();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy