Documentation
¶
Overview ¶
Package instapgx provides Instana instrumentation for pgx/v5 package.
Example (BasicUsage) ¶
urlExample := "postgres://postgres:mysecretpassword@localhost:5432/postgres" cfg, err := pgx.ParseConfig(urlExample) // Initialising Instana Collector c := instana.InitCollector(&instana.Options{ Service: "pgx-v5-service", }) // Assigning the Instana tracer to the cfg.Tracer interface cfg.Tracer = instapgx.InstanaTracer(cfg, c) // Use the cfg in the normal way to create a connection and use it ctx := context.Background() var conn *pgx.Conn conn, err = pgx.ConnectConfig(ctx, cfg) if err != nil { fmt.Printf("unable to connect to database: %v\n\n", err) os.Exit(1) } else { fmt.Println("connection successful") } defer func() { err := conn.Close(ctx) if err != nil { fmt.Printf("unable to close connection: %v\n", err) } }() var val string query := "<valid-query>" err = conn.QueryRow(ctx, query).Scan(&val) if err != nil { fmt.Printf("queryRow failed: %v\n\n", err) os.Exit(1) }
Output:
Index ¶
Examples ¶
Constants ¶
View Source
const Version = "2.10.0"
Version is the instrumentation module semantic version
Variables ¶
This section is empty.
Functions ¶
func InstanaTracer ¶
func InstanaTracer(cfg *pgx.ConnConfig, collector instana.TracerLogger) pgx.QueryTracer
InstanaTracer returns Instana tracer which can be used for instrumenting pgx/v5 database calls.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.