Skip to content

Commit be64564

Browse files
committed
feat: Improve telemetry configuration in the app
1 parent acde470 commit be64564

File tree

17 files changed

+104
-74
lines changed

17 files changed

+104
-74
lines changed

.github/workflows/build.yml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ jobs:
3131
needs: [version]
3232
env:
3333
OTEL_ENDPOINT: ${{ secrets.OTEL_ENDPOINT }}
34+
OTEL_HEADER_AUTH: ${{ secrets.OTEL_HEADER_AUTH }}
3435
VITE_MUI_LICENSE: ${{ secrets.VITE_MUI_LICENSE }}
3536
steps:
3637
- name: Code checkout
@@ -59,7 +60,8 @@ jobs:
5960
- name: Build Linux binaries
6061
run: |
6162
node scripts/replace.mjs cmd/shared/constants.go "<version>=>${{ needs.version.outputs.VERSION }}"
62-
node scripts/replace.mjs cmd/shared/constants.go "<otel>=>$OTEL_ENDPOINT"
63+
node scripts/replace.mjs cmd/shared/constants.go "<otel_endpoint>=>$OTEL_ENDPOINT"
64+
node scripts/replace.mjs cmd/shared/constants.go "<otel_auth>=>$OTEL_HEADER_AUTH"
6365
node scripts/replace.mjs cmd/shared/constants.go "EnvDevelopment=>EnvProduction"
6466
task package oses=linux archs=amd64
6567
@@ -74,6 +76,7 @@ jobs:
7476
needs: [version]
7577
env:
7678
OTEL_ENDPOINT: ${{ secrets.OTEL_ENDPOINT }}
79+
OTEL_HEADER_AUTH: ${{ secrets.OTEL_HEADER_AUTH }}
7780
VITE_MUI_LICENSE: ${{ secrets.VITE_MUI_LICENSE }}
7881
steps:
7982
- name: Code checkout
@@ -102,7 +105,8 @@ jobs:
102105
- name: Build Linux binaries
103106
run: |
104107
node scripts/replace.mjs cmd/shared/constants.go "<version>=>${{ needs.version.outputs.VERSION }}"
105-
node scripts/replace.mjs cmd/shared/constants.go "<otel>=>$OTEL_ENDPOINT"
108+
node scripts/replace.mjs cmd/shared/constants.go "<otel_endpoint>=>$OTEL_ENDPOINT"
109+
node scripts/replace.mjs cmd/shared/constants.go "<otel_auth>=>$OTEL_HEADER_AUTH"
106110
node scripts/replace.mjs cmd/shared/constants.go "EnvDevelopment=>EnvProduction"
107111
task package oses=linux archs=arm64
108112
@@ -117,6 +121,7 @@ jobs:
117121
needs: [version]
118122
env:
119123
OTEL_ENDPOINT: ${{ secrets.OTEL_ENDPOINT }}
124+
OTEL_HEADER_AUTH: ${{ secrets.OTEL_HEADER_AUTH }}
120125
VITE_MUI_LICENSE: ${{ secrets.VITE_MUI_LICENSE }}
121126
steps:
122127
- name: Code checkout
@@ -140,7 +145,8 @@ jobs:
140145
- name: Build MacOS binaries
141146
run: |
142147
node scripts/replace.mjs cmd/shared/constants.go "<version>=>${{ needs.version.outputs.VERSION }}"
143-
node scripts/replace.mjs cmd/shared/constants.go "<otel>=>$OTEL_ENDPOINT"
148+
node scripts/replace.mjs cmd/shared/constants.go "<otel_endpoint>=>$OTEL_ENDPOINT"
149+
node scripts/replace.mjs cmd/shared/constants.go "<otel_auth>=>$OTEL_HEADER_AUTH"
144150
node scripts/replace.mjs cmd/shared/constants.go "EnvDevelopment=>EnvProduction"
145151
task package oses=darwin archs='amd64 arm64'
146152
@@ -155,6 +161,7 @@ jobs:
155161
needs: [version]
156162
env:
157163
OTEL_ENDPOINT: ${{ secrets.OTEL_ENDPOINT }}
164+
OTEL_HEADER_AUTH: ${{ secrets.OTEL_HEADER_AUTH }}
158165
VITE_MUI_LICENSE: ${{ secrets.VITE_MUI_LICENSE }}
159166
steps:
160167
- name: Code checkout
@@ -181,7 +188,8 @@ jobs:
181188
- name: Build Windows binaries
182189
run: |
183190
node scripts/replace.mjs cmd/shared/constants.go "<version>=>${{ needs.version.outputs.VERSION }}"
184-
node scripts/replace.mjs cmd/shared/constants.go "<otel>=>$OTEL_ENDPOINT"
191+
node scripts/replace.mjs cmd/shared/constants.go "<otel_endpoint>=>$OTEL_ENDPOINT"
192+
node scripts/replace.mjs cmd/shared/constants.go "<otel_auth>=>$OTEL_HEADER_AUTH"
185193
node scripts/replace.mjs cmd/shared/constants.go "EnvDevelopment=>EnvProduction"
186194
task package oses=windows archs=amd64
187195
@@ -196,6 +204,7 @@ jobs:
196204
needs: [version]
197205
env:
198206
OTEL_ENDPOINT: ${{ secrets.OTEL_ENDPOINT }}
207+
OTEL_HEADER_AUTH: ${{ secrets.OTEL_HEADER_AUTH }}
199208
VITE_MUI_LICENSE: ${{ secrets.VITE_MUI_LICENSE }}
200209
steps:
201210
- name: Code checkout
@@ -236,7 +245,8 @@ jobs:
236245
CXX: aarch64-w64-mingw32-g++
237246
run: |
238247
node scripts/replace.mjs cmd/shared/constants.go "<version>=>${{ needs.version.outputs.VERSION }}"
239-
node scripts/replace.mjs cmd/shared/constants.go "<otel>=>$OTEL_ENDPOINT"
248+
node scripts/replace.mjs cmd/shared/constants.go "<otel_endpoint>=>$OTEL_ENDPOINT"
249+
node scripts/replace.mjs cmd/shared/constants.go "<otel_auth>=>$OTEL_HEADER_AUTH"
240250
node scripts/replace.mjs cmd/shared/constants.go "EnvDevelopment=>EnvProduction"
241251
task package oses=windows archs=arm64
242252

