Open
Description
Component(s)
receiver/sqlquery
Is your feature request related to a problem? Please describe.
If you have a datasource URL where you want to embed a secret like ${env:PASSWORD}
, if that embedded password has URL-unsafe characters there is no way for them to be escaped.
Describe the solution you'd like
A config option like Correctly noted below that this solution is infeasible. I've adjusted the description and removed the feature request. This needs a deeper solution.url_encode_datasource
(name up for debate) that will URL encode the resulting datasource before creating a NewPool.
Describe alternatives you've considered
No response
Additional context
My silly reproduction is as follows:
Patch:
diff --git a/receiver/sqlqueryreceiver/receiver.go b/receiver/sqlqueryreceiver/receiver.go
index 54f0834b2b..50955fba4d 100644
--- a/receiver/sqlqueryreceiver/receiver.go
+++ b/receiver/sqlqueryreceiver/receiver.go
@@ -6,6 +6,7 @@ package sqlqueryreceiver // import "github.com/open-telemetry/opentelemetry-coll
import (
"context"
"fmt"
+ "log"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/consumer"
@@ -39,6 +40,7 @@ func createMetricsReceiverFunc(sqlOpenerFunc sqlquery.SQLOpenerFunc, clientProvi
) (receiver.Metrics, error) {
sqlCfg := cfg.(*Config)
var opts []scraperhelper.ControllerOption
+ log.Fatal(sqlCfg.DataSource)
pool := internal.NewPool(sqlOpenerFunc, sqlCfg.Driver, sqlCfg.DataSource, sqlCfg.MaxOpenConn)
Config:
receivers:
sqlquery:
collection_interval: 60s
datasource: oracle://sys:${env:PASSWORD}@myhost.domain:1111
driver: oracle
queries:
- metrics:
- attribute_columns:
- DATABASE_ID
- GLOBAL_NAME
- TABLESPACE_NAME
- CONTENTS
data_type: sum
description: The size of tablespaces in the database.
metric_name: oracle.tablespace.size
monotonic: false
static_attributes:
db.system: oracle
state: free
unit: by
value_column: FREE_SPACE
value_type: int
sql: "Robert); DROP TABLE Students;"
exporters:
nop:
service:
pipelines:
metrics:
receivers: [sqlquery]
exporters: [nop]
Result:
braydonk@bk:~/Git/opentelemetry-collector-contrib$ PASSWORD="my&p|a/s@s" ./bin/otelcontribcol_linux_amd64 --config config.yaml
2025-05-16T13:13:09.923Z info [email protected]/service.go:199 Setting up own telemetry... {"resource": {}}
2025/05/16 13:13:09 oracle://sys:my&p|a/s@[email protected]:1111