gcloudtracer

package module
v0.0.0-...-cd89086 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 15, 2017 License: BSD-3-Clause Imports: 15 Imported by: 0

README

GoDoc

gcloud-opentracing

OpenTracing Tracer implementation for GCloud StackDriver in Go. Based on basictracer and implemented Recorder for this propose.

Getting Started

To install gcloud-opentracing, use go get:

go get github.com/lovoo/gcloud-opentracing

or govendor:

govendor fetch github.com/lovoo/gcloud-opentracing

or other tool for vendoring.

Sample Usage

First of all, you need to init Global Tracer with GCloud Tracer:

package main

import (
    gcloudtracer "github.com/lovoo/gcloud-opentracing"
    opentracing "github.com/opentracing/opentracing-go"
    "golang.org/x/net/context"
)

func main() {
    // ...
    opentracing.InitGlobalTracer(
        gcloudtracer.NewTracer(context.Background(), gcloudtracer.WithProject("project-id"))
    )
    // ...
}

Then you can create traces as decribed here. More information you can find on OpenTracing project website.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidProjectID occurs if project identifier is invalid.
	ErrInvalidProjectID = errors.New("invalid project id")
)

Functions

func NewTracer

func NewTracer(ctx context.Context, opts ...Option) (opentracing.Tracer, error)

NewTracer creates new basictracer for GCloud StackDriver.

Types

type Logger

type Logger interface {
	Errorf(string, ...interface{})
}

Logger defines an interface to log an error.

type Option

type Option func(o *Options)

Option defines an recorder option.

func WithClientOption

func WithClientOption(opts ...option.ClientOption) Option

WithClientOption retuns an option that specifies GRPC client Options.

func WithLogger

func WithLogger(logger Logger) Option

WithLogger returns an Option that specifies a logger of the Recorder.

func WithProject

func WithProject(pid string) Option

WithProject returns a Option that specifies a project identifier.

type Options

type Options struct {
	// contains filtered or unexported fields
}

Options containes options for recorder and StackDriver client.

func (*Options) Valid

func (o *Options) Valid() error

Valid validates Options.

type Recorder

type Recorder struct {
	// contains filtered or unexported fields
}

Recorder implements basictracer.SpanRecorder interface used to write traces to the GCE StackDriver.

func NewRecorder

func NewRecorder(ctx context.Context, opts ...Option) (*Recorder, error)

NewRecorder creates new GCloud StackDriver recorder.

func (*Recorder) RecordSpan

func (r *Recorder) RecordSpan(sp basictracer.RawSpan)

RecordSpan writes Span to the GCLoud StackDriver.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL