// Path: exporters/stats/stackdriver/src/main/java/io/opencensus/exporter/stats/stackdriver/StackdriverStatsConfiguration.java
// static final Duration DEFAULT_DEADLINE = Duration.create(60, 0);
// 
// Path: exporters/stats/stackdriver/src/main/java/io/opencensus/exporter/stats/stackdriver/StackdriverStatsConfiguration.java
// static final String DEFAULT_PROJECT_ID =
//     Strings.nullToEmpty(ServiceOptions.getDefaultProjectId());
// 
// Path: exporters/stats/stackdriver/src/main/java/io/opencensus/exporter/stats/stackdriver/StackdriverStatsConfiguration.java
// static final MonitoredResource DEFAULT_RESOURCE = StackdriverExportUtils.getDefaultResource();
// 
// Path: api/src/main/java/io/opencensus/common/OpenCensusLibraryInformation.java
// @ExperimentalApi
// public final class OpenCensusLibraryInformation {
// 
//   /**
//    * The current version of the OpenCensus Java library.
//    *
//    * @since 0.8
//    */
//   public static final String VERSION = "0.32.0-SNAPSHOT"; // CURRENT_OPENCENSUS_VERSION
// 
//   private OpenCensusLibraryInformation() {}
// }


import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
import static io.opencensus.exporter.stats.stackdriver.StackdriverExportUtils.DEFAULT_CONSTANT_LABELS;
import static io.opencensus.exporter.stats.stackdriver.StackdriverStatsConfiguration.DEFAULT_DEADLINE;
import static io.opencensus.exporter.stats.stackdriver.StackdriverStatsConfiguration.DEFAULT_PROJECT_ID;
import static io.opencensus.exporter.stats.stackdriver.StackdriverStatsConfiguration.DEFAULT_RESOURCE;
import com.google.api.MonitoredResource;
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
import com.google.api.gax.rpc.FixedHeaderProvider;
import com.google.api.gax.rpc.HeaderProvider;
import com.google.auth.Credentials;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.cloud.ServiceOptions;
import com.google.cloud.monitoring.v3.MetricServiceClient;
import com.google.cloud.monitoring.v3.MetricServiceSettings;
import com.google.cloud.monitoring.v3.stub.MetricServiceStub;
import com.google.common.annotations.VisibleForTesting;
import io.opencensus.common.Duration;
import io.opencensus.common.OpenCensusLibraryInformation;
import io.opencensus.exporter.metrics.util.IntervalMetricReader;
import io.opencensus.exporter.metrics.util.MetricReader;
import io.opencensus.metrics.LabelKey;
import io.opencensus.metrics.LabelValue;
import io.opencensus.metrics.Metrics;
import java.io.IOException;
import java.util.Map;
import javax.annotation.Nullable;
import javax.annotation.concurrent.GuardedBy;
import javax.annotation.concurrent.ThreadSafe;
      Duration exportInterval, MonitoredResource monitoredResource) throws IOException {
    checkNotNull(exportInterval, "exportInterval");
    checkNotNull(monitoredResource, "monitoredResource");
    checkArgument(
        !DEFAULT_PROJECT_ID.isEmpty(), "Cannot find a project ID from application default.");
    createInternal(
        null,
        DEFAULT_PROJECT_ID,
        exportInterval,
        monitoredResource,
        null,
        null,
        DEFAULT_CONSTANT_LABELS,
        DEFAULT_DEADLINE,
        null);
  }

  // Use createInternal() (instead of constructor) to enforce singleton.
  private static void createInternal(
      @Nullable Credentials credentials,
      String projectId,
      Duration exportInterval,
      MonitoredResource monitoredResource,
      @Nullable String metricNamePrefix,
      @Nullable String displayNamePrefix,
      Map<LabelKey, LabelValue> constantLabels,
      Duration deadline,
      @Nullable MetricServiceStub stub)
      throws IOException {
    synchronized (monitor) {
// Path: exporters/stats/stackdriver/src/main/java/io/opencensus/exporter/stats/stackdriver/StackdriverStatsConfiguration.java
// static final Duration DEFAULT_DEADLINE = Duration.create(60, 0);
// 
// Path: exporters/stats/stackdriver/src/main/java/io/opencensus/exporter/stats/stackdriver/StackdriverStatsConfiguration.java
// static final String DEFAULT_PROJECT_ID =
//     Strings.nullToEmpty(ServiceOptions.getDefaultProjectId());
// 
// Path: exporters/stats/stackdriver/src/main/java/io/opencensus/exporter/stats/stackdriver/StackdriverStatsConfiguration.java
// static final MonitoredResource DEFAULT_RESOURCE = StackdriverExportUtils.getDefaultResource();
// 
// Path: api/src/main/java/io/opencensus/common/OpenCensusLibraryInformation.java
// @ExperimentalApi
// public final class OpenCensusLibraryInformation {
// 
//   /**
//    * The current version of the OpenCensus Java library.
//    *
//    * @since 0.8
//    */
//   public static final String VERSION = "0.32.0-SNAPSHOT"; // CURRENT_OPENCENSUS_VERSION
// 
//   private OpenCensusLibraryInformation() {}
// }


// Path: exporters/stats/stackdriver/src/main/java/io/opencensus/exporter/stats/stackdriver/StackdriverStatsExporter.java
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
import static io.opencensus.exporter.stats.stackdriver.StackdriverExportUtils.DEFAULT_CONSTANT_LABELS;
import static io.opencensus.exporter.stats.stackdriver.StackdriverStatsConfiguration.DEFAULT_DEADLINE;
import static io.opencensus.exporter.stats.stackdriver.StackdriverStatsConfiguration.DEFAULT_PROJECT_ID;
import static io.opencensus.exporter.stats.stackdriver.StackdriverStatsConfiguration.DEFAULT_RESOURCE;
import com.google.api.MonitoredResource;
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
import com.google.api.gax.rpc.FixedHeaderProvider;
import com.google.api.gax.rpc.HeaderProvider;
import com.google.auth.Credentials;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.cloud.ServiceOptions;
import com.google.cloud.monitoring.v3.MetricServiceClient;
import com.google.cloud.monitoring.v3.MetricServiceSettings;
import com.google.cloud.monitoring.v3.stub.MetricServiceStub;
import com.google.common.annotations.VisibleForTesting;
import io.opencensus.common.Duration;
import io.opencensus.common.OpenCensusLibraryInformation;
import io.opencensus.exporter.metrics.util.IntervalMetricReader;
import io.opencensus.exporter.metrics.util.MetricReader;
import io.opencensus.metrics.LabelKey;
import io.opencensus.metrics.LabelValue;
import io.opencensus.metrics.Metrics;
import java.io.IOException;
import java.util.Map;
import javax.annotation.Nullable;
import javax.annotation.concurrent.GuardedBy;
import javax.annotation.concurrent.ThreadSafe;

      Duration exportInterval, MonitoredResource monitoredResource) throws IOException {
    checkNotNull(exportInterval, "exportInterval");
    checkNotNull(monitoredResource, "monitoredResource");
    checkArgument(
        !DEFAULT_PROJECT_ID.isEmpty(), "Cannot find a project ID from application default.");
    createInternal(
        null,
        DEFAULT_PROJECT_ID,
        exportInterval,
        monitoredResource,
        null,
        null,
        DEFAULT_CONSTANT_LABELS,
        DEFAULT_DEADLINE,
        null);
  }

  // Use createInternal() (instead of constructor) to enforce singleton.
  private static void createInternal(
      @Nullable Credentials credentials,
      String projectId,
      Duration exportInterval,
      MonitoredResource monitoredResource,
      @Nullable String metricNamePrefix,
      @Nullable String displayNamePrefix,
      Map<LabelKey, LabelValue> constantLabels,
      Duration deadline,
      @Nullable MetricServiceStub stub)
      throws IOException {
    synchronized (monitor) {
      checkState(instance == null, "Stackdriver stats exporter is already created.");