bun

package
v1.67.0-rc.3 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2024 License: Apache-2.0, BSD-3-Clause, Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package bun provides helper functions for tracing the github.com/uptrace/bun package (https://github.com/uptrace/bun).

Example
package main

import (
	"context"
	"database/sql"

	"github.com/uptrace/bun"
	"github.com/uptrace/bun/dialect/sqlitedialect"

	buntrace "gopkg.in/DataDog/dd-trace-go.v1/contrib/uptrace/bun"

	_ "modernc.org/sqlite"
)

func main() {
	sqlite, err := sql.Open("sqlite", "file::memory:?cache=shared")
	if err != nil {
		panic(err)
	}
	db := bun.NewDB(sqlite, sqlitedialect.New())

	// Wrap the connection with the APM hook.
	buntrace.Wrap(db)
	var user struct {
		Name string
	}
	_ = db.NewSelect().Column("name").Table("users").Scan(context.Background(), &user)
}
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Wrap

func Wrap(db *bun.DB, opts ...Option)

Wrap augments the given DB with tracing.

Types

type Option

type Option func(*config)

Option represents an option that can be used to create or wrap a client.

func WithService

func WithService(name string) Option

WithService sets the given service name for the client.

Jump to

Keyboard shortcuts

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