Skip to content

Commit 9ee5de4

Browse files
chore: config improvements (#32)
1 parent 3603c45 commit 9ee5de4

63 files changed

Lines changed: 1888 additions & 498 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

config/config.exs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,20 @@ config :opentelemetry,
1212
# iex --name a@127.0.0.1 --cookie hyper -S mix
1313
# iex --name b@127.0.0.1 --cookie hyper -S mix
1414
#
15-
# Swap the strategy for prod (DNSPoll / EC2 tags).
16-
config :libcluster,
15+
# Swap the strategy for prod (DNSPoll / EC2 tags). Hyper forwards this straight
16+
# to libcluster; see `Hyper.Cfg.Cluster`.
17+
config :hyper, Hyper.Cfg.Cluster,
1718
topologies: [
1819
hyper: [
1920
strategy: Cluster.Strategy.Epmd,
2021
config: [hosts: [:"a@127.0.0.1", :"b@127.0.0.1", :"c@127.0.0.1"]]
2122
]
2223
]
2324

24-
config :hyper,
25-
cgroup_parent: "hyper",
26-
uid_gid_range: {900_000, 999_999},
27-
layer_dir: "/srv/hyper/layers"
28-
2925
if config_env() == :test do
3026
config :opentelemetry, traces_exporter: :none
3127
# No cluster formation during tests.
32-
config :libcluster, topologies: []
28+
config :hyper, Hyper.Cfg.Cluster, topologies: []
3329

3430
# JUnit XML for Codecov Test Analytics. A fixed report_dir (not the default
3531
# app_path) gives CI a stable path; automatic_create_dir? mkdirs it since

config/runtime.exs

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,39 @@ import Config
22

33
# Per-node resource budget. Lives in runtime config because it builds `Unit.*`
44
# values, which are only loadable once the app's modules are on the code path.
5-
config :hyper, Hyper.Node.Config.Budget,
5+
config :hyper, Hyper.Cfg.Budget,
66
mem_max: Unit.Information.gib(4),
77
disk_max: Unit.Information.gib(4),
88
cpu_max_load: 0.8,
9+
cpu_max_cap: 4.0,
910
disk_bw_cap: Unit.Bandwidth.gibps(1),
1011
disk_bw_max_load: 0.8,
1112
net_bw_cap: Unit.Bandwidth.gibps(1),
1213
net_bw_max_load: 0.8
1314

14-
# Where to send traces. Defaults to Honeycomb; override OTEL_EXPORTER_OTLP_*
15-
# to point at any OTLP/HTTP backend (Collector, Grafana, etc).
15+
# Operator overrides from a well-known location. An optional Elixir config file
16+
# at /etc/hyper/config.exs (override the path with HYPER_CONFIG) is merged in
17+
# last, so its values win over every default set above. An absent file is a
18+
# no-op — the normal case in dev and CI. Skipped under :test so the suite never
19+
# reads host state.
20+
#
21+
# OpenTelemetry exporter wiring is resolved through Hyper.Cfg.Otel so that the
22+
# operator's `config :hyper, Hyper.Cfg.Otel, ...` stanza (if present) takes
23+
# precedence over the TOML table and environment variables.
1624
if config_env() != :test do
17-
endpoint = System.get_env("OTEL_EXPORTER_OTLP_ENDPOINT", "https://api.honeycomb.io")
25+
hyper_config = System.get_env("HYPER_CONFIG") || "/etc/hyper/config.exs"
1826

19-
headers =
20-
case System.get_env("HONEYCOMB_API_KEY") do
21-
nil -> []
22-
"" -> []
23-
key -> [{"x-honeycomb-team", key}]
24-
end
27+
operator =
28+
if File.exists?(hyper_config),
29+
do: Config.Reader.read!(hyper_config, env: config_env()),
30+
else: []
2531

26-
config :opentelemetry_exporter,
27-
otlp_protocol: :http_protobuf,
28-
otlp_endpoint: endpoint,
29-
otlp_headers: headers
32+
otel_exs = get_in(operator, [:hyper, Hyper.Cfg.Otel]) || []
33+
34+
case Hyper.Cfg.Otel.exporter_options(otel_exs) do
35+
{:ok, opts} -> config :opentelemetry_exporter, opts
36+
:none -> config :opentelemetry, traces_exporter: :none
37+
end
38+
39+
for {app, kw} <- operator, do: config(app, kw)
3040
end

0 commit comments

Comments
 (0)