1
- package com .example .spanner ;
1
+ /*
2
+ * Copyright 2018 Google Inc.
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
+ */
2
16
3
- import java . util . Arrays ;
17
+ package com . example . spanner ;
4
18
5
19
import com .google .cloud .spanner .DatabaseClient ;
6
20
import com .google .cloud .spanner .DatabaseId ;
17
31
import io .opencensus .trace .Tracing ;
18
32
import io .opencensus .trace .samplers .Samplers ;
19
33
34
+ import java .util .Arrays ;
35
+
36
+ /**
37
+ * This sample demonstrates how to enable opencensus tracing and stats in cloud spanner client.
38
+ */
20
39
public class TracingSample {
21
40
22
41
private static final String SAMPLE_SPAN = "CloudSpannerSample" ;
23
42
24
- public static void main (String [] args ) throws Exception {
43
+ public static void main (String [] args ) throws Exception {
25
44
if (args .length != 2 ) {
26
45
System .err .println ("Usage: TracingSample <instance_id> <database_id>" );
27
46
return ;
@@ -33,7 +52,8 @@ public static void main(String[] args) throws Exception {
33
52
ZPageHandlers .startHttpServerAndRegisterAll (8080 );
34
53
// Installs an exporter for stack driver traces.
35
54
StackdriverExporter .createAndRegister ();
36
- Tracing .getExportComponent ().getSampledSpanStore ().registerSpanNamesForCollection (Arrays .asList (SAMPLE_SPAN ));
55
+ Tracing .getExportComponent ().getSampledSpanStore ().registerSpanNamesForCollection (
56
+ Arrays .asList (SAMPLE_SPAN ));
37
57
38
58
// Installs an exporter for stack driver stats.
39
59
StackdriverStatsExporter .createAndRegister ();
0 commit comments