Skip to content

Commit c00f28a

Browse files
Gitpod CLI: Improve Segment logging (#19064)
* Gitpod CLI: Improve Segment logging * Set empty logger correctly * Proxy all files in the `static/bin/` folder * copy all files * Revert gzip change and fix proxy dep * Update folder for artefacts
1 parent 4b78a99 commit c00f28a

File tree

5 files changed

+20
-7
lines changed

5 files changed

+20
-7
lines changed

components/ide-proxy/BUILD.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ packages:
55
- "conf/**"
66
- "static/**"
77
deps:
8-
- components/local-app:app
8+
- components/local-app:app-with-manifest
99
argdeps:
1010
- imageRepoBase
1111
config:

components/ide-proxy/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ FROM cgr.dev/chainguard/wolfi-base:latest@sha256:5fd82be4dfccc650c1985d57847f1af
77
RUN apk add brotli gzip
88

99
# Gitpod CLI and Local App
10-
COPY components-local-app--app/bin/* /bin/
10+
COPY components-local-app--app-with-manifest/bin/* /bin/
1111

1212
RUN for FILE in `ls /bin/gitpod-local-companion*`;do \
1313
gzip -v -f -9 -k "$FILE"; \

components/local-app/cmd/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ var rootCmd = &cobra.Command{
9898
if gpctx, err := cfg.GetActiveContext(); err == nil && gpctx != nil {
9999
telemetryEnabled = telemetryEnabled && gpctx.Host.String() == "https://gitpod.io"
100100
}
101-
telemetry.Init(telemetryEnabled, cfg.Telemetry.Identity, constants.Version.String())
101+
telemetry.Init(telemetryEnabled, cfg.Telemetry.Identity, constants.Version.String(), level)
102102
telemetry.RecordCommand(cmd)
103103

104104
if !isVersionCommand(cmd) {

components/local-app/pkg/telemetry/telemetry.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import (
88
"crypto/sha256"
99
"errors"
1010
"fmt"
11+
"io"
12+
"log"
1113
"log/slog"
1214
"math/rand"
1315
"net"
@@ -33,8 +35,8 @@ var opts struct {
3335
client segment.Client
3436
}
3537

36-
// Init initialises the telemetry
37-
func Init(enabled bool, identity, version string) {
38+
// Init initializes the telemetry
39+
func Init(enabled bool, identity, version string, logLevel slog.Level) {
3840
opts.Enabled = enabled
3941
if !enabled {
4042
return
@@ -44,7 +46,18 @@ func Init(enabled bool, identity, version string) {
4446
opts.Identity = identity
4547

4648
if segmentKey != "" {
47-
opts.client = segment.New(segmentKey)
49+
var logger segment.Logger
50+
if logLevel == slog.LevelDebug {
51+
logger = segment.StdLogger(log.New(os.Stderr, "telemetry ", log.LstdFlags))
52+
} else {
53+
// we don't want to log anything
54+
log := log.New(os.Stderr, "telemetry ", log.LstdFlags)
55+
log.SetOutput(io.Discard)
56+
logger = segment.StdLogger(log)
57+
}
58+
opts.client, _ = segment.NewWithConfig(segmentKey, segment.Config{
59+
Logger: logger,
60+
})
4861
}
4962
}
5063

components/proxy/conf/Caddyfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ https://{$GITPOD_DOMAIN} {
336336
}
337337

338338
@ide_bin {
339-
path /static/bin/gitpod-*
339+
path /static/bin/*
340340
}
341341
handle @ide_bin {
342342
import compression

0 commit comments

Comments
 (0)