1 # OpenCensus Agent Go Exporter
3 [![Build Status][travis-image]][travis-url] [![GoDoc][godoc-image]][godoc-url]
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].
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].
17 $ go get -u contrib.go.opencensus.io/exporter/ocagent
29 "contrib.go.opencensus.io/exporter/ocagent"
30 "go.opencensus.io/trace"
34 exp, err := ocagent.NewExporter(ocagent.WithInsecure(), ocagent.WithServiceName("your-service-name"))
36 log.Fatalf("Failed to create the agent exporter: %v", err)
40 // Now register it as a trace exporter.
41 trace.RegisterExporter(exp)
43 // Then use the OpenCensus tracing library, like we normally would.
44 ctx, span := trace.StartSpan(context.Background(), "AgentExporter-Example")
47 for i := 0; i < 10; i++ {
48 _, iSpan := trace.StartSpan(ctx, fmt.Sprintf("Sample-%d", i))
49 <-time.After(6 * time.Millisecond)
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