package io.opentelemetry.example.autoconfigure;

import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.api.trace.Span;
import io.opentelemetry.api.trace.Tracer;
import io.opentelemetry.sdk.autoconfigure.OpenTelemetrySdkAutoConfiguration;

/**
 * An example of using {@link io.opentelemetry.sdk.autoconfigure.OpenTelemetrySdkAutoConfiguration}
 * and logging exporter: {@link io.opentelemetry.exporter.logging.LoggingSpanExporter}.
 */
public final class AutoConfigExample {
  private static final String INSTRUMENTATION_NAME = AutoConfigExample.class.getName();

  public static void main(String[] args) throws InterruptedException {
    // Turn off metrics for this example
    // TODO: this won't be needed after 1.1.0 release
    System.setProperty("otel.metrics.exporter", "none");

    // Let the SDK configure itself using environment variables and system properties
    OpenTelemetry openTelemetry = OpenTelemetrySdkAutoConfiguration.initialize();

    AutoConfigExample example = new AutoConfigExample(openTelemetry);
    // Do some real work that'll emit telemetry
    example.doWork();
  }

  private final Tracer tracer;

  public AutoConfigExample(OpenTelemetry openTelemetry) {
    this.tracer = openTelemetry.getTracer(INSTRUMENTATION_NAME);
  }

  public void doWork() throws InterruptedException {
    Span span =
        tracer
            .spanBuilder("important work")
            .setAttribute("foo", 42)
            .setAttribute("bar", "a string!")
            .startSpan();
    try {
      Thread.sleep(1000);
    } finally {
      span.end();
    }
  }
}

@@ -644,161 +644,8 @@
 n %7B%0A
-    // Turn off metrics for this example%0A    // TODO: this won't be needed after 1.1.0 release%0A    System.setProperty(%22otel.metrics.exporter%22, %22none%22);%0A%0A
     

remove a todo from an example (#3797)