Skip to content

Commit

Permalink
[Metricbeat] Add a switch to the driver definition on SQL module to u…
Browse files Browse the repository at this point in the history
…se pretty names (#17378)
  • Loading branch information
sayden committed Apr 14, 2020
1 parent 3f50058 commit cddf0c1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Fix "ID" event generator of Google Cloud module {issue}17160[17160] {pull}17608[17608]
- Add privileged option for Auditbeat in Openshift {pull}17637[17637]
- Fix storage metricset to allow config without region/zone. {issue}17623[17623] {pull}17624[17624]
- Add a switch to the driver definition on SQL module to use pretty names {pull}17378[17378]

*Packetbeat*

Expand Down
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
}

0 comments on commit cddf0c1

Please sign in to comment.