gormtracer

package module
v0.0.0-...-59501a0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2020 License: MIT Imports: 4 Imported by: 0

README

gormtracer

A gorm plugin for opentracing.

gormtracer only works with GORM 2.0 (gorm.io/gorm)

Usage

import (
	"github.com/opentracing/opentracing-go"
	"gorm.io/gorm"

	"github.com/kamingchan/gormtracer"
)

func main() {
	// set a tracer
	opentracing.SetGlobalTracer(YourTracer)
	// initialize db session
	db, err := gorm.Open(YourDialector, Config)
	if err != nil {
		// handle error
	}
	// initialize gormtracer
	db.Use(gormtracer.NewGormTracer())

	// happy hacking...
	// db.Where("age > ?", 18).Find()
}

Documentation

Index

Constants

View Source
const (
	HookBefore = "opentracing:startSpan"
	HookAfter  = "opentracing:finishSpan"

	OperationName = "MySQL"

	InstanceSpanKey = "opentracing-span"

	KeyRowsAffected = "db.rows_affected"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type GormTracer

type GormTracer struct {
}

func NewGormTracer

func NewGormTracer() *GormTracer

func (*GormTracer) Initialize

func (g *GormTracer) Initialize(db *gorm.DB) error

func (*GormTracer) Name

func (g *GormTracer) Name() string

Jump to

Keyboard shortcuts

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