sqltracer

package
v0.0.0-...-e7e7091 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

sqltracer implements a sql driver that wraps the original driver and adds Sentry tracing capabilities to all queries. The trace is valid if there is a parent span exists in the context.

Please note that when initializing the sqltracer, you will need to specify the `sqltracer.WithDatabaseSystem` option, so that Sentry will picks up the span as a correct query trace.

Example with "github.com/go-sql-driver/mysql" package.

package main

import "github.com/go-sql-driver/mysql"
import "github.com/aldy505/sentry-integration/sqltracer"

func main() {
	sql.Register("sentrymysql", sqltracer.NewSentrySql(&mysql.MySQLDriver{}, sqltracer.WithDatabaseSystem("mysql"), sqltracer.WithDatabaseName("mydb"), sqltracer.WithServerAddress("localhost", "3306")))

	db, err := sql.Open("sentrymysql", "username:password@protocol(address)/dbname?param=value")
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSentrySql

func NewSentrySql(driver driver.Driver, options ...SentrySqlTracerOption) driver.Driver

func NewSentrySqlConnector

func NewSentrySqlConnector(connector driver.Connector, options ...SentrySqlTracerOption) driver.Connector

Types

type SentrySqlTracerOption

type SentrySqlTracerOption func(*sentrySqlConfig)

func WithDatabaseName

func WithDatabaseName(name string) SentrySqlTracerOption

func WithDatabaseSystem

func WithDatabaseSystem(system string) SentrySqlTracerOption

func WithServerAddress

func WithServerAddress(address string, port string) SentrySqlTracerOption

Jump to

Keyboard shortcuts

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