Skip to content

Commit eab8619

Browse files
authored
Fix the sample code shown in README (#373)
1 parent 10d8c86 commit eab8619

File tree

2 files changed

+23
-12
lines changed

2 files changed

+23
-12
lines changed

exporters/auto/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,20 @@ To leverage the GCP extensions to this, simply add the exporter-auto dependency
1515
<dependency>
1616
<groupId>com.google.cloud.opentelemetry</groupId>
1717
<artifactId>exporter-auto</artifactId>
18-
<version>0.27.0-alpha</version>
18+
<version>0.31.0-alpha</version>
1919
<!-- Add the classifier if you explicitly wish to use the shaded variant -->
2020
<classifier>shaded</classifier>
2121
</dependency>
2222
```
2323

2424
#### Gradle
2525
```groovy
26-
implementation "com.google.cloud.opentelemetry:exporter-auto:0.27.0-alpha"
26+
implementation "com.google.cloud.opentelemetry:exporter-auto:0.31.0-alpha"
2727
```
2828

2929
To use the shaded variant with Gradle,
3030
```groovy
31-
implementation "com.google.cloud.opentelemetry:exporter-auto:0.27.0-alpha:shaded"
31+
implementation "com.google.cloud.opentelemetry:exporter-auto:0.31.0-alpha:shaded"
3232
```
3333

3434
#### Shaded Local JAR
@@ -38,9 +38,9 @@ You can download the shaded JAR for `exporter-auto` from the following link -
3838
https://repo1.maven.org/maven2/com/google/cloud/opentelemetry/exporter-auto/<VERSION>-alpha/exporter-auto-<VERSION>-alpha-shaded.jar
3939
```
4040
Replace `<VERSION>` with the version you wish to download. For instance, shaded
41-
variant for `v0.27.0`, will be found at -
41+
variant for `v0.31.0`, will be found at -
4242

43-
`https://repo1.maven.org/maven2/com/google/cloud/opentelemetry/exporter-auto/0.27.0-alpha/exporter-auto-0.27.0-alpha-shaded.jar`
43+
`https://repo1.maven.org/maven2/com/google/cloud/opentelemetry/exporter-auto/0.31.0-alpha/exporter-auto-0.31.0-alpha-shaded.jar`
4444

4545
**Note: Make sure to use the latest release [![LatestRelease][maven-image]][maven-url].**
4646

exporters/trace/README.md

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,28 +29,39 @@ config:
2929
<dependency>
3030
<groupId>com.google.cloud.opentelemetry</groupId>
3131
<artifactId>exporter-trace</artifactId>
32-
<version>0.20.0</version>
32+
<version>0.31.0</version>
3333
</dependency>
3434
```
3535

3636
### Usage
37-
If you are running in a GCP environment, the exporter will automatically authenticate using the environment's service account. If not, you will need to follow the instructions in Authentication.
37+
If you are running in a GCP environment, the exporter will automatically authenticate using the environment's service account. If not, you will need to follow the instructions in Authentication.
38+
39+
See [the code example](../../examples/trace) for details.
3840

3941
#### Create the exporter
4042

41-
You can create exporter and register it in the OpenTelemetry SDK using the default configuration as follows:
43+
You can create exporter using the default configuration as follows:
4244

4345
```java
44-
TraceExporter traceExporter = TraceExporter.createWithDefaultConfiguration();
45-
OpenTelemetrySdk.getTracerProvider().addSpanProcessor(SimpleSpanProcessor.newBuilder(traceExporter).build());
46+
SpanExporter traceExporter = TraceExporter.createWithDefaultConfiguration();
4647
```
4748

4849
You can also customize the configuration using a TraceConfiguration object
4950
```java
50-
TraceExporter traceExporter = TraceExporter.createWithConfiguration(
51+
SpanExporter traceExporter = TraceExporter.createWithConfiguration(
5152
TraceConfiguration.builder().setProjectId("myCoolGcpProject").build()
5253
);
53-
OpenTelemetrySdk.getTracerProvider().addSpanProcessor(SimpleSpanProcessor.newBuilder(traceExporter).build());
54+
```
55+
56+
You can register a `SpanExporter` with your OpenTelemetry instance as follows:
57+
58+
```java
59+
OpenTelemetrySdk.builder()
60+
.setTracerProvider(
61+
SdkTracerProvider.builder()
62+
.addSpanProcessor(BatchSpanProcessor.builder(traceExporter).build())
63+
.build())
64+
.build();
5465
```
5566

5667
#### Specifying a project ID

0 commit comments

Comments
 (0)