Skip to content

Commit 8dc61d3

Browse files
committed
fix: quiet benign ThinPool port exits and keyless OTLP export
ThinPool traps exits (for terminate/2 device teardown), so the normal close of each System.cmd port arrived as an unhandled {:EXIT, port, :normal} and logged as an error. Add a handle_info clause to ignore normal exits. Tracing defaulted to Honeycombs endpoint but only sent the auth header when HONEYCOMB_API_KEY was set, so keyless runs 401d on every batch. Export only when a key or a custom OTEL endpoint is configured; otherwise disable the exporter.
1 parent 5761a4e commit 8dc61d3

2 files changed

Lines changed: 28 additions & 11 deletions

File tree

config/runtime.exs

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,27 @@ config :hyper, Hyper.Node.Config.Budget,
1414
# Where to send traces. Defaults to Honeycomb; override OTEL_EXPORTER_OTLP_*
1515
# to point at any OTLP/HTTP backend (Collector, Grafana, etc).
1616
if config_env() != :test do
17-
endpoint = System.get_env("OTEL_EXPORTER_OTLP_ENDPOINT", "https://api.honeycomb.io")
17+
custom_endpoint = System.get_env("OTEL_EXPORTER_OTLP_ENDPOINT")
18+
api_key = System.get_env("HONEYCOMB_API_KEY")
1819

19-
headers =
20-
case System.get_env("HONEYCOMB_API_KEY") do
21-
nil -> []
22-
"" -> []
23-
key -> [{"x-honeycomb-team", key}]
24-
end
20+
cond do
21+
api_key not in [nil, ""] ->
22+
config :opentelemetry_exporter,
23+
otlp_protocol: :http_protobuf,
24+
otlp_endpoint: custom_endpoint || "https://api.honeycomb.io",
25+
otlp_headers: [{"x-honeycomb-team", api_key}]
2526

26-
config :opentelemetry_exporter,
27-
otlp_protocol: :http_protobuf,
28-
otlp_endpoint: endpoint,
29-
otlp_headers: headers
27+
custom_endpoint not in [nil, ""] ->
28+
# A custom OTLP backend (e.g. a local Collector) needs no Honeycomb key.
29+
config :opentelemetry_exporter,
30+
otlp_protocol: :http_protobuf,
31+
otlp_endpoint: custom_endpoint,
32+
otlp_headers: []
33+
34+
true ->
35+
# No backend configured: exporting to the Honeycomb default with no key
36+
# 401s on every batch. Stay silent instead (typical for local dev). Set
37+
# HONEYCOMB_API_KEY or OTEL_EXPORTER_OTLP_ENDPOINT to enable tracing.
38+
config :opentelemetry, traces_exporter: :none
39+
end
3040
end

lib/hyper/node/img/thin_pool.ex

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,13 @@ defmodule Hyper.Node.Img.ThinPool do
9494
{:reply, :ok, id_free(state, id)}
9595
end
9696

97+
@impl true
98+
# Each privileged command runs through `System.cmd`, which links a transient
99+
# port to this process; because we trap exits (for `terminate/2` teardown),
100+
# the port's normal close is delivered here. Ignore it. An abnormal exit
101+
# carries a non-`:normal` reason and falls through to the default handler.
102+
def handle_info({:EXIT, _port, :normal}, state), do: {:noreply, state}
103+
97104
@impl true
98105
def terminate(_reason, state) do
99106
_ = SuidHelper.Dmsetup.remove(@pool_name)

0 commit comments

Comments
 (0)