Skip to content

Commit 16f0ea8

Browse files
authored
exporter/{metric,trace}: fix README.md example to latest API (#612)
Signed-off-by: Koichi Shiraishi <zchee.io@gmail.com>
1 parent f1aae84 commit 16f0ea8

2 files changed

Lines changed: 9 additions & 12 deletions

File tree

exporter/metric/README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ After you import the metric exporter package, then register the exporter to the
1919
package main
2020

2121
import (
22+
"context"
23+
"log"
24+
2225
"go.opentelemetry.io/otel/attribute"
23-
"go.opentelemetry.io/otel/metric/instrument"
2426
"go.opentelemetry.io/otel/sdk/metric"
2527

2628
mexporter "github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/metric"
@@ -41,14 +43,14 @@ func main() {
4143
// Start meter
4244
meter := provider.Meter("github.com/GoogleCloudPlatform/opentelemetry-operations-go/example/metric")
4345

44-
counter, err := meter.SyncInt64().Counter("counter-foo")
46+
counter, err := meter.Int64Counter("counter-foo")
4547
if err != nil {
4648
log.Fatalf("Failed to create counter: %v", err)
4749
}
48-
labels := []label.KeyValue{
49-
label.Key("key").String("value"),
50+
attrs := []attribute.KeyValue{
51+
attribute.Key("key").String("value"),
5052
}
51-
counter.Add(ctx, 123, labels...)
53+
counter.Add(ctx, 123, attrs...)
5254
}
5355
```
5456

exporter/trace/README.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,8 @@ When running code locally, you may need to specify a Google Project ID in additi
5959

6060
```go
6161
projectID := os.Getenv("GOOGLE_CLOUD_PROJECT")
62-
_, shutdown, err := texporter.InstallNewPipeline(
63-
[]texporter.Option {
64-
texporter.WithProjectID(projectID),
65-
// other optional exporter options
66-
},
67-
...
68-
)
62+
exporter, err := texporter.New(texporter.WithProjectID(projectID))
63+
...
6964
```
7065

7166
## Useful links

0 commit comments

Comments
 (0)