open-nomad/vendor/contrib.go.opencensus.io/exporter/ocagent
Seth Hoenig 435c0d9fc8 deps: Switch to Go modules for dependency management
This PR switches the Nomad repository from using govendor to Go modules
for managing dependencies. Aspects of the Nomad workflow remain pretty
much the same. The usual Makefile targets should continue to work as
they always did. The API submodule simply defers to the parent Nomad
version on the repository, keeping the semantics of API versioning that
currently exists.
2020-06-02 14:30:36 -05:00
..
.travis.yml deps: Switch to Go modules for dependency management 2020-06-02 14:30:36 -05:00
CONTRIBUTING.md deps: Switch to Go modules for dependency management 2020-06-02 14:30:36 -05:00
LICENSE deps: Switch to Go modules for dependency management 2020-06-02 14:30:36 -05:00
README.md deps: Switch to Go modules for dependency management 2020-06-02 14:30:36 -05:00
common.go deps: Switch to Go modules for dependency management 2020-06-02 14:30:36 -05:00
connection.go deps: Switch to Go modules for dependency management 2020-06-02 14:30:36 -05:00
go.mod deps: Switch to Go modules for dependency management 2020-06-02 14:30:36 -05:00
go.sum deps: Switch to Go modules for dependency management 2020-06-02 14:30:36 -05:00
nodeinfo.go deps: Switch to Go modules for dependency management 2020-06-02 14:30:36 -05:00
ocagent.go deps: Switch to Go modules for dependency management 2020-06-02 14:30:36 -05:00
options.go deps: Switch to Go modules for dependency management 2020-06-02 14:30:36 -05:00
transform_spans.go deps: Switch to Go modules for dependency management 2020-06-02 14:30:36 -05:00
transform_stats_to_metrics.go deps: Switch to Go modules for dependency management 2020-06-02 14:30:36 -05:00
version.go deps: Switch to Go modules for dependency management 2020-06-02 14:30:36 -05:00

README.md

OpenCensus Agent Go Exporter

Build Status GoDoc

This repository contains the Go implementation of the OpenCensus Agent (OC-Agent) Exporter. OC-Agent is a deamon process running in a VM that can retrieve spans/stats/metrics from OpenCensus Library, export them to other backends and possibly push configurations back to Library. See more details on OC-Agent Readme.

Note: This is an experimental repository and is likely to get backwards-incompatible changes. Ultimately we may want to move the OC-Agent Go Exporter to OpenCensus Go core library.

Installation

$ go get -u contrib.go.opencensus.io/exporter/ocagent

Usage

import (
	"context"
	"fmt"
	"log"
	"time"

	"contrib.go.opencensus.io/exporter/ocagent"
	"go.opencensus.io/trace"
)

func Example() {
	exp, err := ocagent.NewExporter(ocagent.WithInsecure(), ocagent.WithServiceName("your-service-name"))
	if err != nil {
		log.Fatalf("Failed to create the agent exporter: %v", err)
	}
	defer exp.Stop()

	// Now register it as a trace exporter.
	trace.RegisterExporter(exp)

	// Then use the OpenCensus tracing library, like we normally would.
	ctx, span := trace.StartSpan(context.Background(), "AgentExporter-Example")
	defer span.End()

	for i := 0; i < 10; i++ {
		_, iSpan := trace.StartSpan(ctx, fmt.Sprintf("Sample-%d", i))
		<-time.After(6 * time.Millisecond)
		iSpan.End()
	}
}