Version: v0.0.0-...-cfeac3e Latest Latest

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

Go to latest
Published: Oct 15, 2020 License: MIT Imports: 7 Imported by: 0




View Source
const (
	QueryAttribute = "gorm.query"
	TableAttribute = "gorm.table"

Attributes recorded on the span for the queries.


View Source
var (
	// Operation is the type of query (SELECT, INSERT, UPDATE, DELETE)
	Operation, _ = tag.NewKey("gorm.operation")

	// Table name of the target database table
	Table, _ = tag.NewKey("gorm.table")

Tags applied to measures

View Source
var (
	QueryCount = stats.Int64("opencensus.io/gorm/query_count", "Number of queries started", stats.UnitDimensionless)


View Source
var (
	QueryCountView = &view.View{
		Name:        "opencensus.io/gorm/query_count",
		Description: "Count of queries started",
		TagKeys:     []tag.Key{Operation, Table},
		Measure:     QueryCount,
		Aggregation: view.Count(),


func RegisterCallbacks

func RegisterCallbacks(db *gorm.DB, opts ...Option)

RegisterCallbacks registers the necessary callbacks in Gorm's hook system for instrumentation.

func WithContext

func WithContext(ctx context.Context, db *gorm.DB) *gorm.DB

WithContext sets the current context in the db instance for instrumentation.


type AllowRoot

type AllowRoot bool

AllowRoot allows creating root spans in the absence of existing spans.

type DefaultAttributes

type DefaultAttributes []trace.Attribute

DefaultAttributes sets attributes to each span.

type Option

type Option interface {
	// contains filtered or unexported methods

Option allows for managing ocgorm configuration using functional options.

func StartOptions

func StartOptions(o trace.StartOptions) Option

StartOptions configures the initial options applied to a span.

type OptionFunc

type OptionFunc func(c *callbacks)

OptionFunc converts a regular function to an Option if it's definition is compatible.

type Query

type Query bool

Query allows recording the sql queries in spans.

Jump to

Keyboard shortcuts

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