// Path: exporters/trace/src/main/java/com/google/cloud/opentelemetry/trace/TraceExporter.java
// public class TraceExporter implements SpanExporter {
// 
//   private final CloudTraceClient cloudTraceClient;
//   private final ProjectName projectName;
//   private final String projectId;
//   private final Map<String, AttributeValue> fixedAttributes;
// 
//   public static TraceExporter createWithDefaultConfiguration() throws IOException {
//     TraceConfiguration configuration = TraceConfiguration.builder().build();
//     return TraceExporter.createWithConfiguration(configuration);
//   }
// 
//   public static TraceExporter createWithConfiguration(TraceConfiguration configuration)
//       throws IOException {
//     String projectId = configuration.getProjectId();
//     TraceServiceStub stub = configuration.getTraceServiceStub();
// 
//     if (stub == null) {
//       Credentials credentials =
//           configuration.getCredentials() == null
//               ? GoogleCredentials.getApplicationDefault()
//               : configuration.getCredentials();
// 
//       return TraceExporter.createWithCredentials(
//           projectId, credentials, configuration.getFixedAttributes(), configuration.getDeadline());
//     }
//     return TraceExporter.createWithClient(
//         projectId,
//         new CloudTraceClientImpl(TraceServiceClient.create(stub)),
//         configuration.getFixedAttributes());
//   }
// 
//   private static TraceExporter createWithClient(
//       String projectId,
//       CloudTraceClient cloudTraceClient,
//       Map<String, AttributeValue> fixedAttributes) {
//     return new TraceExporter(projectId, cloudTraceClient, fixedAttributes);
//   }
// 
//   private static TraceExporter createWithCredentials(
//       String projectId,
//       Credentials credentials,
//       Map<String, AttributeValue> fixedAttributes,
//       Duration deadline)
//       throws IOException {
//     TraceServiceSettings.Builder builder =
//         TraceServiceSettings.newBuilder()
//             .setCredentialsProvider(
//                 FixedCredentialsProvider.create(checkNotNull(credentials, "credentials")));
//     // We only use the batchWriteSpans API in this exporter.
//     builder
//         .batchWriteSpansSettings()
//         .setSimpleTimeoutNoRetries(org.threeten.bp.Duration.ofMillis(deadline.toMillis()));
//     return new TraceExporter(
//         projectId,
//         new CloudTraceClientImpl(TraceServiceClient.create(builder.build())),
//         fixedAttributes);
//   }
// 
//   TraceExporter(
//       String projectId,
//       CloudTraceClient cloudTraceClient,
//       Map<String, AttributeValue> fixedAttributes) {
//     this.projectId = projectId;
//     this.cloudTraceClient = cloudTraceClient;
//     this.projectName = ProjectName.of(projectId);
//     this.fixedAttributes = fixedAttributes;
//   }
// 
//   // TODO @imnoahcook add support for flush
//   @Override
//   public CompletableResultCode flush() {
//     return CompletableResultCode.ofFailure();
//   }
// 
//   @Override
//   public CompletableResultCode export(Collection<SpanData> spanDataList) {
//     List<Span> spans = new ArrayList<>(spanDataList.size());
//     for (SpanData spanData : spanDataList) {
//       spans.add(TraceTranslator.generateSpan(spanData, projectId, fixedAttributes));
//     }
// 
//     cloudTraceClient.batchWriteSpans(projectName, spans);
//     return CompletableResultCode.ofSuccess();
//   }
// 
//   @Override
//   public CompletableResultCode shutdown() {
//     this.cloudTraceClient.shutdown();
//     return CompletableResultCode.ofSuccess();
//   }
// }


