diff --git a/Makefile b/Makefile index 319e0dce..a3259ade 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ build: .PHONY: run run: - docker run --rm --link some-clickhouse-server -it -u ${shell id -u} -v "${PWD}:/data" -e SPAN_STORAGE_TYPE=grpc-plugin jaegertracing/all-in-one:1.24.0 --grpc-storage-plugin.binary=/data/jaeger-clickhouse-$(GOOS)-$(GOARCH) --grpc-storage-plugin.configuration-file=/data/config.yaml + docker run --rm --link some-clickhouse-server -it -u ${shell id -u} -p16686:16686 -p14250:14250 -p14268:14268 -p6831:6831/udp -v "${PWD}:/data" -e SPAN_STORAGE_TYPE=grpc-plugin jaegertracing/all-in-one:1.24.0 --query.ui-config=/data/jaeger-ui.json --grpc-storage-plugin.binary=/data/jaeger-clickhouse-$(GOOS)-$(GOARCH) --grpc-storage-plugin.configuration-file=/data/config.yaml .PHONY: fmt fmt: diff --git a/cmd/jaeger-clickhouse/main.go b/cmd/jaeger-clickhouse/main.go index 8b254fd6..2339f5d0 100644 --- a/cmd/jaeger-clickhouse/main.go +++ b/cmd/jaeger-clickhouse/main.go @@ -35,16 +35,17 @@ func main() { logger.Error("Could not parse config file: %q", err) } - var store shared.PluginServices - s, err := storage.NewStore(logger, cfg, jaegerclickhouse.EmbeddedFiles) + var pluginServices shared.PluginServices + store, err := storage.NewStore(logger, cfg, jaegerclickhouse.EmbeddedFiles) if err != nil { logger.Error("Failed to crate storage", err) os.Exit(1) } - store.Store = s + pluginServices.Store = store + pluginServices.ArchiveStore = store - grpc.Serve(&store) - if err = s.Close(); err != nil { + grpc.Serve(&pluginServices) + if err = store.Close(); err != nil { logger.Error("Failed to close store", "error", err) os.Exit(1) } diff --git a/jaeger-ui.json b/jaeger-ui.json new file mode 100644 index 00000000..1d83d438 --- /dev/null +++ b/jaeger-ui.json @@ -0,0 +1,8 @@ +{ + "dependencies": { + "dagMaxNumServices": 200, + "menuEnabled": true + }, + "archiveEnabled": true +} + diff --git a/sqlscripts/0004-jaeger-spans-archive.sql b/sqlscripts/0004-jaeger-spans-archive.sql new file mode 100644 index 00000000..91edb281 --- /dev/null +++ b/sqlscripts/0004-jaeger-spans-archive.sql @@ -0,0 +1,8 @@ +CREATE TABLE IF NOT EXISTS jaeger_archive_spans_v2 ( + timestamp DateTime CODEC(Delta, ZSTD(1)), + traceID String CODEC(ZSTD(1)), + model String CODEC(ZSTD(3)) +) ENGINE MergeTree() +PARTITION BY toYYYYMM(timestamp) +ORDER BY traceID +SETTINGS index_granularity=1024 diff --git a/storage/store.go b/storage/store.go index 6876efa6..a8c21943 100644 --- a/storage/store.go +++ b/storage/store.go @@ -33,6 +33,7 @@ type Store struct { } var _ shared.StoragePlugin = (*Store)(nil) +var _ shared.ArchiveStoragePlugin = (*Store)(nil) var _ io.Closer = (*Store)(nil) func NewStore(logger hclog.Logger, cfg Configuration, embeddedSQLScripts embed.FS) (*Store, error) { @@ -92,6 +93,11 @@ func initializeDB(db *sql.DB, initSQLScriptsDir string, embeddedScripts embed.FS return err } sqlStatements = append(sqlStatements, string(f)) + f, err = embeddedScripts.ReadFile("sqlscripts/0004-jaeger-spans-archive.sql") + if err != nil { + return err + } + sqlStatements = append(sqlStatements, string(f)) } return executeScripts(sqlStatements, db) } @@ -108,6 +114,14 @@ func (s *Store) DependencyReader() dependencystore.Reader { return clickhousedependencystore.NewDependencyStore() } +func (s *Store) ArchiveSpanReader() spanstore.Reader { + return clickhousespanstore.NewTraceReader(s.db, "", "", "jaeger_archive_spans_v2") +} + +func (s *Store) ArchiveSpanWriter() spanstore.Writer { + return clickhousespanstore.NewSpanWriter(s.logger, s.db, "", "jaeger_archive_spans_v2", clickhousespanstore.Encoding(s.cfg.Encoding), s.cfg.BatchFlushInterval, s.cfg.BatchWriteSize) +} + func (s *Store) Close() error { return s.db.Close() }