-
Notifications
You must be signed in to change notification settings - Fork 49
/
main.go
68 lines (58 loc) · 1.8 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package main
import (
"flag"
"net/http"
"os"
"path/filepath"
// Package contains time zone info for connecting to ClickHouse servers with non-UTC time zone
_ "time/tzdata"
hclog "github.com/hashicorp/go-hclog"
"github.com/jaegertracing/jaeger/plugin/storage/grpc"
"github.com/jaegertracing/jaeger/plugin/storage/grpc/shared"
"github.com/prometheus/client_golang/prometheus/promhttp"
yaml "gopkg.in/yaml.v3"
"github.com/jaegertracing/jaeger-clickhouse/storage"
)
func main() {
var configPath string
flag.StringVar(&configPath, "config", "", "The absolute path to the ClickHouse plugin's configuration file")
flag.Parse()
logger := hclog.New(&hclog.LoggerOptions{
Name: "jaeger-clickhouse",
// If this is set to e.g. Warn, the debug logs are never sent to Jaeger even despite
// --grpc-storage-plugin.log-level=debug
Level: hclog.Trace,
JSONFormat: true,
})
cfgFile, err := os.ReadFile(filepath.Clean(configPath))
if err != nil {
logger.Error("Could not read config file", "config", configPath, "error", err)
os.Exit(1)
}
var cfg storage.Configuration
err = yaml.Unmarshal(cfgFile, &cfg)
if err != nil {
logger.Error("Could not parse config file", "error", err)
}
go func() {
http.Handle("/metrics", promhttp.Handler())
err = http.ListenAndServe(cfg.MetricsEndpoint, nil)
if err != nil {
logger.Error("Failed to listen for metrics endpoint", "error", err)
}
}()
var pluginServices shared.PluginServices
store, err := storage.NewStore(logger, cfg)
if err != nil {
logger.Error("Failed to create a storage", err)
os.Exit(1)
}
pluginServices.Store = store
pluginServices.ArchiveStore = store
pluginServices.StreamingSpanWriter = store
grpc.Serve(&pluginServices)
if err = store.Close(); err != nil {
logger.Error("Failed to close store", "error", err)
os.Exit(1)
}
}