import com.google.auto.service.AutoService;
import com.google.cloud.opentelemetry.trace.TraceExporter;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
import io.opentelemetry.sdk.autoconfigure.spi.traces.ConfigurableSpanExporterProvider;
import io.opentelemetry.sdk.trace.export.SpanExporter;
import java.io.IOException;
/*
 * Copyright 2022 Google
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.google.cloud.opentelemetry.auto;


@AutoService(ConfigurableSpanExporterProvider.class)
public class GoogleCloudSpanExporterFactory implements ConfigurableSpanExporterProvider {

  @Override
  public SpanExporter createExporter(ConfigProperties config) {
    try {
// Path: exporters/trace/src/main/java/com/google/cloud/opentelemetry/trace/TraceExporter.java
// public class TraceExporter implements SpanExporter {
// 
//   private final CloudTraceClient cloudTraceClient;
//   private final ProjectName projectName;
//   private final String projectId;
//   private final Map<String, AttributeValue> fixedAttributes;
// 
//   public static TraceExporter createWithDefaultConfiguration() throws IOException {
//     TraceConfiguration configuration = TraceConfiguration.builder().build();
//     return TraceExporter.createWithConfiguration(configuration);
//   }
// 
//   public static TraceExporter createWithConfiguration(TraceConfiguration configuration)
//       throws IOException {
//     String projectId = configuration.getProjectId();
//     TraceServiceStub stub = configuration.getTraceServiceStub();
// 
//     if (stub == null) {
//       Credentials credentials =
//           configuration.getCredentials() == null
//               ? GoogleCredentials.getApplicationDefault()
//               : configuration.getCredentials();
// 
//       return TraceExporter.createWithCredentials(
//           projectId, credentials, configuration.getFixedAttributes(), configuration.getDeadline());
//     }
//     return TraceExporter.createWithClient(
//         projectId,
//         new CloudTraceClientImpl(TraceServiceClient.create(stub)),
//         configuration.getFixedAttributes());
//   }
// 
//   private static TraceExporter createWithClient(
//       String projectId,
//       CloudTraceClient cloudTraceClient,
//       Map<String, AttributeValue> fixedAttributes) {
//     return new TraceExporter(projectId, cloudTraceClient, fixedAttributes);
//   }
// 
//   private static TraceExporter createWithCredentials(
//       String projectId,
//       Credentials credentials,
//       Map<String, AttributeValue> fixedAttributes,
//       Duration deadline)
//       throws IOException {
//     TraceServiceSettings.Builder builder =
//         TraceServiceSettings.newBuilder()
//             .setCredentialsProvider(
//                 FixedCredentialsProvider.create(checkNotNull(credentials, "credentials")));
//     // We only use the batchWriteSpans API in this exporter.
//     builder
//         .batchWriteSpansSettings()
//         .setSimpleTimeoutNoRetries(org.threeten.bp.Duration.ofMillis(deadline.toMillis()));
//     return new TraceExporter(
//         projectId,
//         new CloudTraceClientImpl(TraceServiceClient.create(builder.build())),
//         fixedAttributes);
//   }
// 
//   TraceExporter(
//       String projectId,
//       CloudTraceClient cloudTraceClient,
//       Map<String, AttributeValue> fixedAttributes) {
//     this.projectId = projectId;
//     this.cloudTraceClient = cloudTraceClient;
//     this.projectName = ProjectName.of(projectId);
//     this.fixedAttributes = fixedAttributes;
//   }
// 
//   // TODO @imnoahcook add support for flush
//   @Override
//   public CompletableResultCode flush() {
//     return CompletableResultCode.ofFailure();
//   }
// 
//   @Override
//   public CompletableResultCode export(Collection<SpanData> spanDataList) {
//     List<Span> spans = new ArrayList<>(spanDataList.size());
//     for (SpanData spanData : spanDataList) {
//       spans.add(TraceTranslator.generateSpan(spanData, projectId, fixedAttributes));
//     }
// 
//     cloudTraceClient.batchWriteSpans(projectName, spans);
//     return CompletableResultCode.ofSuccess();
//   }
// 
//   @Override
//   public CompletableResultCode shutdown() {
//     this.cloudTraceClient.shutdown();
//     return CompletableResultCode.ofSuccess();
//   }
// }


// Path: exporters/auto/src/main/java/com/google/cloud/opentelemetry/auto/GoogleCloudSpanExporterFactory.java
import com.google.auto.service.AutoService;
import com.google.cloud.opentelemetry.trace.TraceExporter;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
import io.opentelemetry.sdk.autoconfigure.spi.traces.ConfigurableSpanExporterProvider;
import io.opentelemetry.sdk.trace.export.SpanExporter;
import java.io.IOException;

/*
 * Copyright 2022 Google
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.google.cloud.opentelemetry.auto;


@AutoService(ConfigurableSpanExporterProvider.class)
public class GoogleCloudSpanExporterFactory implements ConfigurableSpanExporterProvider {

  @Override
  public SpanExporter createExporter(ConfigProperties config) {
    try {
      return TraceExporter.createWithDefaultConfiguration();