8000 Fixed otel error in case of Supabase Dialect by coolwednesday · Pull Request #1841 · gofr-dev/gofr · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fixed otel error in case of Supabase Dialect #1841

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 12, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion pkg/gofr/datasource/sql/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ func NewSQL(configs config.Config, logger datasource.Logger, metrics Metrics) *D

logger.Debugf("registering sql dialect '%s' for traces", dbConfig.Dialect)

otelRegisteredDialect, err := otelsql.Register(dbConfig.Dialect)
otelRegisteredDialect, err := registerOtel(dbConfig.Dialect)

if err != nil {
logger.Errorf("could not register sql dialect '%s' for traces, error: %s", dbConfig.Dialect, err)
return nil
Expand Down Expand Up @@ -105,6 +106,18 @@ func NewSQL(configs config.Config, logger datasource.Logger, metrics Metrics) *D
return database
}

func registerOtel(dialect string) (string, error) {
// Supabase uses the PostgreSQL driver, so we register it as the "postgres" dialect
// to ensure compatibility with OpenTelemetry instrumentation.
otelSupportedDialect := dialect

if dialect == supabaseDialect {
otelSupportedDialect = dialectPostgres
}

return otelsql.Register(otelSupportedDialect)
}

func pingToTestConnection(database *DB) *DB {
if err := database.DB.Ping(); err != nil {
printConnectionFailureLog("connect", database.config, database.logger, err)
Expand Down
Loading
0