Skip to content

Commit 2e19138

Browse files
zeitlingerJames McIntyre
andauthored
Add exposition textformats to bom (#1451)
Replaces #1450 --------- Signed-off-by: Gregor Zeitlinger <[email protected]> Co-authored-by: James McIntyre <[email protected]>
1 parent 91f9cff commit 2e19138

File tree

3 files changed

+84
-1
lines changed

3 files changed

+84
-1
lines changed

mise.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,12 @@ run = "lychee --include-fragments ."
4646
[tasks.lint-gh-actions]
4747
run = "zizmor .github/"
4848

49+
[tasks.lint-bom]
50+
run = "scripts/lint-bom.sh"
51+
4952
[tasks.lint-rest]
5053
description = "All lints not covered by super linter"
51-
depends = ["lint-links", "lint-gh-actions"]
54+
depends = ["lint-links", "lint-gh-actions", "lint-bom"]
5255

5356
[tasks.acceptance-test]
5457
description = "Run OATs acceptance tests"

prometheus-metrics-bom/pom.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@
5454
<artifactId>prometheus-metrics-exporter-opentelemetry-no-otel</artifactId>
5555
<version>${project.version}</version>
5656
</dependency>
57+
<dependency>
58+
<groupId>io.prometheus</groupId>
59+
<artifactId>prometheus-metrics-exporter-opentelemetry-otel-agent-resources</artifactId>
60+
<version>${project.version}</version>
61+
</dependency>
5762
<dependency>
5863
<groupId>io.prometheus</groupId>
5964
<artifactId>prometheus-metrics-exporter-pushgateway</artifactId>
@@ -79,6 +84,11 @@
7984
<artifactId>prometheus-metrics-exposition-formats</artifactId>
8085
<version>${project.version}</version>
8186
</dependency>
87+
<dependency>
88+
<groupId>io.prometheus</groupId>
89+
<artifactId>prometheus-metrics-exposition-textformats</artifactId>
90+
<version>${project.version}</version>
91+
</dependency>
8292
<dependency>
8393
<groupId>io.prometheus</groupId>
8494
<artifactId>prometheus-metrics-instrumentation-dropwizard</artifactId>

scripts/lint-bom.sh

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
function first_artifact_id() {
6+
local bom_file="$1"
7+
grep '<artifactId>' "$bom_file" | head -n 2 | tail -n 1 |
8+
sed 's/.*<artifactId>\(.*\)<\/artifactId>.*/\1/'
9+
}
10+
11+
function add_dir() {
12+
local dir="$1"
13+
if [[ ! -d "$dir" ]]; then
14+
echo "Directory $dir does not exist."
15+
exit 1
16+
fi
17+
18+
if [[ $ignore_dirs =~ $dir ]]; then
19+
echo "Skipping $dir"
20+
return
21+
fi
22+
23+
if [[ ! -f "$dir/pom.xml" ]]; then
24+
echo "File $dir/pom.xml does not exist."
25+
exit 1
26+
fi
27+
28+
artifact_id=$(first_artifact_id "$dir/pom.xml")
29+
if [[ -z "$artifact_id" ]]; then
30+
echo "No artifactId found in $dir/pom.xml"
31+
exit 1
32+
fi
33+
34+
echo "Found artifactId '$artifact_id' in $dir/pom.xml"
35+
# add to want
36+
if [[ -z "${want+x}" ]]; then
37+
want="$artifact_id"
38+
else
39+
want="$want
40+
$artifact_id"
41+
fi
42+
}
43+
44+
declare want
45+
ignore_dirs="prometheus-metrics-parent"
46+
47+
for dir in prometheus-metrics*; do
48+
add_dir "$dir"
49+
done
50+
for dir in prometheus-metrics-tracer/prometheus-metrics*; do
51+
if [[ -d "$dir" ]]; then
52+
add_dir "$dir"
53+
fi
54+
done
55+
56+
want=$(echo "$want" | sort | uniq)
57+
have="$(grep '<artifactId>prometheus-metrics' prometheus-metrics-bom/pom.xml |
58+
sed 's/.*<artifactId>\(.*\)<\/artifactId>.*/\1/' | sort)"
59+
60+
if [[ "$want" != "$have" ]]; then
61+
echo "The BOM file prometheus-metrics-bom/bom.xml does not match the current directory contents."
62+
echo "Expected: $want"
63+
echo "Found: $have"
64+
65+
diff -u <(echo "$have") <(echo "$want")
66+
67+
exit 1
68+
else
69+
echo "BOM file is up to date."
70+
fi

0 commit comments

Comments
 (0)