cmd/cli/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ require (
99
github.com/samber/lo v1.52.0
1010
github.com/sirupsen/logrus v1.9.3
1111
github.com/urfave/cli/v2 v2.27.7
12-
github.com/vegidio/go-sak v0.0.0-20251231095403-269ef6b33bb6
12+
github.com/vegidio/go-sak v0.0.0-20260222095309-3fc413b07da0
1313
github.com/vegidio/umd v0.0.0-20250918022752-c66c1259c887
1414
)
1515

cmd/cli/go.sum

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu
132132
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
133133
github.com/urfave/cli/v2 v2.27.7 h1:bH59vdhbjLv3LAvIu6gd0usJHgoTTPhCFib8qqOwXYU=
134134
github.com/urfave/cli/v2 v2.27.7/go.mod h1:CyNAG/xg+iAOg0N4MPGZqVmv2rCoP267496AOXUZjA4=
135-
github.com/vegidio/go-sak v0.0.0-20251231095403-269ef6b33bb6 h1:9HcDcvhox+yWpBN0j4O4pkBQBE0D1MeJ4VH7raXua7o=
135+
github.com/vegidio/go-sak v0.0.0-20260222095309-3fc413b07da0 h1:2GHf9bITTN2RumCZ2h4qk9N5xgpxBG5aOE16eeRSRBE=
136136
github.com/vegidio/umd v0.0.0-20250918022752-c66c1259c887 h1:GjRjolcR3c2UwIjKrJ/uVI6Q0w9Mdva0DKl+Lb+K5PU=
137137
github.com/vegidio/umd v0.0.0-20250918022752-c66c1259c887/go.mod h1:amUjKHQQjnSH4G4S60XE1TSzYTCCMbH4P0vYVthwDN0=
138138
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=

