Skip to content

Commit 6096d1b

Browse files
---
yaml --- r: 8855 b: refs/heads/lesv-patch-1 c: f1b114f h: refs/heads/master i: 8853: d718690 8851: c364b60 8847: d351754
1 parent 38a2941 commit 6096d1b

11 files changed

Lines changed: 1136 additions & 2 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ refs/tags/v0.22.0: 18b298fe4bfe8ec2f20b0e0bf7ffdcce5cc3c5fe
6666
refs/heads/vam-google-patch-1: d0c8fee3a4074d0bf7360ce8c4f7f7223d0ee7b9
6767
refs/heads/vam-google-patch-CODEOWNERS: 2ac1616e25229e51d08a984708ef1918f91a35ee
6868
refs/heads/danoscarmike-patch-1: 7342a9916bce4ed00002c7202e2a16c5d46afaea
69-
refs/heads/lesv-patch-1: 876d1fb7c206e6304f424f9c889a50b934a30869
69+
refs/heads/lesv-patch-1: f1b114f8a279f34100f20e47fbed6b5a1005f16b
7070
refs/heads/ml-update-branch: 079dd6610017f5c51b9d1938c12d6d55b61513cf
7171
refs/heads/vkedia-patch-2: 7d8241388a9769a5c069334761b06c7012c878e7
7272
refs/heads/vkedia-patch-3: 4d128043acaa7db9160faf439d2ca6104e8a88cb

