Skip to content

Commit 83899a5

Browse files
authored
Merge pull request #4 from ClickHouse/clickhouse-exporter-improvements
inline asyncs
2 parents 8a07ed4 + 14b2b43 commit 83899a5

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

exporter/clickhouseexporter/exporter_logs.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,28 @@ SETTINGS index_granularity=8192, ttl_only_drop_parts = 1;
188188
ResourceAttributes,
189189
LogAttributes
190190
)`
191+
inlineinsertLogsSQLTemplate = `INSERT INTO %s SETTINGS async_insert=1, wait_for_async_insert=0 (
192+
Timestamp,
193+
TraceId,
194+
SpanId,
195+
TraceFlags,
196+
SeverityText,
197+
SeverityNumber,
198+
ServiceName,
199+
Body,
200+
ResourceAttributes,
201+
LogAttributes
202+
) VALUES (
203+
?,
204+
?,
205+
?,
206+
?,
207+
?,
208+
?,
209+
?,
210+
?,
211+
?,
212+
?)`
191213
)
192214

193215
var driverName = "clickhouse" // for testing
@@ -274,5 +296,8 @@ func renderCreateLogsTableSQL(cfg *Config) string {
274296
}
275297

276298
func renderInsertLogsSQL(cfg *Config) string {
299+
if strings.HasPrefix(cfg.Endpoint, "tcp") && cfg.ConnectionParams["async_insert"] == "1" {
300+
return fmt.Sprintf(inlineinsertLogsSQLTemplate, cfg.LogsTableName)
301+
}
277302
return fmt.Sprintf(insertLogsSQLTemplate, cfg.LogsTableName)
278303
}

0 commit comments

Comments
 (0)