Code refactoring for bpa operator
[icn.git] / cmd / bpa-operator / vendor / contrib.go.opencensus.io / exporter / ocagent / README.md
1 # OpenCensus Agent Go Exporter
2
3 [![Build Status][travis-image]][travis-url] [![GoDoc][godoc-image]][godoc-url]
4
5
6 This repository contains the Go implementation of the OpenCensus Agent (OC-Agent) Exporter.
7 OC-Agent is a deamon process running in a VM that can retrieve spans/stats/metrics from
8 OpenCensus Library, export them to other backends and possibly push configurations back to
9 Library. See more details on [OC-Agent Readme][OCAgentReadme].
10
11 Note: This is an experimental repository and is likely to get backwards-incompatible changes.
12 Ultimately we may want to move the OC-Agent Go Exporter to [OpenCensus Go core library][OpenCensusGo].
13
14 ## Installation
15
16 ```bash
17 $ go get -u contrib.go.opencensus.io/exporter/ocagent
18 ```
19
20 ## Usage
21
22 ```go
23 import (
24         "context"
25         "fmt"
26         "log"
27         "time"
28
29         "contrib.go.opencensus.io/exporter/ocagent"
30         "go.opencensus.io/trace"
31 )
32
33 func Example() {
34         exp, err := ocagent.NewExporter(ocagent.WithInsecure(), ocagent.WithServiceName("your-service-name"))
35         if err != nil {
36                 log.Fatalf("Failed to create the agent exporter: %v", err)
37         }
38         defer exp.Stop()
39
40         // Now register it as a trace exporter.
41         trace.RegisterExporter(exp)
42
43         // Then use the OpenCensus tracing library, like we normally would.
44         ctx, span := trace.StartSpan(context.Background(), "AgentExporter-Example")
45         defer span.End()
46
47         for i := 0; i < 10; i++ {
48                 _, iSpan := trace.StartSpan(ctx, fmt.Sprintf("Sample-%d", i))
49                 <-time.After(6 * time.Millisecond)
50                 iSpan.End()
51         }
52 }
53 ```
54
55 [OCAgentReadme]: https://github.com/census-instrumentation/opencensus-proto/tree/master/opencensus/proto/agent#opencensus-agent-proto
56 [OpenCensusGo]: https://github.com/census-instrumentation/opencensus-go
57 [godoc-image]: https://godoc.org/contrib.go.opencensus.io/exporter/ocagent?status.svg
58 [godoc-url]: https://godoc.org/contrib.go.opencensus.io/exporter/ocagent
59 [travis-image]: https://travis-ci.org/census-ecosystem/opencensus-go-exporter-ocagent.svg?branch=master
60 [travis-url]: https://travis-ci.org/census-ecosystem/opencensus-go-exporter-ocagent
61