@@ -14,16 +14,17 @@ import (
14
14
"github.com/aws/aws-sdk-go-v2/service/cloudwatch"
15
15
"github.com/awslabs/aws-lambda-go-api-proxy/httpadapter"
16
16
grpcreflect "github.com/bufbuild/connect-grpcreflect-go"
17
+ segment "github.com/segmentio/analytics-go/v3"
17
18
"github.com/sirupsen/logrus"
18
19
19
20
"github.com/gitpod-io/leeway/pkg/remotereporter/api/gen/v1/v1connect"
20
21
"github.com/gitpod-io/leeway/tracker/backend/ingestor/handler"
21
22
)
22
23
23
24
var (
24
- listen = flag .String ("listen" , ":8080" , "address to listen on when not running as lambda" )
25
- verbose = flag .Bool ("verbose" , false , "enable verbose logging" )
26
- sampleSink = flag .String ("sample- sink" , "console" , "where to write samples to. Valid values are: console, cloudwatch" )
25
+ listen = flag .String ("listen" , ":8080" , "address to listen on when not running as lambda" )
26
+ verbose = flag .Bool ("verbose" , false , "enable verbose logging" )
27
+ sink = flag .String ("sink" , "console" , "where to write samples to. Valid values are: console, cloudwatch, influxdb, segment " )
27
28
)
28
29
29
30
func main () {
@@ -41,7 +42,7 @@ func main() {
41
42
mux := http .NewServeMux ()
42
43
43
44
var store handler.SampleStorageFunc
44
- switch * sampleSink {
45
+ switch * sink {
45
46
case "console" :
46
47
store = handler .PrintSample
47
48
case "cloudwatch" :
@@ -57,8 +58,11 @@ func main() {
57
58
log .Fatalf ("cannot create InfluxDB client: %v" , err )
58
59
}
59
60
store = handler .WriteToInfluxDB (client , os .Getenv ("INFLUXDB_DATABASE" ))
61
+ case "segment" :
62
+ client := segment .New (os .Getenv ("SEGMENT_KEY" ))
63
+ store = handler .WriteToSegment (client )
60
64
default :
61
- logrus .Fatalf ("unsupported --sample-sink: %s" , * sampleSink )
65
+ logrus .Fatalf ("unsupported --sample-sink: %s" , * sink )
62
66
}
63
67
mux .Handle (v1connect .NewReporterServiceHandler (handler .NewBuildReportHandler (store )))
64
68
0 commit comments