public final class StackdriverStatsExporter extends Object
Example of usage on Google Cloud VMs:
public static void main(String[] args) {
StackdriverStatsExporter.createAndRegister(
StackdriverStatsConfiguration
.builder()
.setProjectId("MyStackdriverProjectId")
.setExportInterval(Duration.fromMillis(100000))
.build());
... // Do work.
}
Modifier and Type | Method and Description |
---|---|
static void |
createAndRegister()
Creates a Stackdriver Stats exporter with default settings.
|
static void |
createAndRegister(io.opencensus.common.Duration exportInterval)
Deprecated.
in favor of
createAndRegister(StackdriverStatsConfiguration) . |
static void |
createAndRegister(StackdriverStatsConfiguration configuration)
Creates a Stackdriver Stats exporter with a
StackdriverStatsConfiguration . |
static void |
createAndRegisterWithCredentialsAndProjectId(com.google.auth.Credentials credentials,
String projectId,
io.opencensus.common.Duration exportInterval)
Deprecated.
in favor of
createAndRegister(StackdriverStatsConfiguration) . |
static void |
createAndRegisterWithMonitoredResource(io.opencensus.common.Duration exportInterval,
com.google.api.MonitoredResource monitoredResource)
Deprecated.
in favor of
createAndRegister(StackdriverStatsConfiguration) . |
static void |
createAndRegisterWithProjectId(String projectId,
io.opencensus.common.Duration exportInterval)
Deprecated.
in favor of
createAndRegister(StackdriverStatsConfiguration) . |
static void |
createAndRegisterWithProjectIdAndMonitoredResource(String projectId,
io.opencensus.common.Duration exportInterval,
com.google.api.MonitoredResource monitoredResource)
Deprecated.
in favor of
createAndRegister(StackdriverStatsConfiguration) . |
@Deprecated public static void createAndRegisterWithCredentialsAndProjectId(com.google.auth.Credentials credentials, String projectId, io.opencensus.common.Duration exportInterval) throws IOException
createAndRegister(StackdriverStatsConfiguration)
.Only one Stackdriver exporter can be created.
credentials
- a credentials used to authenticate API calls.projectId
- the cloud project id.exportInterval
- the interval between pushing stats to StackDriver.IllegalStateException
- if a Stackdriver exporter already exists.IOException
@Deprecated public static void createAndRegisterWithProjectId(String projectId, io.opencensus.common.Duration exportInterval) throws IOException
createAndRegister(StackdriverStatsConfiguration)
.Only one Stackdriver exporter can be created.
This uses the default application credentials. See GoogleCredentials.getApplicationDefault()
.
This is equivalent with:
StackdriverStatsExporter.createWithCredentialsAndProjectId(
GoogleCredentials.getApplicationDefault(), projectId);
projectId
- the cloud project id.exportInterval
- the interval between pushing stats to StackDriver.IllegalStateException
- if a Stackdriver exporter is already created.IOException
public static void createAndRegister(StackdriverStatsConfiguration configuration) throws IOException
StackdriverStatsConfiguration
.
Only one Stackdriver exporter can be created.
If credentials
of the configuration is not set, the exporter will use the default
application credentials. See GoogleCredentials.getApplicationDefault()
.
If projectId
of the configuration is not set, the exporter will use the default
project ID configured. See ServiceOptions.getDefaultProjectId()
.
If exportInterval
of the configuration is not set, the exporter will use the default
interval of one minute.
If monitoredResources
of the configuration is not set, the exporter will try to
create an appropriate monitoredResources
based on the environment variables. In
addition, please refer to
cloud.google.com/monitoring/custom-metrics/creating-metrics#which-resource for a list of valid
MonitoredResource
s.
If metricNamePrefix
of the configuration is not set, the exporter will use the
default prefix "OpenCensus".
configuration
- the StackdriverStatsConfiguration
.IllegalStateException
- if a Stackdriver exporter is already created.IOException
public static void createAndRegister() throws IOException
Only one Stackdriver exporter can be created.
This is equivalent with:
StackdriverStatsExporter.createAndRegister(StackdriverStatsConfiguration.builder().build());
This method uses the default application credentials. See GoogleCredentials.getApplicationDefault()
.
This method uses the default project ID configured. See ServiceOptions.getDefaultProjectId()
.
This method uses the default interval of one minute.
This method uses the default resource created from the environment variables.
This method uses the default display name prefix "OpenCensus".
IllegalStateException
- if a Stackdriver exporter is already created.IOException
@Deprecated public static void createAndRegister(io.opencensus.common.Duration exportInterval) throws IOException
createAndRegister(StackdriverStatsConfiguration)
.Only one Stackdriver exporter can be created.
This uses the default application credentials. See GoogleCredentials.getApplicationDefault()
.
This uses the default project ID configured see ServiceOptions.getDefaultProjectId()
.
This is equivalent with:
StackdriverStatsExporter.createWithProjectId(ServiceOptions.getDefaultProjectId());
exportInterval
- the interval between pushing stats to StackDriver.IllegalStateException
- if a Stackdriver exporter is already created.IOException
@Deprecated public static void createAndRegisterWithProjectIdAndMonitoredResource(String projectId, io.opencensus.common.Duration exportInterval, com.google.api.MonitoredResource monitoredResource) throws IOException
createAndRegister(StackdriverStatsConfiguration)
.Only one Stackdriver exporter can be created.
Please refer to cloud.google.com/monitoring/custom-metrics/creating-metrics#which-resource
for a list of valid MonitoredResource
s.
This uses the default application credentials. See GoogleCredentials.getApplicationDefault()
.
projectId
- the cloud project id.exportInterval
- the interval between pushing stats to StackDriver.monitoredResource
- the Monitored Resource used by exporter.IllegalStateException
- if a Stackdriver exporter is already created.IOException
@Deprecated public static void createAndRegisterWithMonitoredResource(io.opencensus.common.Duration exportInterval, com.google.api.MonitoredResource monitoredResource) throws IOException
createAndRegister(StackdriverStatsConfiguration)
.Only one Stackdriver exporter can be created.
Please refer to cloud.google.com/monitoring/custom-metrics/creating-metrics#which-resource
for a list of valid MonitoredResource
s.
This uses the default application credentials. See GoogleCredentials.getApplicationDefault()
.
This uses the default project ID configured see ServiceOptions.getDefaultProjectId()
.
exportInterval
- the interval between pushing stats to StackDriver.monitoredResource
- the Monitored Resource used by exporter.IllegalStateException
- if a Stackdriver exporter is already created.IOException