ppmssqldb

package module
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

README

ppmssql

This package instruments the denisenkom/go-mssqldb package.

Installation

$ go get github.com/pinpoint-apm/pinpoint-go-agent/plugin/mssql
import "github.com/pinpoint-apm/pinpoint-go-agent/plugin/mssql"

Usage

PkgGoDev

This package instruments the MS SQL Server driver calls. Use this package's driver in place of the SQL Server driver.

dsn := "server=localhost;user id=sa;password=TestPass123;port=1433;database=TestDB"
db, err := sql.Open("sqlserver-pinpoint", dsn)

It is necessary to pass the context containing the pinpoint.Tracer to all exec and query methods on SQL driver.

ctx := pinpoint.NewContext(context.Background(), tracer)
row, err := db.QueryContext(ctx, "SELECT * FROM Inventory")
import (
    "database/sql"
    "github.com/pinpoint-apm/pinpoint-go-agent"
    _ "github.com/pinpoint-apm/pinpoint-go-agent/plugin/mssql"
)

func query(w http.ResponseWriter, r *http.Request) {
    dsn := "server=localhost;user id=sa;password=TestPass123;port=1433;database=TestDB"
    db, err := sql.Open("sqlserver-pinpoint", dsn)
    defer db.Close()

    rows, _ := db.QueryContext(r.Context(), "SELECT * FROM Inventory")
    for rows.Next() {
        _ = rows.Scan(&id, &name, &quantity)
        fmt.Printf("user: %d, %s, %d\n", id, name, quantity)
    }
    rows.Close()
}

Full Example Source

Documentation

Overview

Package ppmssqldb instruments the denisenkom/go-mssqldb package (https://github.com/denisenkom/go-mssqldb).

This package instruments the MS SQL Server driver calls. Use this package's driver in place of the SQL Server driver.

 dsn := "server=localhost;user id=sa;password=TestPass123;port=1433;database=TestDB"
	db, err := sql.Open("sqlserver-pinpoint", dsn)

It is necessary to pass the context containing the pinpoint.Tracer to all exec and query methods on SQL driver.

ctx := pinpoint.NewContext(context.Background(), tracer)
row, err := db.QueryContext(ctx, "SELECT * FROM Inventory")

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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