Skip to content
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

[Metricbeat] Add a switch to the driver definition on SQL module to use pretty names #17378

Merged
Merged
Changes from 1 commit
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
12 changes: 11 additions & 1 deletion x-pack/metricbeat/module/sql/query/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (m *MetricSet) Fetch(ctx context.Context, report mb.ReporterV2) error {
// DB gets a client ready to query the database
func (m *MetricSet) DB() (*sqlx.DB, error) {
if m.db == nil {
db, err := sqlx.Open(m.Driver, m.HostData().URI)
db, err := sqlx.Open(switchDriverName(m.Driver), m.HostData().URI)
if err != nil {
return nil, errors.Wrap(err, "opening connection")
}
Expand Down Expand Up @@ -251,3 +251,13 @@ func (m *MetricSet) Close() error {
}
return errors.Wrap(m.db.Close(), "closing connection")
}

// switchDriverName switches between driver name and a pretty name for a driver. For example, 'oracle' driver is called
// 'godror' so this detail implementation must be hidden to the user, that should only choose and see 'oracle' as driver
func switchDriverName(d string) string {
if d == "oracle" {
return "godror"
}

return d
}