branches/lesv-patch-1/google-cloud-trace/pom.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@
3535
<groupId>com.google.api.grpc</groupId>
3636
<artifactId>proto-google-cloud-trace-v1</artifactId>
3737
</dependency>
38+
<dependency>
39+
<groupId>com.google.api.grpc</groupId>
40+
<artifactId>proto-google-cloud-trace-v2</artifactId>
41+
</dependency>
3842
<dependency>
3943
<groupId>io.grpc</groupId>
4044
<artifactId>grpc-netty</artifactId>
@@ -73,6 +77,11 @@
7377
<artifactId>grpc-google-cloud-trace-v1</artifactId>
7478
<scope>test</scope>
7579
</dependency>
80+
<dependency>
81+
<groupId>com.google.api.grpc</groupId>
82+
<artifactId>grpc-google-cloud-trace-v2</artifactId>
83+
<scope>test</scope>
84+
</dependency>
7685
<dependency>
7786
<groupId>com.google.api</groupId>
7887
<artifactId>gax-grpc</artifactId>
Lines changed: 328 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,328 @@
1+
/*
2+
* Copyright 2017, Google LLC All rights reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.google.cloud.trace.v2;
17+
18+
import com.google.api.core.BetaApi;
19+
import com.google.api.gax.core.BackgroundResource;
20+
import com.google.api.gax.rpc.UnaryCallable;
21+
import com.google.cloud.trace.v2.stub.TraceServiceStub;
22+
import com.google.devtools.cloudtrace.v2.BatchWriteSpansRequest;
23+
import com.google.devtools.cloudtrace.v2.ProjectName;
24+
import com.google.devtools.cloudtrace.v2.Span;
25+
import com.google.protobuf.Empty;
26+
import java.io.IOException;
27+
import java.util.List;
28+
import java.util.concurrent.TimeUnit;
29+
import javax.annotation.Generated;
30+
31+
// AUTO-GENERATED DOCUMENTATION AND SERVICE
32+
/**
33+
* Service Description: This file describes an API for collecting and viewing traces and spans
34+
* within a trace. A Trace is a collection of spans corresponding to a single operation or set of
35+
* operations for an application. A span is an individual timed event which forms a node of the
36+
* trace tree. A single trace may contain span(s) from multiple services.
37+
*
38+
* <p>This class provides the ability to make remote calls to the backing service through method
39+
* calls that map to API methods. Sample code to get started:
40+
*
41+
* <pre>
42+
* <code>
43+
* try (TraceServiceClient traceServiceClient = TraceServiceClient.create()) {
44+
* ProjectName name = ProjectName.of("[PROJECT]");
45+
* List&lt;Span&gt; spans = new ArrayList&lt;&gt;();
46+
* traceServiceClient.batchWriteSpans(name, spans);
47+
* }
48+
* </code>
49+
* </pre>
50+
*
51+
* <p>Note: close() needs to be called on the traceServiceClient object to clean up resources such
52+
* as threads. In the example above, try-with-resources is used, which automatically calls close().
53+
*
54+
* <p>The surface of this class includes several types of Java methods for each of the API's
55+
* methods:
56+
*
57+
* <ol>
58+
* <li> A "flattened" method. With this type of method, the fields of the request type have been
59+
* converted into function parameters. It may be the case that not all fields are available as
60+
* parameters, and not every API method will have a flattened method entry point.
61+
* <li> A "request object" method. This type of method only takes one parameter, a request object,
62+
* which must be constructed before the call. Not every API method will have a request object
63+
* method.
64+
* <li> A "callable" method. This type of method takes no parameters and returns an immutable API
65+
* callable object, which can be used to initiate calls to the service.
66+
* </ol>
67+
*
68+
* <p>See the individual methods for example code.
69+
*
70+
* <p>Many parameters require resource names to be formatted in a particular way. To assist with
71+
* these names, this class includes a format method for each type of name, and additionally a parse
72+
* method to extract the individual identifiers contained within names that are returned.
73+
*
74+
* <p>This class can be customized by passing in a custom instance of TraceServiceSettings to
75+
* create(). For example:
76+
*
77+
* <p>To customize credentials:
78+
*
79+
* <pre>
80+
* <code>
81+
* TraceServiceSettings traceServiceSettings =
82+
* TraceServiceSettings.newBuilder()
83+
* .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
84+
* .build();
85+
* TraceServiceClient traceServiceClient =
86+
* TraceServiceClient.create(traceServiceSettings);
87+
* </code>
88+
* </pre>
89+
*
90+
* To customize the endpoint:
91+
*
92+
* <pre>
93+
* <code>
94+
* TraceServiceSettings traceServiceSettings =
95+
* TraceServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
96+
* TraceServiceClient traceServiceClient =
97+
* TraceServiceClient.create(traceServiceSettings);
98+
* </code>
99+
* </pre>
100+
*/
101+
@Generated("by GAPIC v0.0.5")
102+
@BetaApi
103+
public class TraceServiceClient implements BackgroundResource {
104+
private final TraceServiceSettings settings;
105+
private final TraceServiceStub stub;
106+
107+
/** Constructs an instance of TraceServiceClient with default settings. */
108+
public static final TraceServiceClient create() throws IOException {
109+
return create(TraceServiceSettings.newBuilder().build());
110+
}
111+
112+
/**
113+
* Constructs an instance of TraceServiceClient, using the given settings. The channels are
114+
* created based on the settings passed in, or defaults for any settings that are not set.
115+
*/
116+
public static final TraceServiceClient create(TraceServiceSettings settings) throws IOException {
117+
return new TraceServiceClient(settings);
118+
}
119+
120+
/**
121+
* Constructs an instance of TraceServiceClient, using the given stub for making calls. This is
122+
* for advanced usage - prefer to use TraceServiceSettings}.
123+
*/
124+
@BetaApi("A restructuring of stub classes is planned, so this may break in the future")
125+
public static final TraceServiceClient create(TraceServiceStub stub) {
126+
return new TraceServiceClient(stub);
127+
}
128+
129+
/**
130+
* Constructs an instance of TraceServiceClient, using the given settings. This is protected so
131+
* that it is easy to make a subclass, but otherwise, the static factory methods should be
132+
* preferred.
133+
*/
134+
protected TraceServiceClient(TraceServiceSettings settings) throws IOException {
135+
this.settings = settings;
136+
this.stub = settings.createStub();
137+
}
138+
139+
@BetaApi("A restructuring of stub classes is planned, so this may break in the future")
140+
protected TraceServiceClient(TraceServiceStub stub) {
141+
this.settings = null;
142+
this.stub = stub;
143+
}
144+
145+
public final TraceServiceSettings getSettings() {
146+
return settings;
147+
}
148+
149+
@BetaApi("A restructuring of stub classes is planned, so this may break in the future")
150+
public TraceServiceStub getStub() {
151+
return stub;
152+
}
153+
154+
// AUTO-GENERATED DOCUMENTATION AND METHOD
155+
/**
156+
* Sends new spans to Stackdriver Trace or updates existing traces. If the name of a trace that
157+
* you send matches that of an existing trace, new spans are added to the existing trace. Attempt
158+
* to update existing spans results undefined behavior. If the name does not match, a new trace is
159+
* created with given set of spans.
160+
*
161+
* <p>Sample code:
162+
*
163+
* <pre><code>
164+
* try (TraceServiceClient traceServiceClient = TraceServiceClient.create()) {
165+
* ProjectName name = ProjectName.of("[PROJECT]");
166+
* List&lt;Span&gt; spans = new ArrayList&lt;&gt;();
167+
* traceServiceClient.batchWriteSpans(name, spans);
168+
* }
169+
* </code></pre>
170+
*
171+
* @param name Required. Name of the project where the spans belong. The format is
172+
* `projects/PROJECT_ID`.
173+
* @param spans A collection of spans.
174+
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
175+
*/
176+
public final void batchWriteSpans(ProjectName name, List<Span> spans) {
177+
178+
BatchWriteSpansRequest request =
179+
BatchWriteSpansRequest.newBuilder().setNameWithProjectName(name).addAllSpans(spans).build();
180+
batchWriteSpans(request);
181+
}
182+
183+
// AUTO-GENERATED DOCUMENTATION AND METHOD
184+
/**
185+
* Sends new spans to Stackdriver Trace or updates existing traces. If the name of a trace that
186+
* you send matches that of an existing trace, new spans are added to the existing trace. Attempt
187+
* to update existing spans results undefined behavior. If the name does not match, a new trace is
188+
* created with given set of spans.
189+
*
190+
* <p>Sample code:
191+
*
192+
* <pre><code>
193+
* try (TraceServiceClient traceServiceClient = TraceServiceClient.create()) {
194+
* ProjectName name = ProjectName.of("[PROJECT]");
195+
* List&lt;Span&gt; spans = new ArrayList&lt;&gt;();
196+
* BatchWriteSpansRequest request = BatchWriteSpansRequest.newBuilder()
197+
* .setNameWithProjectName(name)
198+
* .addAllSpans(spans)
199+
* .build();
200+
* traceServiceClient.batchWriteSpans(request);
201+
* }
202+
* </code></pre>
203+
*
204+
* @param request The request object containing all of the parameters for the API call.
205+
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
206+
*/
207+
public final void batchWriteSpans(BatchWriteSpansRequest request) {
208+
batchWriteSpansCallable().call(request);
209+
}
210+
211+
// AUTO-GENERATED DOCUMENTATION AND METHOD
212+
/**
213+
* Sends new spans to Stackdriver Trace or updates existing traces. If the name of a trace that
214+
* you send matches that of an existing trace, new spans are added to the existing trace. Attempt
215+
* to update existing spans results undefined behavior. If the name does not match, a new trace is
216+
* created with given set of spans.
217+
*
218+
* <p>Sample code:
219+
*
220+
* <pre><code>
221+
* try (TraceServiceClient traceServiceClient = TraceServiceClient.create()) {
222+
* ProjectName name = ProjectName.of("[PROJECT]");
223+
* List&lt;Span&gt; spans = new ArrayList&lt;&gt;();
224+
* BatchWriteSpansRequest request = BatchWriteSpansRequest.newBuilder()
225+
* .setNameWithProjectName(name)
226+
* .addAllSpans(spans)
227+
* .build();
228+
* ApiFuture&lt;Void&gt; future = traceServiceClient.batchWriteSpansCallable().futureCall(request);
229+
* // Do something
230+
* future.get();
231+
* }
232+
* </code></pre>
233+
*/
234+
public final UnaryCallable<BatchWriteSpansRequest, Empty> batchWriteSpansCallable() {
235+
return stub.batchWriteSpansCallable();
236+
}
237+
238+
// AUTO-GENERATED DOCUMENTATION AND METHOD
239+
/**
240+
* Creates a new Span.
241+
*
242+
* <p>Sample code:
243+
*
244+
* <pre><code>
245+
* try (TraceServiceClient traceServiceClient = TraceServiceClient.create()) {
246+
* SpanName name = SpanName.of("[PROJECT]", "[TRACE]", "[SPAN]");
247+
* String spanId = "";
248+
* TruncatableString displayName = TruncatableString.newBuilder().build();
249+
* Timestamp startTime = Timestamp.newBuilder().build();
250+
* Timestamp endTime = Timestamp.newBuilder().build();
251+
* Span request = Span.newBuilder()
252+
* .setNameWithSpanName(name)
253+
* .setSpanId(spanId)
254+
* .setDisplayName(displayName)
255+
* .setStartTime(startTime)
256+
* .setEndTime(endTime)
257+
* .build();
258+
* Span response = traceServiceClient.createSpan(request);
259+
* }
260+
* </code></pre>
261+
*
262+
* @param request The request object containing all of the parameters for the API call.
263+
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
264+
*/
265+
public final Span createSpan(Span request) {
266+
return createSpanCallable().call(request);
267+
}
268+
269+
// AUTO-GENERATED DOCUMENTATION AND METHOD
270+
/**
271+
* Creates a new Span.
272+
*
273+
* <p>Sample code:
274+
*
275+
* <pre><code>
276+
* try (TraceServiceClient traceServiceClient = TraceServiceClient.create()) {
277+
* SpanName name = SpanName.of("[PROJECT]", "[TRACE]", "[SPAN]");
278+
* String spanId = "";
279+
* TruncatableString displayName = TruncatableString.newBuilder().build();
280+
* Timestamp startTime = Timestamp.newBuilder().build();
281+
* Timestamp endTime = Timestamp.newBuilder().build();
282+
* Span request = Span.newBuilder()
283+
* .setNameWithSpanName(name)
284+
* .setSpanId(spanId)
285+
* .setDisplayName(displayName)
286+
* .setStartTime(startTime)
287+
* .setEndTime(endTime)
288+
* .build();
289+
* ApiFuture&lt;Span&gt; future = traceServiceClient.createSpanCallable().futureCall(request);
290+
* // Do something
291+
* Span response = future.get();
292+
* }
293+
* </code></pre>
294+
*/
295+
public final UnaryCallable<Span, Span> createSpanCallable() {
296+
return stub.createSpanCallable();
297+
}
298+
299+
@Override
300+
public final void close() throws Exception {
301+
stub.close();
302+
}
303+
304+
@Override
305+
public void shutdown() {
306+
stub.shutdown();
307+
}
308+
309+
@Override
310+
public boolean isShutdown() {
311+
return stub.isShutdown();
312+
}
313+
314+
@Override
315+
public boolean isTerminated() {
316+
return stub.isTerminated();
317+
}
318+
319+
@Override
320+
public void shutdownNow() {
321+
stub.shutdownNow();
322+
}
323+
324+
@Override
325+
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
326+
return stub.awaitTermination(duration, unit);
327+
}
328+
}

0 commit comments

Comments
 (0)