This repository has been archived by the owner on Jan 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
85 lines (67 loc) · 1.99 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package main
import (
"context"
"log"
"os"
"github.com/johanneswuerbach/jaeger-s3/plugin"
pConfig "github.com/johanneswuerbach/jaeger-s3/plugin/config"
"github.com/ory/viper"
"github.com/spf13/pflag"
hclog "github.com/hashicorp/go-hclog"
"github.com/jaegertracing/jaeger/plugin/storage/grpc"
"github.com/jaegertracing/jaeger/plugin/storage/grpc/shared"
"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/service/athena"
"github.com/aws/aws-sdk-go-v2/service/s3"
)
const (
loggerName = "jaeger-s3"
)
func main() {
logLevel := os.Getenv("GRPC_STORAGE_PLUGIN_LOG_LEVEL")
if logLevel == "" {
logLevel = hclog.Warn.String()
}
logger := hclog.New(&hclog.LoggerOptions{
Level: hclog.LevelFromString(logLevel),
Name: loggerName,
JSONFormat: true,
})
var configPath string
pflag.StringVar(&configPath, "config", "", "A path to the s3 plugin's configuration file")
pflag.Parse()
if err := viper.BindPFlags(pflag.CommandLine); err != nil {
log.Fatalf("unable bind flags, %v", err)
}
if configPath != "" {
viper.SetConfigFile(configPath)
if err := viper.ReadInConfig(); err != nil {
log.Fatalf("error reading config file, %v", err)
}
}
var configuration pConfig.Configuration
err := viper.Unmarshal(&configuration)
if err != nil {
log.Fatalf("unable to decode into struct, %v", err)
}
logger.Debug("plugin starting ...", configuration)
ctx := context.TODO()
cfg, err := config.LoadDefaultConfig(ctx, func(lo *config.LoadOptions) error {
return nil
})
if err != nil {
log.Fatalf("unable to load SDK config, %v", err)
}
s3Svc := s3.NewFromConfig(cfg)
athenaSvc := athena.NewFromConfig(cfg)
logger.Debug("plugin configured")
s3Plugin, err := plugin.NewS3Plugin(ctx, logger, s3Svc, configuration.S3, athenaSvc, configuration.Athena)
if err != nil {
log.Fatalf("unable to create plugin, %v", err)
}
logger.Debug("plugin created")
grpc.Serve(&shared.PluginServices{
Store: s3Plugin,
StreamingSpanWriter: s3Plugin,
})
}