@@ -14,16 +14,17 @@ import (
1414 "github.com/aws/aws-sdk-go-v2/service/cloudwatch"
1515 "github.com/awslabs/aws-lambda-go-api-proxy/httpadapter"
1616 grpcreflect "github.com/bufbuild/connect-grpcreflect-go"
17+ segment "github.com/segmentio/analytics-go/v3"
1718 "github.com/sirupsen/logrus"
1819
1920 "github.com/gitpod-io/leeway/pkg/remotereporter/api/gen/v1/v1connect"
2021 "github.com/gitpod-io/leeway/tracker/backend/ingestor/handler"
2122)
2223
2324var (
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 " )
2728)
2829
2930func main () {
@@ -41,7 +42,7 @@ func main() {
4142 mux := http .NewServeMux ()
4243
4344 var store handler.SampleStorageFunc
44- switch * sampleSink {
45+ switch * sink {
4546 case "console" :
4647 store = handler .PrintSample
4748 case "cloudwatch" :
@@ -57,8 +58,11 @@ func main() {
5758 log .Fatalf ("cannot create InfluxDB client: %v" , err )
5859 }
5960 store = handler .WriteToInfluxDB (client , os .Getenv ("INFLUXDB_DATABASE" ))
61+ case "segment" :
62+ client := segment .New (os .Getenv ("SEGMENT_KEY" ))
63+ store = handler .WriteToSegment (client )
6064 default :
61- logrus .Fatalf ("unsupported --sample-sink: %s" , * sampleSink )
65+ logrus .Fatalf ("unsupported --sample-sink: %s" , * sink )
6266 }
6367 mux .Handle (v1connect .NewReporterServiceHandler (handler .NewBuildReportHandler (store )))
6468
0 commit comments