add option to inject a sql.DB instance

main v0.1.0-rc4
William Perron 10 months ago
parent ab74c7829a
commit 0e4ba9050f
Signed by: wperron
GPG Key ID: BFDB4EF72D73C5F2

@ -79,3 +79,16 @@ func newSqliteExporter(cfg *Config) (*sqliteExporter, error) {
func NewSqliteSDKTraceExporter(cfg *Config) (sdktrace.SpanExporter, error) {
return newSqliteExporter(cfg)
}
func NewSqliteSDKTraceExporterWithDB(db *sql.DB) (sdktrace.SpanExporter, error) {
tx, _ := db.Begin()
defer tx.Commit()
if _, err := tx.Exec(initScript); err != nil {
return nil, fmt.Errorf("failed to run migrations: %w", err)
}
return &sqliteExporter{
db: db,
}, nil
}

Loading…
Cancel
Save