Skip to content

Commit

Permalink
update module
Browse files Browse the repository at this point in the history
  • Loading branch information
hucansen committed Dec 14, 2022
1 parent 8acf65c commit 5fd6a4f
Show file tree
Hide file tree
Showing 131 changed files with 1,357 additions and 1,357 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/.idea/

# go.opencensus.io/exporter/aws
# github.com/gozelle/opencensus-go/exporter/aws
/exporter/aws/

# Exclude vendor, use dep ensure after checkout:
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ information on using pull requests.
Fork the repo, checkout the upstream repo to your GOPATH by:

```
$ go get -d go.opencensus.io
$ go get -d github.com/gozelle/opencensus-go
```

Add your fork as an origin:

```
cd $(go env GOPATH)/src/go.opencensus.io
cd $(go env GOPATH)/src/github.com/gozelle/opencensus-go
git remote add fork [email protected]:YOUR_GITHUB_USERNAME/opencensus-go.git
```

Expand Down
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Currently it consists of three major components: tags, stats and tracing.
## Installation

```
$ go get -u go.opencensus.io
$ go get -u github.com/gozelle/opencensus-go
```

The API of this project is still evolving, see: [Deprecation Policy](#deprecation-policy).
Expand All @@ -29,8 +29,8 @@ OpenCensus Go libraries require Go 1.8 or later.
The easiest way to get started using OpenCensus in your application is to use an existing
integration with your RPC framework:

* [net/http](https://godoc.org/go.opencensus.io/plugin/ochttp)
* [gRPC](https://godoc.org/go.opencensus.io/plugin/ocgrpc)
* [net/http](https://godoc.org/github.com/gozelle/opencensus-go/plugin/ochttp)
* [gRPC](https://godoc.org/github.com/gozelle/opencensus-go/plugin/ocgrpc)
* [database/sql](https://godoc.org/github.com/opencensus-integrations/ocsql)
* [Go kit](https://godoc.org/github.com/go-kit/kit/tracing/opencensus)
* [Groupcache](https://godoc.org/github.com/orijtech/groupcache)
Expand All @@ -48,8 +48,8 @@ framework or use [custom stats](#stats) and [spans](#spans) directly in your app
OpenCensus can export instrumentation data to various backends.
OpenCensus has exporter implementations for the following, users
can implement their own exporters by implementing the exporter interfaces
([stats](https://godoc.org/go.opencensus.io/stats/view#Exporter),
[trace](https://godoc.org/go.opencensus.io/trace#Exporter)):
([stats](https://godoc.org/github.com/gozelle/opencensus-go/stats/view#Exporter),
[trace](https://godoc.org/github.com/gozelle/opencensus-go/trace#Exporter)):

* [Prometheus][exporter-prom] for stats
* [OpenZipkin][exporter-zipkin] for traces
Expand Down Expand Up @@ -198,10 +198,10 @@ defer span.End()
Across the network, OpenCensus provides different propagation
methods for different protocols.

* gRPC integrations use the OpenCensus' [binary propagation format](https://godoc.org/go.opencensus.io/trace/propagation).
* gRPC integrations use the OpenCensus' [binary propagation format](https://godoc.org/github.com/gozelle/opencensus-go/trace/propagation).
* HTTP integrations use Zipkin's [B3](https://github.com/openzipkin/b3-propagation)
by default but can be configured to use a custom propagation method by setting another
[propagation.HTTPFormat](https://godoc.org/go.opencensus.io/trace/propagation#HTTPFormat).
[propagation.HTTPFormat](https://godoc.org/github.com/gozelle/opencensus-go/trace/propagation#HTTPFormat).

## Execution Tracer

Expand Down Expand Up @@ -247,19 +247,19 @@ release in which the functionality was marked *Deprecated*.
[travis-url]: https://travis-ci.org/census-instrumentation/opencensus-go
[appveyor-image]: https://ci.appveyor.com/api/projects/status/vgtt29ps1783ig38?svg=true
[appveyor-url]: https://ci.appveyor.com/project/opencensusgoteam/opencensus-go/branch/master
[godoc-image]: https://godoc.org/go.opencensus.io?status.svg
[godoc-url]: https://godoc.org/go.opencensus.io
[godoc-image]: https://godoc.org/github.com/gozelle/opencensus-go?status.svg
[godoc-url]: https://godoc.org/github.com/gozelle/opencensus-go
[gitter-image]: https://badges.gitter.im/census-instrumentation/lobby.svg
[gitter-url]: https://gitter.im/census-instrumentation/lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge


[new-ex]: https://godoc.org/go.opencensus.io/tag#example-NewMap
[new-replace-ex]: https://godoc.org/go.opencensus.io/tag#example-NewMap--Replace
[new-ex]: https://godoc.org/github.com/gozelle/opencensus-go/tag#example-NewMap
[new-replace-ex]: https://godoc.org/github.com/gozelle/opencensus-go/tag#example-NewMap--Replace

[exporter-prom]: https://godoc.org/contrib.go.opencensus.io/exporter/prometheus
[exporter-stackdriver]: https://godoc.org/contrib.go.opencensus.io/exporter/stackdriver
[exporter-zipkin]: https://godoc.org/contrib.go.opencensus.io/exporter/zipkin
[exporter-jaeger]: https://godoc.org/contrib.go.opencensus.io/exporter/jaeger
[exporter-prom]: https://godoc.org/contrib.github.com/gozelle/opencensus-go/exporter/prometheus
[exporter-stackdriver]: https://godoc.org/contrib.github.com/gozelle/opencensus-go/exporter/stackdriver
[exporter-zipkin]: https://godoc.org/contrib.github.com/gozelle/opencensus-go/exporter/zipkin
[exporter-jaeger]: https://godoc.org/contrib.github.com/gozelle/opencensus-go/exporter/jaeger
[exporter-xray]: https://github.com/census-ecosystem/opencensus-go-exporter-aws
[exporter-datadog]: https://github.com/DataDog/opencensus-go-exporter-datadog
[exporter-graphite]: https://github.com/census-ecosystem/opencensus-go-exporter-graphite
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "{build}"

platform: x64

clone_folder: c:\gopath\src\go.opencensus.io
clone_folder: c:\gopath\src\github.com/gozelle/opencensus-go

environment:
GOPATH: 'c:\gopath'
Expand Down
12 changes: 6 additions & 6 deletions examples/derived_gauges/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ Enter different value for number of items to queue and fetch the metrics using a
## Run the example

```
$ go get go.opencensus.io/examples/derived_gauges/...
$ go get github.com/gozelle/opencensus-go/examples/derived_gauges/...
```

then:

```
$ go run $(go env GOPATH)/src/go.opencensus.io/examples/derived_gauges/derived_gauge.go
$ go run $(go env GOPATH)/src/github.com/gozelle/opencensus-go/examples/derived_gauges/derived_gauge.go
```

## How to use derived gauges?
Expand Down Expand Up @@ -166,10 +166,10 @@ import (
"sync"
"time"

"go.opencensus.io/examples/exporter"
"go.opencensus.io/metric"
"go.opencensus.io/metric/metricdata"
"go.opencensus.io/metric/metricproducer"
"github.com/gozelle/opencensus-go/examples/exporter"
"github.com/gozelle/opencensus-go/metric"
"github.com/gozelle/opencensus-go/metric/metricdata"
"github.com/gozelle/opencensus-go/metric/metricproducer"
)

const (
Expand Down
32 changes: 16 additions & 16 deletions examples/derived_gauges/derived_gauge.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ import (
"strings"
"sync"
"time"

"go.opencensus.io/examples/exporter"
"go.opencensus.io/metric"
"go.opencensus.io/metric/metricdata"
"go.opencensus.io/metric/metricproducer"
"github.com/gozelle/opencensus-go/examples/exporter"
"github.com/gozelle/opencensus-go/metric"
"github.com/gozelle/opencensus-go/metric/metricdata"
"github.com/gozelle/opencensus-go/metric/metricproducer"
)

const (
Expand All @@ -52,7 +52,7 @@ const (
type queue struct {
size int
lastConsumed time.Time

mu sync.Mutex
q []int
}
Expand All @@ -71,7 +71,7 @@ func init() {
func (q *queue) consume() {
q.mu.Lock()
defer q.mu.Unlock()

consumeCount := rand.Int() % maxItemsToConsumePerAttempt
i := 0
for i = 0; i < consumeCount; i++ {
Expand All @@ -91,7 +91,7 @@ func (q *queue) consume() {
func (q *queue) produce(count int) {
q.mu.Lock()
defer q.mu.Unlock()

for i := 0; i < count; i++ {
v := rand.Int() % 100
q.q = append(q.q, v)
Expand Down Expand Up @@ -159,7 +159,7 @@ func doWork() {
fmt.Printf(" 2. queue_seconds_since_processed_last = the number of seconds elapsed since last time the queue was processed.\n")
fmt.Printf("\nGo to file://%s to see the metrics. OR do `tail -f %s` in another terminal\n\n\n",
metricsLogFile, metricsLogFile)

// Take a number of items to queue as an input from the user
// and enqueue the same number of items on to the consumer queue.
for {
Expand All @@ -181,13 +181,13 @@ func main() {
exporter.Start()
defer exporter.Stop()
defer exporter.Close()

// Create metric registry and register it with global producer manager.
// START reg
r := metric.NewRegistry()
metricproducer.GlobalManager().AddProducer(r)
// END reg

// Create Int64DerviedGauge
// START size
queueSizeGauge, err := r.AddInt64DerivedGauge(
Expand All @@ -198,14 +198,14 @@ func main() {
log.Fatalf("error creating queue size derived gauge, error %v\n", err)
}
// END size

// START entrySize
err = queueSizeGauge.UpsertEntry(q.Size)
if err != nil {
log.Fatalf("error getting queue size derived gauge entry, error %v\n", err)
}
// END entrySize

// Create Float64DerviedGauge
// START elapsed
elapsedSeconds, err := r.AddFloat64DerivedGauge(
Expand All @@ -216,19 +216,19 @@ func main() {
log.Fatalf("error creating queue_seconds_since_processed_last derived gauge, error %v\n", err)
}
// END elapsed

// START entryElapsed
err = elapsedSeconds.UpsertEntry(q.Elapsed)
if err != nil {
log.Fatalf("error getting queue_seconds_since_processed_last derived gauge entry, error %v\n", err)
}
// END entryElapsed

quit := make(chan bool)
defer func() {
close(quit)
}()

// Run consumer and producer
go q.runConsumer(5*time.Second, quit)

Expand Down
18 changes: 9 additions & 9 deletions examples/exporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package exporter // import "go.opencensus.io/examples/exporter"
package exporter // import "github.com/gozelle/opencensus-go/examples/exporter"

import (
"encoding/hex"
"fmt"
"regexp"
"time"

"go.opencensus.io/stats/view"
"go.opencensus.io/trace"
"github.com/gozelle/opencensus-go/stats/view"
"github.com/gozelle/opencensus-go/trace"
)

// indent these many spaces
Expand All @@ -43,7 +43,7 @@ type PrintExporter struct{}
func (e *PrintExporter) ExportView(vd *view.Data) {
for _, row := range vd.Rows {
fmt.Printf("%v %-45s", vd.End.Format("15:04:05"), vd.View.Name)

switch v := row.Data.(type) {
case *view.DistributionData:
fmt.Printf("distribution: min=%.1f max=%.1f mean=%.1f", v.Min, v.Max, v.Mean)
Expand All @@ -55,7 +55,7 @@ func (e *PrintExporter) ExportView(vd *view.Data) {
fmt.Printf("last: value=%v", v.Value)
}
fmt.Println()

for _, tag := range row.Tags {
fmt.Printf("%v- %v=%v\n", indent, tag.Key.Name(), tag.Value)
}
Expand All @@ -77,12 +77,12 @@ func (e *PrintExporter) ExportSpan(vd *trace.SpanData) {
if !reZero.MatchString(parentSpanID) {
fmt.Println("ParentSpanID:", parentSpanID)
}

fmt.Println()
fmt.Printf("Span: %v\n", vd.Name)
fmt.Printf("Status: %v [%v]\n", vd.Status.Message, vd.Status.Code)
fmt.Printf("Elapsed: %v\n", vd.EndTime.Sub(vd.StartTime).Round(time.Millisecond))

if len(vd.Annotations) > 0 {
fmt.Println()
fmt.Println("Annotations:")
Expand All @@ -94,7 +94,7 @@ func (e *PrintExporter) ExportSpan(vd *trace.SpanData) {
fmt.Println()
}
}

if len(vd.Attributes) > 0 {
fmt.Println()
fmt.Println("Attributes:")
Expand Down
24 changes: 12 additions & 12 deletions examples/exporter/logexporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

// Package exporter contains a log exporter that supports exporting
// OpenCensus metrics and spans to a logging framework.
package exporter // import "go.opencensus.io/examples/exporter"
package exporter // import "github.com/gozelle/opencensus-go/examples/exporter"

import (
"context"
Expand All @@ -24,10 +24,10 @@ import (
"os"
"sync"
"time"

"go.opencensus.io/metric/metricdata"
"go.opencensus.io/metric/metricexport"
"go.opencensus.io/trace"
"github.com/gozelle/opencensus-go/metric/metricdata"
"github.com/gozelle/opencensus-go/metric/metricexport"
"github.com/gozelle/opencensus-go/trace"
)

// LogExporter exports metrics and span to log file
Expand All @@ -47,11 +47,11 @@ type Options struct {
// ReportingInterval is a time interval between two successive metrics
// export.
ReportingInterval time.Duration

// MetricsLogFile is path where exported metrics are logged.
// If it is nil then the metrics are logged on console
MetricsLogFile string

// TracesLogFile is path where exported span data are logged.
// If it is nil then the span data are logged on console
TracesLogFile string
Expand Down Expand Up @@ -171,20 +171,20 @@ func (e *LogExporter) ExportSpan(sd *trace.SpanData) {
if !reZero.MatchString(parentSpanID) {
e.tLogger.Println("ParentSpanID:", parentSpanID)
}

e.tLogger.Println()
e.tLogger.Printf("Span: %v\n", sd.Name)
e.tLogger.Printf("Status: %v [%v]\n", sd.Status.Message, sd.Status.Code)
e.tLogger.Printf("Elapsed: %v\n", sd.EndTime.Sub(sd.StartTime).Round(time.Millisecond))

spanKinds := map[int]string{
1: "Server",
2: "Client",
}
if spanKind, ok := spanKinds[sd.SpanKind]; ok {
e.tLogger.Printf("SpanKind: %s\n", spanKind)
}

if len(sd.Annotations) > 0 {
e.tLogger.Println()
e.tLogger.Println("Annotations:")
Expand All @@ -196,15 +196,15 @@ func (e *LogExporter) ExportSpan(sd *trace.SpanData) {
e.tLogger.Println()
}
}

if len(sd.Attributes) > 0 {
e.tLogger.Println()
e.tLogger.Println("Attributes:")
for k, v := range sd.Attributes {
e.tLogger.Printf("%v- %v=%v\n", indent, k, v)
}
}

if len(sd.MessageEvents) > 0 {
eventTypes := map[trace.MessageEventType]string{
trace.MessageEventTypeSent: "Sent",
Expand Down
Loading

0 comments on commit 5fd6a4f

Please sign in to comment.