diff --git a/factory.go b/factory.go index a14d190..523d8b9 100644 --- a/factory.go +++ b/factory.go @@ -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 +}