@Generated(value="by gapic-generator") @BetaApi public class TraceServiceClient extends Object implements BackgroundResource
This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:
try (TraceServiceClient traceServiceClient = TraceServiceClient.create()) {
String projectId = "";
Traces traces = Traces.newBuilder().build();
traceServiceClient.patchTraces(projectId, traces);
}
Note: close() needs to be called on the traceServiceClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().
The surface of this class includes several types of Java methods for each of the API's methods:
See the individual methods for example code.
Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.
This class can be customized by passing in a custom instance of TraceServiceSettings to create(). For example:
To customize credentials:
TraceServiceSettings traceServiceSettings =
TraceServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
TraceServiceClient traceServiceClient =
TraceServiceClient.create(traceServiceSettings);
To customize the endpoint:
TraceServiceSettings traceServiceSettings =
TraceServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
TraceServiceClient traceServiceClient =
TraceServiceClient.create(traceServiceSettings);
Modifier and Type | Class and Description |
---|---|
static class |
TraceServiceClient.ListTracesFixedSizeCollection |
static class |
TraceServiceClient.ListTracesPage |
static class |
TraceServiceClient.ListTracesPagedResponse |
Modifier | Constructor and Description |
---|---|
protected |
TraceServiceClient(TraceServiceSettings settings)
Constructs an instance of TraceServiceClient, using the given settings.
|
protected |
TraceServiceClient(TraceServiceStub stub) |
Modifier and Type | Method and Description |
---|---|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static TraceServiceClient |
create()
Constructs an instance of TraceServiceClient with default settings.
|
static TraceServiceClient |
create(TraceServiceSettings settings)
Constructs an instance of TraceServiceClient, using the given settings.
|
static TraceServiceClient |
create(TraceServiceStub stub)
Constructs an instance of TraceServiceClient, using the given stub for making calls.
|
TraceServiceSettings |
getSettings() |
TraceServiceStub |
getStub() |
com.google.devtools.cloudtrace.v1.Trace |
getTrace(com.google.devtools.cloudtrace.v1.GetTraceRequest request)
Gets a single trace by its ID.
|
com.google.devtools.cloudtrace.v1.Trace |
getTrace(String projectId,
String traceId)
Gets a single trace by its ID.
|
UnaryCallable<com.google.devtools.cloudtrace.v1.GetTraceRequest,com.google.devtools.cloudtrace.v1.Trace> |
getTraceCallable()
Gets a single trace by its ID.
|
boolean |
isShutdown() |
boolean |
isTerminated() |
TraceServiceClient.ListTracesPagedResponse |
listTraces(com.google.devtools.cloudtrace.v1.ListTracesRequest request)
Returns of a list of traces that match the specified filter conditions.
|
TraceServiceClient.ListTracesPagedResponse |
listTraces(String projectId)
Returns of a list of traces that match the specified filter conditions.
|
UnaryCallable<com.google.devtools.cloudtrace.v1.ListTracesRequest,com.google.devtools.cloudtrace.v1.ListTracesResponse> |
listTracesCallable()
Returns of a list of traces that match the specified filter conditions.
|
UnaryCallable<com.google.devtools.cloudtrace.v1.ListTracesRequest,TraceServiceClient.ListTracesPagedResponse> |
listTracesPagedCallable()
Returns of a list of traces that match the specified filter conditions.
|
void |
patchTraces(com.google.devtools.cloudtrace.v1.PatchTracesRequest request)
Sends new traces to Stackdriver Trace or updates existing traces.
|
void |
patchTraces(String projectId,
com.google.devtools.cloudtrace.v1.Traces traces)
Sends new traces to Stackdriver Trace or updates existing traces.
|
UnaryCallable<com.google.devtools.cloudtrace.v1.PatchTracesRequest,Empty> |
patchTracesCallable()
Sends new traces to Stackdriver Trace or updates existing traces.
|
void |
shutdown() |
void |
shutdownNow() |
protected TraceServiceClient(TraceServiceSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") protected TraceServiceClient(TraceServiceStub stub)
public static final TraceServiceClient create() throws IOException
IOException
public static final TraceServiceClient create(TraceServiceSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public static final TraceServiceClient create(TraceServiceStub stub)
public final TraceServiceSettings getSettings()
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public TraceServiceStub getStub()
public final void patchTraces(String projectId, com.google.devtools.cloudtrace.v1.Traces traces)
Sample code:
try (TraceServiceClient traceServiceClient = TraceServiceClient.create()) {
String projectId = "";
Traces traces = Traces.newBuilder().build();
traceServiceClient.patchTraces(projectId, traces);
}
projectId
- ID of the Cloud project where the trace data is stored.traces
- The body of the message.ApiException
- if the remote call failspublic final void patchTraces(com.google.devtools.cloudtrace.v1.PatchTracesRequest request)
Sample code:
try (TraceServiceClient traceServiceClient = TraceServiceClient.create()) {
String projectId = "";
Traces traces = Traces.newBuilder().build();
PatchTracesRequest request = PatchTracesRequest.newBuilder()
.setProjectId(projectId)
.setTraces(traces)
.build();
traceServiceClient.patchTraces(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.devtools.cloudtrace.v1.PatchTracesRequest,Empty> patchTracesCallable()
Sample code:
try (TraceServiceClient traceServiceClient = TraceServiceClient.create()) {
String projectId = "";
Traces traces = Traces.newBuilder().build();
PatchTracesRequest request = PatchTracesRequest.newBuilder()
.setProjectId(projectId)
.setTraces(traces)
.build();
ApiFuture<Void> future = traceServiceClient.patchTracesCallable().futureCall(request);
// Do something
future.get();
}
public final com.google.devtools.cloudtrace.v1.Trace getTrace(String projectId, String traceId)
Sample code:
try (TraceServiceClient traceServiceClient = TraceServiceClient.create()) {
String projectId = "";
String traceId = "";
Trace response = traceServiceClient.getTrace(projectId, traceId);
}
projectId
- ID of the Cloud project where the trace data is stored.traceId
- ID of the trace to return.ApiException
- if the remote call failspublic final com.google.devtools.cloudtrace.v1.Trace getTrace(com.google.devtools.cloudtrace.v1.GetTraceRequest request)
Sample code:
try (TraceServiceClient traceServiceClient = TraceServiceClient.create()) {
String projectId = "";
String traceId = "";
GetTraceRequest request = GetTraceRequest.newBuilder()
.setProjectId(projectId)
.setTraceId(traceId)
.build();
Trace response = traceServiceClient.getTrace(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.devtools.cloudtrace.v1.GetTraceRequest,com.google.devtools.cloudtrace.v1.Trace> getTraceCallable()
Sample code:
try (TraceServiceClient traceServiceClient = TraceServiceClient.create()) {
String projectId = "";
String traceId = "";
GetTraceRequest request = GetTraceRequest.newBuilder()
.setProjectId(projectId)
.setTraceId(traceId)
.build();
ApiFuture<Trace> future = traceServiceClient.getTraceCallable().futureCall(request);
// Do something
Trace response = future.get();
}
public final TraceServiceClient.ListTracesPagedResponse listTraces(String projectId)
Sample code:
try (TraceServiceClient traceServiceClient = TraceServiceClient.create()) {
String projectId = "";
for (Trace element : traceServiceClient.listTraces(projectId).iterateAll()) {
// doThingsWith(element);
}
}
projectId
- ID of the Cloud project where the trace data is stored.ApiException
- if the remote call failspublic final TraceServiceClient.ListTracesPagedResponse listTraces(com.google.devtools.cloudtrace.v1.ListTracesRequest request)
Sample code:
try (TraceServiceClient traceServiceClient = TraceServiceClient.create()) {
String projectId = "";
ListTracesRequest request = ListTracesRequest.newBuilder()
.setProjectId(projectId)
.build();
for (Trace element : traceServiceClient.listTraces(request).iterateAll()) {
// doThingsWith(element);
}
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.devtools.cloudtrace.v1.ListTracesRequest,TraceServiceClient.ListTracesPagedResponse> listTracesPagedCallable()
Sample code:
try (TraceServiceClient traceServiceClient = TraceServiceClient.create()) {
String projectId = "";
ListTracesRequest request = ListTracesRequest.newBuilder()
.setProjectId(projectId)
.build();
ApiFuture<ListTracesPagedResponse> future = traceServiceClient.listTracesPagedCallable().futureCall(request);
// Do something
for (Trace element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final UnaryCallable<com.google.devtools.cloudtrace.v1.ListTracesRequest,com.google.devtools.cloudtrace.v1.ListTracesResponse> listTracesCallable()
Sample code:
try (TraceServiceClient traceServiceClient = TraceServiceClient.create()) {
String projectId = "";
ListTracesRequest request = ListTracesRequest.newBuilder()
.setProjectId(projectId)
.build();
while (true) {
ListTracesResponse response = traceServiceClient.listTracesCallable().call(request);
for (Trace element : response.getTracesList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final void close()
close
in interface AutoCloseable
public void shutdown()
shutdown
in interface BackgroundResource
public boolean isShutdown()
isShutdown
in interface BackgroundResource
public boolean isTerminated()
isTerminated
in interface BackgroundResource
public void shutdownNow()
shutdownNow
in interface BackgroundResource
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException
awaitTermination
in interface BackgroundResource
InterruptedException
Copyright © 2019 Google LLC. All rights reserved.