go-pg

command module
v0.0.0-...-316a413 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2021 License: BSD-2-Clause Imports: 8 Imported by: 0

README

go-pg OpenTelemetry instrumentation example

PkgGoDev

Quickstart

To install pgotel instrumentation:

go get github.com/go-pg/pg/extra/pgotel/v10

Then add OpenTelemetry hook:

db := pg.Connect(&pg.Options{
    Addr:     "postgresql-server:5432",
    User:     "postgres",
    Database: "example",
})

db.AddQueryHook(pgotel.NewTracingHook())

Example

To run this example you need a PostgreSQL server. You can start one with Docker:

make up

Then run the example:

UPTRACE_DSN="https://<token>@api.uptrace.dev/<project_id>" go run main.go

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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