feat: bake product version from Spec and expose build in health.

Resolve MAJOR.MINOR via EventHubSpec/VERSION; CI run_number as EVENTHUB_BUILD; health returns version/build/git_sha/built_at.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-17 21:48:24 +03:00
parent 2b65a804d3
commit cd61aaff20
7 changed files with 72 additions and 4 deletions
+2 -1
View File
@@ -29,7 +29,8 @@ trails() ->
properties => #{
status => #{type => string},
service => #{type => string},
version => #{type => string},
version => #{type => string, description => <<"MAJOR.MINOR from EventHubSpec/VERSION">>},
build => #{type => integer, description => <<"CI run_number (per-repo)">>},
git_sha => #{type => string},
built_at => #{type => string}
}
+2 -1
View File
@@ -31,7 +31,8 @@ trails() ->
properties => #{
status => #{type => string},
service => #{type => string},
version => #{type => string},
version => #{type => string, description => <<"MAJOR.MINOR from EventHubSpec/VERSION">>},
build => #{type => integer, description => <<"CI run_number (per-repo)">>},
git_sha => #{type => string},
built_at => #{type => string}
}
+17 -1
View File
@@ -1,13 +1,15 @@
-module(eventhub_build_info).
-export([info/0, version/0, git_sha/0, built_at/0]).
-export([info/0, version/0, build/0, git_sha/0, built_at/0]).
%% @doc Runtime build identity from env (baked at image build or set in compose).
%% version = MAJOR.MINOR (EventHubSpec/VERSION); build = CI run_number (per-repo).
-spec info() -> map().
info() ->
#{
status => <<"ok">>,
service => <<"eventhub">>,
version => version(),
build => build(),
git_sha => git_sha(),
built_at => built_at()
}.
@@ -15,6 +17,20 @@ info() ->
-spec version() -> binary().
version() -> env("EVENTHUB_VERSION", <<"0.0">>).
-spec build() -> non_neg_integer().
build() ->
case os:getenv("EVENTHUB_BUILD") of
false -> 0;
[] -> 0;
Value ->
try list_to_integer(Value) of
N when is_integer(N), N >= 0 -> N;
_ -> 0
catch
error:badarg -> 0
end
end.
-spec git_sha() -> binary().
git_sha() -> env("EVENTHUB_GIT_SHA", <<"unknown">>).