The postgres integration provides an opinionated way to interact with PostgreSQL as OLTP database for helix services.

The integration works with all PostgreSQL-compatible databases, such as:

Trace attributes

The postgres integration sets the following trace attributes:

  • postgres.database
  • span.kind

When applicable, these attributes can be set as well:

  • postgres.query
  • postgres.batch.length
  • postgres.transaction.query
  • postgres.transaction.batch.length


postgres.database: "my_db"
postgres.query: "SELECT id, username FROM users;"
span.kind: "server"


The integration uses the jackc/pgx Go library.

Install the Go module with:

$ go get

Simple example on how to import, configure, and use the integration:

import (


func main() {
  cfg := postgres.Config{
    Address:  "",
    Database: "my_db",
    User:     "username",
    Password: "password",

  db, err := postgres.Connect(cfg)
  if err != nil {
    return err

  ctx := context.Background()
  rows, err := db.Query(ctx, "QUERY", args...)
  if err != nil {
    // ...

  defer rows.Close()
  for rows.Next() {
    // ...

  if err := service.Start(); err != nil {

  if err := service.Close(); err != nil {

Is something missing?

If you notice something we've missed or could be improved on, please follow this link and submit a pull request to the repository. Once we merge it, the changes will be reflected on the website the next time it is deployed. Thank you for your contributions!
Built by