@Test public void updateAll() { StackdriverTraceConfiguration configuration = StackdriverTraceConfiguration.builder() .setCredentials(FAKE_CREDENTIALS) .setProjectId(PROJECT_ID) .build(); assertThat(configuration.getCredentials()).isEqualTo(FAKE_CREDENTIALS); assertThat(configuration.getProjectId()).isEqualTo(PROJECT_ID); } }
/** * Creates and registers the Stackdriver Trace exporter to the OpenCensus library for an explicit * project ID. Only one Stackdriver exporter can be registered at any point. * * <p>This uses the default application credentials see {@link * GoogleCredentials#getApplicationDefault}. * * <p>This is equivalent with: * * <pre>{@code * StackdriverExporter.createAndRegisterWithCredentialsAndProjectId( * GoogleCredentials.getApplicationDefault(), projectId); * }</pre> * * @param projectId the cloud project id. * @throws IllegalStateException if a Stackdriver exporter is already registered. * @since 0.6 */ public static void createAndRegisterWithProjectId(String projectId) throws IOException { StackdriverTraceExporter.createAndRegister( StackdriverTraceConfiguration.builder() .setCredentials(GoogleCredentials.getApplicationDefault()) .setProjectId(projectId) .build()); }
/** * Creates and registers the Stackdriver Trace exporter to the OpenCensus library for an explicit * project ID. Only one Stackdriver exporter can be registered at any point. * * <p>This uses the default application credentials see {@link * GoogleCredentials#getApplicationDefault}. * * <p>This is equivalent with: * * <pre>{@code * StackdriverExporter.createAndRegisterWithCredentialsAndProjectId( * GoogleCredentials.getApplicationDefault(), projectId); * }</pre> * * @param projectId the cloud project id. * @throws IllegalStateException if a Stackdriver exporter is already registered. * @since 0.6 */ public static void createAndRegisterWithProjectId(String projectId) throws IOException { StackdriverTraceExporter.createAndRegister( StackdriverTraceConfiguration.builder() .setCredentials(GoogleCredentials.getApplicationDefault()) .setProjectId(projectId) .build()); }
/** * Creates and registers the Stackdriver Trace exporter to the OpenCensus library. Only one * Stackdriver exporter can be registered at any point. * * <p>This uses the default application credentials see {@link * GoogleCredentials#getApplicationDefault}. * * <p>This uses the default project ID configured see {@link ServiceOptions#getDefaultProjectId}. * * <p>This is equivalent with: * * <pre>{@code * StackdriverExporter.createAndRegisterWithProjectId(ServiceOptions.getDefaultProjectId()); * }</pre> * * @throws IllegalStateException if a Stackdriver exporter is already registered. * @since 0.6 */ public static void createAndRegister() throws IOException { StackdriverTraceExporter.createAndRegister( StackdriverTraceConfiguration.builder() .setCredentials(GoogleCredentials.getApplicationDefault()) // TODO(sebright): Handle null default project ID. .setProjectId(castNonNull(ServiceOptions.getDefaultProjectId())) .build()); }
/** * Creates and registers the Stackdriver Trace exporter to the OpenCensus library. Only one * Stackdriver exporter can be registered at any point. * * <p>This uses the default application credentials see {@link * GoogleCredentials#getApplicationDefault}. * * <p>This uses the default project ID configured see {@link ServiceOptions#getDefaultProjectId}. * * <p>This is equivalent with: * * <pre>{@code * StackdriverExporter.createAndRegisterWithProjectId(ServiceOptions.getDefaultProjectId()); * }</pre> * * @throws IllegalStateException if a Stackdriver exporter is already registered. * @since 0.6 */ public static void createAndRegister() throws IOException { StackdriverTraceExporter.createAndRegister( StackdriverTraceConfiguration.builder() .setCredentials(GoogleCredentials.getApplicationDefault()) // TODO(sebright): Handle null default project ID. .setProjectId(castNonNull(ServiceOptions.getDefaultProjectId())) .build()); }
/** * Creates and registers the Stackdriver Trace exporter to the OpenCensus library for an explicit * project ID and using explicit credentials. Only one Stackdriver exporter can be registered at * any point. * * @param credentials a credentials used to authenticate API calls. * @param projectId the cloud project id. * @throws IllegalStateException if a Stackdriver exporter is already registered. * @since 0.6 */ public static void createAndRegisterWithCredentialsAndProjectId( Credentials credentials, String projectId) throws IOException { StackdriverTraceExporter.createAndRegister( StackdriverTraceConfiguration.builder() .setCredentials(credentials) .setProjectId(projectId) .build()); }
/** * Creates and registers the Stackdriver Trace exporter to the OpenCensus library for an explicit * project ID and using explicit credentials. Only one Stackdriver exporter can be registered at * any point. * * @param credentials a credentials used to authenticate API calls. * @param projectId the cloud project id. * @throws IllegalStateException if a Stackdriver exporter is already registered. * @since 0.6 */ public static void createAndRegisterWithCredentialsAndProjectId( Credentials credentials, String projectId) throws IOException { StackdriverTraceExporter.createAndRegister( StackdriverTraceConfiguration.builder() .setCredentials(credentials) .setProjectId(projectId) .build()); }