gormotel

package module
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2021 License: MIT Imports: 10 Imported by: 0

README

gorm-otel

opentelemetry support for gorm2.

Features
  • Record SQL in span logs.
  • Record Result in span logs.
  • Record Table in span tags.
  • Record Error in span tags and logs.
  • Register Create Query Delete Update Row Raw tracing callbacks.
Get Started

I assume that you already have an opentelemetry Tracer client started in your project.

func main() {
	var db *gorm.DB
	
	db.Use(gormotel.New())
	
	// if you want to use customized tracer instead of opentelemetry.GlobalTracer() which is default,
	// you can use the option WithTracer(yourTracer)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(opts ...applyOption) gorm.Plugin

New constructs a new plugin based opentelemetry. It supports to trace all operations in gorm, so if you have already traced your servers, now this plugin will perfect your tracing job.

func WithIgnoreErrNotFound added in v1.0.3

func WithIgnoreErrNotFound(ignoreErrNotFound bool) applyOption

func WithLogResult

func WithLogResult(logResult bool) applyOption

WithLogResult enable otelPlugin to log the result of each executed sql.

func WithSqlParameters

func WithSqlParameters(logSqlParameters bool) applyOption

func WithTracerProvider

func WithTracerProvider(provider trace.TracerProvider) applyOption

WithTracerProvider specifies a tracer provider to use for creating a tracer. If none is specified, the global provider is used.

Types

This section is empty.

Jump to

Keyboard shortcuts

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