Skip to content

fix: clarify and expand the default env vars the agent provides to the configs #142

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 17, 2024
Merged
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
12 changes: 9 additions & 3 deletions internal/connections/confighandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,19 @@ func GetAllOtelConfigFilePaths(ctx context.Context, tmpDir string) ([]string, er

func SetEnvVars() error {
collector_url, token, debug := viper.GetString("observe_url"), viper.GetString("token"), viper.GetBool("debug")
endpoint, err := url.JoinPath(collector_url, "/v2/otel")
otelEndpoint, err := url.JoinPath(collector_url, "/v2/otel")
if err != nil {
return err
}
promEndpoint, err := url.JoinPath(collector_url, "/v1/prometheus")
if err != nil {
return err
}
// Setting values from the Observe agent config as env vars to fill in the OTEL collector config
os.Setenv("OBSERVE_ENDPOINT", endpoint)
os.Setenv("OBSERVE_TOKEN", "Bearer "+token)
os.Setenv("OBSERVE_COLLECTOR_URL", collector_url)
os.Setenv("OBSERVE_OTEL_ENDPOINT", otelEndpoint)
os.Setenv("OBSERVE_PROMETHEUS_ENDPOINT", promEndpoint)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where does this get used?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nowhere yet, but I will use it for the prometheus remote write exporter as I'm doing the metrics conversion.

os.Setenv("OBSERVE_AUTHORIZATION_HEADER", "Bearer "+token)
os.Setenv("FILESTORAGE_PATH", GetDefaultFilestoragePath())

if debug {
Expand Down
4 changes: 2 additions & 2 deletions packaging/docker/observe-agent/otel-collector.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ processors:

exporters:
otlphttp/observe:
endpoint: ${env:OBSERVE_ENDPOINT}
endpoint: ${env:OBSERVE_OTEL_ENDPOINT}
headers:
authorization: ${env:OBSERVE_TOKEN}
authorization: ${env:OBSERVE_AUTHORIZATION_HEADER}
sending_queue:
num_consumers: 4
queue_size: 100
Expand Down
4 changes: 2 additions & 2 deletions packaging/linux/etc/observe-agent/otel-collector.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ processors:

exporters:
otlphttp/observe:
endpoint: ${env:OBSERVE_ENDPOINT}
endpoint: ${env:OBSERVE_OTEL_ENDPOINT}
headers:
authorization: ${env:OBSERVE_TOKEN}
authorization: ${env:OBSERVE_AUTHORIZATION_HEADER}
sending_queue:
num_consumers: 4
queue_size: 100
Expand Down
4 changes: 2 additions & 2 deletions packaging/macos/config/otel-collector.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ processors:

exporters:
otlphttp/observe:
endpoint: ${env:OBSERVE_ENDPOINT}
endpoint: ${env:OBSERVE_OTEL_ENDPOINT}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this works today and is just a cleanup?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! This works, but it couldn't be used for prometheus or other collection as it had the /v2/otel baked into it. I think in an ideal world, users would specify the token and collection endpoint as top level env vars or config, and never reference them explicitly anywhere else.

headers:
authorization: ${env:OBSERVE_TOKEN}
authorization: ${env:OBSERVE_AUTHORIZATION_HEADER}
sending_queue:
num_consumers: 4
queue_size: 100
Expand Down
4 changes: 2 additions & 2 deletions packaging/windows/config/otel-collector.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ processors:

exporters:
otlphttp/observe:
endpoint: ${env:OBSERVE_ENDPOINT}
endpoint: ${env:OBSERVE_OTEL_ENDPOINT}
headers:
authorization: ${env:OBSERVE_TOKEN}
authorization: ${env:OBSERVE_AUTHORIZATION_HEADER}
sending_queue:
num_consumers: 4
queue_size: 100
Expand Down
Loading