content: /*
   * Copyright The OpenTelemetry Authors
   * SPDX-License-Identifier: Apache-2.0
   */
  
  package io.opentelemetry.javaagent.tooling;
  
  import io.opentelemetry.context.Context;
  import io.opentelemetry.sdk.common.CompletableResultCode;
  import io.opentelemetry.sdk.trace.ReadWriteSpan;
  import io.opentelemetry.sdk.trace.ReadableSpan;
  import io.opentelemetry.sdk.trace.SpanProcessor;
  import io.opentelemetry.semconv.incubating.ThreadIncubatingAttributes;
  
  public class AddThreadDetailsSpanProcessor implements SpanProcessor {
  
    @Override
    public void onStart(Context context, ReadWriteSpan span) {
      Thread currentThread = Thread.currentThread();
      span.setAttribute(ThreadIncubatingAttributes.THREAD_ID, currentThread.getId());
      span.setAttribute(ThreadIncubatingAttributes.THREAD_NAME, currentThread.getName());
    }
  
    @Override
    public boolean isStartRequired() {
      return true;
    }
  
    @Override
    public void onEnd(ReadableSpan span) {}
  
    @Override
    public boolean isEndRequired() {
      return false;
    }
  
    @Override
    public CompletableResultCode shutdown() {
      return CompletableResultCode.ofSuccess();
    }
  
    @Override
    public CompletableResultCode forceFlush() {
      return CompletableResultCode.ofSuccess();
    }
  }
  