MCPcopy Create free account
hub / github.com/go-gorm/opentelemetry

github.com/go-gorm/opentelemetry @v0.1.16

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.1.16 ↗ · + Follow
147 symbols 406 edges 17 files ⚖ MIT 32 documented · 22% 23 cross-repo links updated 6d agov0.1.16 · 2025-07-18★ 1379 open issues

Browse by type

Functions 122 Types & classes 25
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

opentelemetry

Opentelemetry for gorm

Feature

Tracing

  • support tracing gorm by Hook Create Query Delete Update Row Raw

Metrics

  • Collect DB Status

Logging

  • Use logrus replace gorm default logger
  • Use hook to report span message

Provider

  • Out-of-the-box default opentelemetry provider
  • Support setting via environment variables

How to Use ?

Set logger

package main

import(
    "gorm.io/gorm/logger"
    "gorm.io/plugin/opentelemetry/logging/logrus"
)

func init(){
    logger := logger.New(
        logrus.NewWriter(),
        logger.Config{
            SlowThreshold: time.Millisecond,
            LogLevel:      logger.Warn,
            Colorful:      false,
        },
    )
    db, err := gorm.Open(sqlite.Open("file::memory:?cache=shared"),&gorm.Config{Logger: logger})
}

Set tracing and metrics

package main

import(
    "gorm.io/plugin/opentelemetry/tracing"
)

func init(){

    db, err := gorm.Open(sqlite.Open("file::memory:?cache=shared"), &gorm.Config{})
    if err != nil {
        panic(err)
    }

    if err := db.Use(tracing.NewPlugin()); err != nil {
        panic(err)
    }
}

Set only tracing

package main

import(
    "gorm.io/plugin/opentelemetry/tracing"
)

func init(){

    db, err := gorm.Open(sqlite.Open("file::memory:?cache=shared"), &gorm.Config{})
    if err != nil {
        panic(err)
    }

    if err := db.Use(tracing.NewPlugin(tracing.WithoutMetrics())); err != nil {
        panic(err)
    }
}

More info

See examples

Extension points exported contracts — how you extend this code

browse all types & interfaces →

Core symbols most depended-on inside this repo

browse all functions →

Shape

Function 74
Method 48
Struct 15
FuncType 5
Interface 5

Languages

Go100%

Modules by API surface

logging/logrus/logger.go26 symbols
provider/options.go19 symbols
tracing/tracing.go15 symbols
logging/slog/option.go13 symbols
logging/logrus/option.go12 symbols
tracing/option.go9 symbols
provider/provider.go7 symbols
logging/slog/handler.go7 symbols
examples/metric/metrics/main.go7 symbols
logging/slog/logger.go6 symbols
tracing/tracing_test.go5 symbols
logging/slog/logger_test.go5 symbols

For agents

$ claude mcp add opentelemetry \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page