Skip to content

Commit b29d025

Browse files
fix: macos telemetry (#53)
* check macos logging is working via otel Removed transformation and updated logs from local to signoz, which is working. Keeping this as a save point. * fix: mac telemetry otel collector format Format data same as linux. * add to release-testing.yaml * switch to github runner * capture /System/Volumes/Data and other non os vols * only consider used memory buffer and cached should be ignored * add debug log files * chore: revert the debug files
1 parent 36461e4 commit b29d025

File tree

8 files changed

+204
-114
lines changed

8 files changed

+204
-114
lines changed

.github/workflows/release-testing.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ name: Branch Build and Upload to R2
33
on:
44
push:
55
branches:
6-
- "obs"
7-
- feat-transparent-cache
6+
- "prashant-warp-740"
87

98
env:
109
AWS_ACCESS_KEY_ID: ${{ secrets.WB_PACKAGES_DEV_R2_ACCESS_KEY_ID }}
@@ -15,7 +14,7 @@ env:
1514

1615
jobs:
1716
build-and-upload:
18-
runs-on: warp-ubuntu-latest-x64-16x
17+
runs-on: ubuntu-latest
1918

2019
steps:
2120
- name: Check out code

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,7 @@ pkg/telemetry/binaries/*/*/otelcol-contrib.exe
3030

3131
.env
3232
**/*.key
33-
**/*.crt
33+
**/*.crt
34+
35+
# ignore telemetry local debug files
36+
otel-metrics-out.log*.debug

cmd/agentd/cmd/root.go

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@ import (
99
)
1010

1111
type flagsStruct struct {
12-
stdoutFile string
13-
stderrFile string
14-
settingsFile string
15-
launchTelemetry bool
16-
launchProxyServer bool
17-
launchTransparentCache bool
18-
logLevel string
12+
stdoutFile string
13+
stderrFile string
14+
settingsFile string
15+
launchTelemetry bool
16+
launchProxyServer bool
17+
launchTransparentCache bool
18+
logLevel string
19+
telemetrySigNozEnable bool
20+
telemetrySigNozEndpoint string
21+
telemetrySigNozAPIKey string
1922
}
2023

2124
var flags flagsStruct
@@ -28,13 +31,16 @@ var rootCmd = &cobra.Command{
2831
RunE: func(cmd *cobra.Command, args []string) error {
2932

3033
err := app.NewApp(cmd.Context(), &app.ApplicationOptions{
31-
SettingsFile: flags.settingsFile,
32-
StdoutFile: flags.stdoutFile,
33-
StderrFile: flags.stderrFile,
34-
LaunchTelemetry: flags.launchTelemetry,
35-
LaunchProxyServer: flags.launchProxyServer,
36-
LaunchTransparentCache: flags.launchTransparentCache,
37-
LogLevel: flags.logLevel,
34+
SettingsFile: flags.settingsFile,
35+
StdoutFile: flags.stdoutFile,
36+
StderrFile: flags.stderrFile,
37+
LaunchTelemetry: flags.launchTelemetry,
38+
LaunchProxyServer: flags.launchProxyServer,
39+
LaunchTransparentCache: flags.launchTransparentCache,
40+
LogLevel: flags.logLevel,
41+
TelemetrySigNozEnable: flags.telemetrySigNozEnable,
42+
TelemetrySigNozEndpoint: flags.telemetrySigNozEndpoint,
43+
TelemetrySigNozAPIKey: flags.telemetrySigNozAPIKey,
3844
})
3945
if err != nil {
4046
return err
@@ -80,4 +86,7 @@ func init() {
8086
rootCmd.PersistentFlags().BoolVar(&flags.launchProxyServer, "launch-proxy-server", false, "launch proxy server")
8187
rootCmd.PersistentFlags().BoolVar(&flags.launchTransparentCache, "launch-transparent-cache", false, "launch transparent cache")
8288
rootCmd.PersistentFlags().StringVar(&flags.logLevel, "log-level", "info", "log level (debug, info, warn, error)")
89+
rootCmd.PersistentFlags().BoolVar(&flags.telemetrySigNozEnable, "telemetry-signoz-enable", false, "enable SigNoz telemetry export")
90+
rootCmd.PersistentFlags().StringVar(&flags.telemetrySigNozEndpoint, "telemetry-signoz-endpoint", "", "SigNoz OTLP endpoint (e.g., ingest.us.signoz.cloud:443)")
91+
rootCmd.PersistentFlags().StringVar(&flags.telemetrySigNozAPIKey, "telemetry-signoz-api-key", "", "SigNoz ingestion API key")
8392
}

pkg/app/app.go

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,16 @@ import (
1818
)
1919

2020
type ApplicationOptions struct {
21-
SettingsFile string `json:"settings_file"`
22-
StdoutFile string `json:"stdout_file"`
23-
StderrFile string `json:"stderr_file"`
24-
LaunchTelemetry bool `json:"launch_telemetry"`
25-
LaunchProxyServer bool `json:"launch_cache_proxy_server"`
26-
LaunchTransparentCache bool `json:"launch_transparent_cache"`
27-
LogLevel string `json:"log_level"`
21+
SettingsFile string `json:"settings_file"`
22+
StdoutFile string `json:"stdout_file"`
23+
StderrFile string `json:"stderr_file"`
24+
LaunchTelemetry bool `json:"launch_telemetry"`
25+
LaunchProxyServer bool `json:"launch_cache_proxy_server"`
26+
LaunchTransparentCache bool `json:"launch_transparent_cache"`
27+
LogLevel string `json:"log_level"`
28+
TelemetrySigNozEnable bool `json:"telemetry_signoz_enable"`
29+
TelemetrySigNozEndpoint string `json:"telemetry_signoz_endpoint"`
30+
TelemetrySigNozAPIKey string `json:"telemetry_signoz_api_key"`
2831
}
2932

3033
func (opts *ApplicationOptions) ApplyDefaults() {
@@ -219,13 +222,16 @@ func NewApp(ctx context.Context, opts *ApplicationOptions) error {
219222

220223
pushFrequency, _ := time.ParseDuration(settings.Telemetry.PushFrequency)
221224
if err := telemetry.StartTelemetryCollection(telemetryCtx, &telemetry.TelemetryOptions{
222-
BaseDirectory: settings.Telemetry.BaseDirectory,
223-
RunnerID: settings.Agent.ID,
224-
PollingSecret: settings.Agent.PollingSecret,
225-
HostURL: settings.Agent.HostURL,
226-
Enabled: settings.Telemetry.Enabled,
227-
PushFrequency: pushFrequency,
228-
Port: settings.Telemetry.Port,
225+
BaseDirectory: settings.Telemetry.BaseDirectory,
226+
RunnerID: settings.Agent.ID,
227+
PollingSecret: settings.Agent.PollingSecret,
228+
HostURL: settings.Agent.HostURL,
229+
Enabled: settings.Telemetry.Enabled,
230+
PushFrequency: pushFrequency,
231+
Port: settings.Telemetry.Port,
232+
SigNozEnable: opts.TelemetrySigNozEnable,
233+
SigNozEndpoint: opts.TelemetrySigNozEndpoint,
234+
SigNozAPIKey: opts.TelemetrySigNozAPIKey,
229235
}); err != nil {
230236
log.Logger().Errorf("failed to start telemetry: %v", err)
231237
}

pkg/telemetry/manager.go

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,26 +29,32 @@ type TelemetryManager struct {
2929
otelCollectorCmd *exec.Cmd
3030

3131
// Configuration
32-
port int
33-
baseDirectory string
34-
warpbuildAPI *warpbuild.APIClient
35-
runnerID string
36-
pollingSecret string
37-
hostURL string
32+
port int
33+
baseDirectory string
34+
warpbuildAPI *warpbuild.APIClient
35+
runnerID string
36+
pollingSecret string
37+
hostURL string
38+
sigNozEnable bool
39+
sigNozEndpoint string
40+
sigNozAPIKey string
3841
}
3942

4043
// NewTelemetryManager creates a new telemetry manager
41-
func NewTelemetryManager(ctx context.Context, port int, baseDirectory string, warpbuildAPI *warpbuild.APIClient, runnerID, pollingSecret, hostURL string) *TelemetryManager {
44+
func NewTelemetryManager(ctx context.Context, port int, baseDirectory string, warpbuildAPI *warpbuild.APIClient, runnerID, pollingSecret, hostURL string, sigNozEnable bool, sigNozEndpoint, sigNozAPIKey string) *TelemetryManager {
4245
managerCtx, cancel := context.WithCancel(ctx)
4346
return &TelemetryManager{
44-
ctx: managerCtx,
45-
cancel: cancel,
46-
port: port,
47-
baseDirectory: baseDirectory,
48-
warpbuildAPI: warpbuildAPI,
49-
runnerID: runnerID,
50-
pollingSecret: pollingSecret,
51-
hostURL: hostURL,
47+
ctx: managerCtx,
48+
cancel: cancel,
49+
port: port,
50+
baseDirectory: baseDirectory,
51+
warpbuildAPI: warpbuildAPI,
52+
runnerID: runnerID,
53+
pollingSecret: pollingSecret,
54+
hostURL: hostURL,
55+
sigNozEnable: sigNozEnable,
56+
sigNozEndpoint: sigNozEndpoint,
57+
sigNozAPIKey: sigNozAPIKey,
5258
}
5359
}
5460

@@ -292,13 +298,21 @@ func (tm *TelemetryManager) writeOtelCollectorConfig() error {
292298
OS string
293299
Arch string
294300
Port int
301+
RunnerID string
302+
SigNozEndpoint string
303+
SigNozAPIKey string
304+
EnableSigNoz bool
295305
}{
296306
LogExportFilePath: tm.getOtelCollectorOutputFilePath(false),
297307
MetricsExportFilePath: tm.getOtelCollectorOutputFilePath(true),
298308
PushFrequency: 60 * time.Second, // Default push frequency
299309
OS: runtime.GOOS,
300310
Arch: runtime.GOARCH,
301311
Port: tm.port,
312+
RunnerID: tm.runnerID,
313+
SigNozEndpoint: tm.sigNozEndpoint,
314+
SigNozAPIKey: tm.sigNozAPIKey,
315+
EnableSigNoz: tm.sigNozEnable && tm.sigNozEndpoint != "" && tm.sigNozAPIKey != "",
302316
}
303317

304318
log.Logger().Infof("Parsing template with vars: %+v", data)

0 commit comments

Comments
 (0)