Skip to content

Commit

Permalink
Add support for archive storage
Browse files Browse the repository at this point in the history
Signed-off-by: Pavol Loffay <[email protected]>
  • Loading branch information
pavolloffay committed Jul 16, 2021
1 parent 6ea8852 commit 3c150f7
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
11 changes: 6 additions & 5 deletions cmd/jaeger-clickhouse/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
8 changes: 8 additions & 0 deletions jaeger-ui.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"dependencies": {
"dagMaxNumServices": 200,
"menuEnabled": true
},
"archiveEnabled": true
}

8 changes: 8 additions & 0 deletions sqlscripts/0004-jaeger-spans-archive.sql
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions storage/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
}
Expand All @@ -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()
}
Expand Down

0 comments on commit 3c150f7

Please sign in to comment.