zeroshade commented on code in PR #2729: URL: https://github.com/apache/arrow-adbc/pull/2729#discussion_r2073898005
########## go/adbc/driver/internal/driverbase/database.go: ########## @@ -136,4 +201,218 @@ func (db *database) SetLogger(logger *slog.Logger) { } } +func (base *database) InitTracing(ctx context.Context, driverName string, driverVersion string) error { + return base.Base().InitTracing(ctx, driverName, driverVersion) +} + +func (base *DatabaseImplBase) InitTracing(ctx context.Context, driverName string, driverVersion string) (err error) { + fullyQualifiedDriverName := driverNamespace + "." + driverName + + getExporterName := sync.OnceValue(func() string { + return os.Getenv(otelTracesExporter) + }) + exporterName := getExporterName() + + // Empty exporter + if exporterName == "" { + base.Tracer = otel.Tracer(fullyQualifiedDriverName) + return + } + + var ( + exporterType traceExporterType + exporters []sdktrace.SpanExporter + ) + + exporters, exporterType, err = getExporters( + ctx, + exporterName, + base, + driverName, + ) + if err != nil { + return + } + + if len(exporters) < 1 { + // This should not normally happen after a successful call to getExporters, + // but here for completeness + err = base.ErrorHelper.Errorf( + adbc.StatusInvalidState, + "%s '%s'", + DatabaseMessageNoOtelTracesExporters, + exporterType.String(), + ) + return + } + + base.Tracer, err = newTracer(exporters, base, fullyQualifiedDriverName, driverVersion) + if err != nil { + return + } + + return Review Comment: you can eliminate the `if` entirely here, just do `return` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org