forked from open-telemetry/opentelemetry-collector-contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
exporter/clickhouse: use endpoint instead of raw dsn in configuration. (
- Loading branch information
Showing
15 changed files
with
169 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' | ||
change_type: breaking | ||
|
||
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) | ||
component: clickhouseexporter | ||
|
||
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). | ||
note: use endpoint instead of raw dsn in configuration. | ||
|
||
# One or more tracking issues related to the change | ||
issues: [8028] | ||
|
||
# (Optional) One or more lines of additional information to render under the primary note. | ||
# These lines will be padded with 2 spaces and then inserted directly into the document. | ||
# Use pipe (|) for multiline entries. | ||
subtext: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -261,17 +261,17 @@ around 40k/s logs entry per CPU cores, add more collector node can increase line | |
|
||
The following settings are required: | ||
|
||
- `dsn` (no default): The ClickHouse server DSN (Data Source Name), for | ||
example `tcp:https://user:[email protected]:9000/default` | ||
For tcp protocol reference: [ClickHouse/clickhouse-go#dsn](https://github.com/ClickHouse/clickhouse-go#dsn). | ||
For http protocol | ||
reference: [ClickHouse/clickhouse-go#http-support-experimental](https://github.com/ClickHouse/clickhouse-go/tree/main#http-support-experimental) | ||
. | ||
- `endpoint` (no default): The ClickHouse server endpoint, support multi host, for example: | ||
tcp protocol `tcp:https://ip1:port,ip2:port` | ||
http protocol `https://ip:port,ip2:port` | ||
|
||
The following settings can be optionally configured: | ||
|
||
- `ttl_days` (default= 0): The data time-to-live in days, 0 means no ttl. | ||
- `username` (default = ): The authentication username. | ||
- `password` (default = ): The authentication password. | ||
- `ttl_days` (default = 0): The data time-to-live in days, 0 means no ttl. | ||
- `database` (default = otel): The database name. | ||
- `connection_params` (default = {}). Params is the extra connection parameters with map format. for example compression/dial_timeout. | ||
- `logs_table_name` (default = otel_logs): The table name for logs. | ||
- `traces_table_name` (default = otel_traces): The table name for traces. | ||
- `metrics_table_name` (default = otel_metrics): The table name for metrics. | ||
|
@@ -297,7 +297,8 @@ processors: | |
send_batch_size: 100000 | ||
exporters: | ||
clickhouse: | ||
dsn: tcp:https://127.0.0.1:9000/otel | ||
endpoint: tcp:https://127.0.0.1:9000 | ||
database: otel | ||
ttl_days: 3 | ||
logs_table: otel_logs | ||
traces_table: otel_traces | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,7 @@ import ( | |
"go.opentelemetry.io/collector/exporter/exporterhelper" | ||
) | ||
|
||
const defaultDSN = "tcp:https://127.0.0.1:9000/otel" | ||
const defaultEndpoint = "tcp:https://127.0.0.1:9000" | ||
|
||
func TestLoadConfig(t *testing.T) { | ||
t.Parallel() | ||
|
@@ -35,7 +35,7 @@ func TestLoadConfig(t *testing.T) { | |
require.NoError(t, err) | ||
|
||
defaultCfg := createDefaultConfig() | ||
defaultCfg.(*Config).DSN = defaultDSN | ||
defaultCfg.(*Config).Endpoint = defaultEndpoint | ||
|
||
tests := []struct { | ||
id component.ID | ||
|
@@ -49,7 +49,14 @@ func TestLoadConfig(t *testing.T) { | |
{ | ||
id: component.NewIDWithName(typeStr, "full"), | ||
expected: &Config{ | ||
DSN: defaultDSN, | ||
Endpoint: defaultEndpoint, | ||
Database: "otel", | ||
Username: "foo", | ||
Password: "bar", | ||
ConnectionParams: map[string]string{ | ||
"compression": "zstd", | ||
"dial_timeout": "5s", | ||
}, | ||
TTLDays: 3, | ||
LogsTableName: "otel_logs", | ||
TracesTableName: "otel_traces", | ||
|
@@ -92,3 +99,61 @@ func withDefaultConfig(fns ...func(*Config)) *Config { | |
} | ||
return cfg | ||
} | ||
|
||
func TestConfig_buildDSN(t *testing.T) { | ||
type fields struct { | ||
Endpoint string | ||
Username string | ||
Password string | ||
Database string | ||
Params map[string]string | ||
} | ||
type args struct { | ||
database string | ||
} | ||
tests := []struct { | ||
name string | ||
fields fields | ||
args args | ||
want string | ||
wantErr error | ||
}{ | ||
{ | ||
name: "valid config", | ||
fields: fields{ | ||
Endpoint: defaultEndpoint, | ||
Username: "foo", | ||
Password: "bar", | ||
Database: "otel", | ||
Params: map[string]string{ | ||
"compression": "zstd", | ||
}, | ||
}, | ||
args: args{ | ||
database: defaultDatabase, | ||
}, | ||
want: "tcp:https://foo:[email protected]:9000/default?compression=zstd", | ||
}, | ||
{ | ||
name: "invalid config", | ||
fields: fields{ | ||
Endpoint: "127.0.0.1:9000", | ||
}, | ||
wantErr: errConfigInvalidEndpoint, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
cfg := &Config{ | ||
Endpoint: tt.fields.Endpoint, | ||
Username: tt.fields.Username, | ||
Password: tt.fields.Password, | ||
Database: tt.fields.Database, | ||
ConnectionParams: tt.fields.Params, | ||
} | ||
got, err := cfg.buildDSN(tt.args.database) | ||
assert.Equalf(t, tt.wantErr, err, "buildDSN(%v)", tt.args.database) | ||
assert.Equalf(t, tt.want, got, "buildDSN(%v)", tt.args.database) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.