Skip to content

Commit 0f7db9a

Browse files
fix: ensure provided env var OBSERVE_COLLECTOR_URL never ends in a slash (#163)
### Description Ensure provided env var OBSERVE_COLLECTOR_URL never ends in a slash. Providing a consistent format regardless of how the agent is configured will make using this downstream easier and more reliable. ### Checklist - [ ] Created tests which fail without the change (if possible) - [ ] Extended the README / documentation, if necessary
1 parent d37d19e commit 0f7db9a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

internal/connections/confighandler.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ func GetAllOtelConfigFilePaths(ctx context.Context, tmpDir string) ([]string, er
7474

7575
func SetEnvVars() error {
7676
collector_url, token, debug := viper.GetString("observe_url"), viper.GetString("token"), viper.GetBool("debug")
77+
// Ensure the collector url does not end with a slash for consistency. This will allow endpoints to be configured like:
78+
// "${env:OBSERVE_COLLECTOR_URL}/v1/kubernetes/v1/entity"
79+
// without worrying about a double slash.
80+
if collector_url[len(collector_url)-1] == '/' {
81+
collector_url = collector_url[:len(collector_url)-1]
82+
}
7783
otelEndpoint, err := url.JoinPath(collector_url, "/v2/otel")
7884
if err != nil {
7985
return err

0 commit comments

Comments
 (0)