Skip to content

Commit b0fbd03

Browse files
fix: clarify and expand the default env vars the agent provides to the configs (#142)
### Description Clarify and expand the default env vars the agent provides to the configs. This makes the vanilla collector endpoint available as well as exposing the prometheus endpoint. It also renames OBSERVE_TOKEN to OBSERVE_AUTHORIZATION_HEADER for clarity since the value is prefixed by `"Bearer "`, and renames OBSERVE_ENDPOINT to OBSERVE_OTEL_ENDPOINT since the value is suffixed with `"/v2/otel"` ### Checklist - [ ] Created tests which fail without the change (if possible) - [ ] Extended the README / documentation, if necessary
1 parent c68cef6 commit b0fbd03

File tree

5 files changed

+17
-11
lines changed

5 files changed

+17
-11
lines changed

internal/connections/confighandler.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,19 @@ func GetAllOtelConfigFilePaths(ctx context.Context, tmpDir string) ([]string, er
7878

7979
func SetEnvVars() error {
8080
collector_url, token, debug := viper.GetString("observe_url"), viper.GetString("token"), viper.GetBool("debug")
81-
endpoint, err := url.JoinPath(collector_url, "/v2/otel")
81+
otelEndpoint, err := url.JoinPath(collector_url, "/v2/otel")
82+
if err != nil {
83+
return err
84+
}
85+
promEndpoint, err := url.JoinPath(collector_url, "/v1/prometheus")
8286
if err != nil {
8387
return err
8488
}
8589
// Setting values from the Observe agent config as env vars to fill in the OTEL collector config
86-
os.Setenv("OBSERVE_ENDPOINT", endpoint)
87-
os.Setenv("OBSERVE_TOKEN", "Bearer "+token)
90+
os.Setenv("OBSERVE_COLLECTOR_URL", collector_url)
91+
os.Setenv("OBSERVE_OTEL_ENDPOINT", otelEndpoint)
92+
os.Setenv("OBSERVE_PROMETHEUS_ENDPOINT", promEndpoint)
93+
os.Setenv("OBSERVE_AUTHORIZATION_HEADER", "Bearer "+token)
8894
os.Setenv("FILESTORAGE_PATH", GetDefaultFilestoragePath())
8995

9096
if debug {

packaging/docker/observe-agent/otel-collector.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ processors:
8383

8484
exporters:
8585
otlphttp/observe:
86-
endpoint: ${env:OBSERVE_ENDPOINT}
86+
endpoint: ${env:OBSERVE_OTEL_ENDPOINT}
8787
headers:
88-
authorization: ${env:OBSERVE_TOKEN}
88+
authorization: ${env:OBSERVE_AUTHORIZATION_HEADER}
8989
sending_queue:
9090
num_consumers: 4
9191
queue_size: 100

packaging/linux/etc/observe-agent/otel-collector.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ processors:
8383

8484
exporters:
8585
otlphttp/observe:
86-
endpoint: ${env:OBSERVE_ENDPOINT}
86+
endpoint: ${env:OBSERVE_OTEL_ENDPOINT}
8787
headers:
88-
authorization: ${env:OBSERVE_TOKEN}
88+
authorization: ${env:OBSERVE_AUTHORIZATION_HEADER}
8989
sending_queue:
9090
num_consumers: 4
9191
queue_size: 100

packaging/macos/config/otel-collector.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ processors:
8383

8484
exporters:
8585
otlphttp/observe:
86-
endpoint: ${env:OBSERVE_ENDPOINT}
86+
endpoint: ${env:OBSERVE_OTEL_ENDPOINT}
8787
headers:
88-
authorization: ${env:OBSERVE_TOKEN}
88+
authorization: ${env:OBSERVE_AUTHORIZATION_HEADER}
8989
sending_queue:
9090
num_consumers: 4
9191
queue_size: 100

packaging/windows/config/otel-collector.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ processors:
6363

6464
exporters:
6565
otlphttp/observe:
66-
endpoint: ${env:OBSERVE_ENDPOINT}
66+
endpoint: ${env:OBSERVE_OTEL_ENDPOINT}
6767
headers:
68-
authorization: ${env:OBSERVE_TOKEN}
68+
authorization: ${env:OBSERVE_AUTHORIZATION_HEADER}
6969
sending_queue:
7070
num_consumers: 4
7171
queue_size: 100

0 commit comments

Comments
 (0)