Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions common/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (

C "github.com/getlantern/common"

"github.com/getlantern/radiance/common/deviceid"
"github.com/getlantern/radiance/common/env"
"github.com/getlantern/radiance/common/reporting"
"github.com/getlantern/radiance/internal"
Expand Down Expand Up @@ -65,6 +66,10 @@ func Init(dataDir, logDir, logLevel, deviceID string) error {
return nil
}

if deviceID == "" {
deviceID = deviceid.Get()
}

reporting.Init(Version)
err := setupDirectories(dataDir, logDir)
if err != nil {
Expand Down Expand Up @@ -114,7 +119,7 @@ func afterConfigIsAvailableCallback(configPath, deviceID string) {
return
}

if err := initOTEL(deviceID, cfg.ConfigResponse); err != nil {
if err := initOTEL(deviceID, &cfg.ConfigResponse); err != nil {
slog.Error("Failed to initialize OpenTelemetry", "error", err)
return
}
Expand Down Expand Up @@ -190,7 +195,7 @@ func initLogger(logPath, level string) error {
logger := slog.New(slog.NewTextHandler(logWriter, &slog.HandlerOptions{
AddSource: true,
Level: lvl,
ReplaceAttr: func(groups []string, a slog.Attr) slog.Attr {
ReplaceAttr: func(_ []string, a slog.Attr) slog.Attr {
switch a.Key {
case slog.SourceKey:
source, ok := a.Value.Any().(*slog.Source)
Expand Down Expand Up @@ -243,7 +248,7 @@ type config struct {
ConfigResponse C.ConfigResponse
}

func initOTEL(deviceID string, configResponse C.ConfigResponse) error {
func initOTEL(deviceID string, configResponse *C.ConfigResponse) error {
initMutex.Lock()
defer initMutex.Unlock()

Expand Down
2 changes: 1 addition & 1 deletion metrics/otel.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func buildResources(serviceName string, a Attributes) []attribute.KeyValue {

// SetupOTelSDK bootstraps the OpenTelemetry pipeline.
// If it does not return an error, make sure to call shutdown for proper cleanup.
func SetupOTelSDK(ctx context.Context, attributes Attributes, cfg common.ConfigResponse) (func(context.Context) error, error) {
func SetupOTelSDK(ctx context.Context, attributes Attributes, cfg *common.ConfigResponse) (func(context.Context) error, error) {
if cfg.Features == nil {
cfg.Features = make(map[string]bool)
}
Expand Down