Skip to content

opentracing stackdriver implementation with support for Stackdriver Trace, Stackdriver Logging, and Stackdriver Error Reporting

License

Notifications You must be signed in to change notification settings

savaki/stackdriver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

stackdriver

GoDoc

stackdriver is an opentracing implementation that provides support for Stackdriver Trace, Stackdriver Logging, and Stackdriver Error Reporting

Getting Started

To install stackdriver, use:

go get -u github.com/savaki/stackdriver

Sample

Assuming a credentials file, credentials.json, the following can be used:

package main

import (
	"context"
	"time"

	"github.com/opentracing/opentracing-go"
	"github.com/opentracing/opentracing-go/log"
	"github.com/savaki/stackdriver"
	"google.golang.org/api/option"
)

func main() {
	ctx := context.Background()
	projectID := "your-gcp-project-id"
	tracer, _ := stackdriver.All(ctx, projectID, "service-name", "version",
		option.WithCredentialsFile("credentials.json"),
	)

	opentracing.SetGlobalTracer(tracer)

	span := opentracing.StartSpan("Sample")
	span.LogFields(log.String("message", "recorded to Stackdriver logging"))
	defer span.Finish()

	// stackdriver publishes content asynchronous, need to give it a moment 
	time.Sleep(time.Second * 3) 
}

To Do

  • Implement Span.FinishWithOptions
  • Implement Span.LogKV

About

opentracing stackdriver implementation with support for Stackdriver Trace, Stackdriver Logging, and Stackdriver Error Reporting

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages