-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor client.NewBucket Add client.NewInstrumentedBucket Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>
- Loading branch information
Showing
16 changed files
with
596 additions
and
274 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
// Copyright (c) The Thanos Authors. | ||
// Licensed under the Apache License 2.0. | ||
|
||
package client | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"io/ioutil" | ||
|
||
"github.com/go-kit/log" | ||
"github.com/prometheus/client_golang/prometheus" | ||
"go.opentelemetry.io/otel/trace" | ||
|
||
"github.com/thanos-io/objstore/tracing/opentelemetry" | ||
"github.com/thanos-io/objstore/tracing/opentracing" | ||
) | ||
|
||
func ExampleBucket() { | ||
// Read the configuration file. | ||
confContentYaml, err := ioutil.ReadFile("testconf/filesystem.conf.yml") | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
// Create a new bucket. | ||
bucket, err := NewBucket(log.NewNopLogger(), confContentYaml, "example") | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
// Test it. | ||
exists, err := bucket.Exists(context.Background(), "example") | ||
if err != nil { | ||
panic(err) | ||
} | ||
fmt.Println(exists) | ||
// Output: | ||
// false | ||
} | ||
|
||
func ExampleInstrumentedBucket() { | ||
// Read the configuration file. | ||
confContentYaml, err := ioutil.ReadFile("testconf/filesystem.conf.yml") | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
// Create a new bucket. | ||
bucket, err := NewBucket(log.NewNopLogger(), confContentYaml, "example") | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
// Wrap it with instrumentation. | ||
bucket = InstrumentedBucket(bucket, prometheus.NewRegistry()) | ||
|
||
// Test it. | ||
exists, err := bucket.Exists(context.Background(), "example") | ||
if err != nil { | ||
panic(err) | ||
} | ||
fmt.Println(exists) | ||
// Output: | ||
// false | ||
} | ||
|
||
func ExampleTracingBucketUsingOpenTracing() { //nolint:govet | ||
// Read the configuration file. | ||
confContentYaml, err := ioutil.ReadFile("testconf/filesystem.conf.yml") | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
// Create a new bucket. | ||
bucket, err := NewBucket(log.NewNopLogger(), confContentYaml, "example") | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
// Wrap it with tracing. | ||
bucket = opentracing.TracedBucket(bucket) | ||
|
||
// Test it. | ||
exists, err := bucket.Exists(context.Background(), "example") | ||
if err != nil { | ||
panic(err) | ||
} | ||
fmt.Println(exists) | ||
// Output: | ||
// false | ||
} | ||
|
||
func ExampleTracingBucketUsingOpenTelemetry() { //nolint:govet | ||
// Read the configuration file. | ||
confContentYaml, err := ioutil.ReadFile("testconf/filesystem.conf.yml") | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
// Create a new bucket. | ||
bucket, err := NewBucket(log.NewNopLogger(), confContentYaml, "example") | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
// Wrap it with tracing. | ||
bucket = opentelemetry.TracedBucket(bucket, trace.NewNoopTracerProvider().Tracer("bucket")) | ||
|
||
// Test it. | ||
exists, err := bucket.Exists(context.Background(), "example") | ||
if err != nil { | ||
panic(err) | ||
} | ||
fmt.Println(exists) | ||
// Output: | ||
// false | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
type: "FILESYSTEM" | ||
config: | ||
directory: "./data" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.