cmd/cli/umd.go

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,16 @@ func startQuery(
2222
noTelemetry bool,
2323
cookies []fetch.Cookie,
2424
) error {
25-
tel := o11y.NewTelemetry(shared.OtelEndpoint, "umd", shared.Version, shared.OtelEnvironment, !noTelemetry)
26-
defer tel.Close()
25+
otel := o11y.NewTelemetry(
26+
shared.OtelEndpoint,
27+
"umd",
28+
shared.Version,
29+
map[string]string{"Authorization": shared.OtelAuth},
30+
shared.OtelEnvironment,
31+
!noTelemetry,
32+
)
33+
34+
defer otel.Close()
2735

2836
fields := make(map[string]any)
2937
var resp *umd.Response
@@ -47,7 +55,7 @@ func startQuery(
4755

4856
extractor, err := u.FindExtractor(url)
4957
if err != nil {
50-
tel.LogError("Extractor not found", fields, err)
58+
otel.LogError("Extractor not found", fields, err)
5159
return err
5260
}
5361

@@ -57,7 +65,7 @@ func startQuery(
5765
source, err := extractor.SourceType()
5866
if err != nil {
5967
fmt.Printf("\n\n")
60-
tel.LogError("Source type not found", fields, err)
68+
otel.LogError("Source type not found", fields, err)
6169
return err
6270
}
6371

@@ -78,15 +86,15 @@ func startQuery(
7886
}
7987

8088
fields["cache"] = resp != nil
81-
tel.LogInfo("Start download", fields)
89+
otel.LogInfo("Start download", fields)
8290

8391
// nil means that nothing was found in the cache
8492
if resp == nil {
8593
resp, _ = extractor.QueryMedia(limit, extensions, true)
8694

8795
err = charm.StartSpinner(source.Type(), source.Name(), resp)
8896
if err != nil {
89-
tel.LogError("Error while querying media", fields, err)
97+
otel.LogError("Error while querying media", fields, err)
9098
return err
9199
}
92100

@@ -100,7 +108,7 @@ func startQuery(
100108
result := shared.DownloadAll(resp.Media, fullDir, parallel)
101109
responses, err := charm.StartProgress(result, len(resp.Media))
102110
if err != nil {
103-
tel.LogError("Error while downloading media", fields, err)
111+
otel.LogError("Error while downloading media", fields, err)
104112
return err
105113
}
106114

@@ -121,7 +129,7 @@ func startQuery(
121129
charm.PrintDeleted(fileName)
122130
})
123131

124-
tel.LogInfo("End download", fields)
132+
otel.LogInfo("End download", fields)
125133

126134
shared.CreateReport(fullDir, remaining)
127135

cmd/gui/app.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ import (
88

99
// App struct
1010
type App struct {
11-
ctx context.Context
12-
tel *o11y.Telemetry
11+
ctx context.Context
12+
otel *o11y.Telemetry
1313
}
1414

1515
// NewApp creates a new App application struct
16-
func NewApp(tel *o11y.Telemetry) *App {
17-
return &App{tel: tel}
16+
func NewApp(otel *o11y.Telemetry) *App {
17+
return &App{otel: otel}
1818
}
1919

2020
// startup is called when the app starts. The context is saved

cmd/gui/binding.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func (a *App) QueryMedia(
3939

4040
cookies, err := shared.GetCookies(cookiesType, cookiesLocation)
4141
if err != nil {
42-
a.tel.LogError("Failed to get cookies", fields, err)
42+
a.otel.LogError("Failed to get cookies", fields, err)
4343
return nil, err
4444
}
4545

@@ -57,7 +57,7 @@ func (a *App) QueryMedia(
5757

5858
extractor, err := u.FindExtractor(url)
5959
if err != nil {
60-
a.tel.LogError("Extractor not found", fields, err)
60+
a.otel.LogError("Extractor not found", fields, err)
6161
return nil, err
6262
}
6363

@@ -67,7 +67,7 @@ func (a *App) QueryMedia(
6767

6868
source, err := extractor.SourceType()
6969
if err != nil {
70-
a.tel.LogError("Source type not found", fields, err)
70+
a.otel.LogError("Source type not found", fields, err)
7171
return nil, err
7272
}
7373

@@ -90,7 +90,7 @@ func (a *App) QueryMedia(
9090
fields["cache"] = resp != nil
9191

9292
if enableTelemetry {
93-
a.tel.LogInfo("Start download", fields)
93+
a.otel.LogInfo("Start download", fields)
9494
}
9595

9696
// nil means that nothing was found in the cache
@@ -101,7 +101,7 @@ func (a *App) QueryMedia(
101101
a.OnMediaQueried(total)
102102
})
103103
if err != nil {
104-
a.tel.LogError("Error while querying media", fields, err)
104+
a.otel.LogError("Error while querying media", fields, err)
105105
return nil, err
106106
}
107107

@@ -187,7 +187,7 @@ func (a *App) StartDownload(media []umd.Media, directory string, parallel int, e
187187
shared.CreateReport(fullDir, remaining)
188188

189189
if enableTelemetry {
190-
a.tel.LogInfo("End download", fields)
190+
a.otel.LogInfo("End download", fields)
191191
}
192192

193193
return downloads

cmd/gui/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require (
66
github.com/samber/lo v1.52.0
77
github.com/sirupsen/logrus v1.9.3
88
github.com/spf13/afero v1.15.0
9-
github.com/vegidio/go-sak v0.0.0-20251231095403-269ef6b33bb6
9+
github.com/vegidio/go-sak v0.0.0-20260222095309-3fc413b07da0
1010
github.com/vegidio/umd v0.0.0-20250918022752-c66c1259c887
1111
github.com/wailsapp/wails/v2 v2.10.2
1212
)

cmd/gui/go.sum

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,7 @@ github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6Kllzaw
134134
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
135135
github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo=
136136
github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
137-
github.com/vegidio/go-sak v0.0.0-20251231095403-269ef6b33bb6 h1:9HcDcvhox+yWpBN0j4O4pkBQBE0D1MeJ4VH7raXua7o=
138-
github.com/vegidio/go-sak v0.0.0-20251231095403-269ef6b33bb6/go.mod h1:UlZVJKCyXZTW30FJtjiDUPGtgGqXUc/s0Y4JBeJVmjQ=
137+
github.com/vegidio/go-sak v0.0.0-20260222095309-3fc413b07da0 h1:2GHf9bITTN2RumCZ2h4qk9N5xgpxBG5aOE16eeRSRBE=
139138
github.com/vegidio/umd v0.0.0-20250918022752-c66c1259c887 h1:GjRjolcR3c2UwIjKrJ/uVI6Q0w9Mdva0DKl+Lb+K5PU=
140139
github.com/vegidio/umd v0.0.0-20250918022752-c66c1259c887/go.mod h1:amUjKHQQjnSH4G4S60XE1TSzYTCCMbH4P0vYVthwDN0=
141140
github.com/wailsapp/go-webview2 v1.0.21 h1:k3dtoZU4KCoN/AEIbWiPln3P2661GtA2oEgA2Pb+maA=

cmd/gui/main.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,19 @@ func main() {
2121
// Disable logging
2222
log.SetOutput(io.Discard)
2323

24-
tel := o11y.NewTelemetry(shared.OtelEndpoint, "umd", shared.Version, shared.OtelEnvironment, true)
25-
defer tel.Close()
24+
otel := o11y.NewTelemetry(
25+
shared.OtelEndpoint,
26+
"umd",
27+
shared.Version,
28+
map[string]string{"Authorization": shared.OtelAuth},
29+
shared.OtelEnvironment,
30+
true,
31+
)
32+
33+
defer otel.Close()
2634

2735
// Create an instance of the app structure
28-
app := NewApp(tel)
36+
app := NewApp(otel)
2937

3038
// Create an application with options
3139
err := wails.Run(&options.App{
@@ -46,7 +54,7 @@ func main() {
4654
})
4755

4856
if err != nil {
49-
tel.LogError("Error running the app", nil, err)
57+
otel.LogError("Error running the app", nil, err)
5058
log.Error("Error:", err)
5159
}
5260
}

cmd/playground/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module playground
22

33
go 1.25.4
44

5-
require github.com/vegidio/go-sak v0.0.0-20251231095403-269ef6b33bb6
5+
require github.com/vegidio/go-sak v0.0.0-20260222095309-3fc413b07da0
66

77
require (
88
github.com/Velocidex/json v0.0.0-20220224052537-92f3c0326e5a // indirect

0 commit comments

Comments
 (0)