Search in sources :

Example 6 with SinkInfo

use of com.google.cloud.logging.SinkInfo in project google-cloud-java by GoogleCloudPlatform.

the class LoggingSnippets method createSinkAsync.

/**
   * Example of asynchronously creating a sink to export logs to a BigQuery dataset (in the
   * {@link LoggingOptions#getProjectId()} project).
   */
// [TARGET createAsync(SinkInfo)]
// [VARIABLE "my_sink_name"]
// [VARIABLE "my_dataset"]
public Sink createSinkAsync(String sinkName, String datasetName) throws ExecutionException, InterruptedException {
    // [START createSinkAsync]
    SinkInfo sinkInfo = SinkInfo.of(sinkName, DatasetDestination.of(datasetName));
    Future<Sink> future = logging.createAsync(sinkInfo);
    // ...
    Sink sink = future.get();
    // [END createSinkAsync]
    return sink;
}
Also used : Sink(com.google.cloud.logging.Sink) SinkInfo(com.google.cloud.logging.SinkInfo)

Aggregations

SinkInfo (com.google.cloud.logging.SinkInfo)6 Sink (com.google.cloud.logging.Sink)5 Logging (com.google.cloud.logging.Logging)1 RemoteLoggingHelper (com.google.cloud.logging.testing.RemoteLoggingHelper)1 BeforeClass (org.junit.BeforeClass)1