Handle empty device ID #135
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
lantern-outline
does not currently have code to pass a device ID tocommon.Init
, so this code fails. This checks for an empty ID and sets it if it's empty.This pull request makes several improvements to how the application initializes and manages configuration, particularly with regards to device ID handling and OpenTelemetry (OTEL) setup. The main changes are focused on ensuring that a device ID is always set, refactoring function signatures to use pointers for configuration objects, and making minor code cleanups.
Device ID management and initialization:
Init
function incommon/init.go
now ensures that if thedeviceID
parameter is empty, it is automatically set usingdeviceid.Get()
, improving robustness in device identification.deviceid
package is now imported incommon/init.go
to support the above enhancement.Configuration and OpenTelemetry (OTEL) setup:
initOTEL
function and its callers have been refactored to accept a pointer toConfigResponse
instead of a value, ensuring more efficient memory usage and consistency across the codebase. [1] [2]SetupOTelSDK
function inmetrics/otel.go
has also been updated to accept a pointer toConfigResponse
, aligning with the changes ininitOTEL
.Code cleanup:
ReplaceAttr
function in the logger initialization now ignores thegroups
parameter by using_
, which is a minor code style improvement.