Skip to content

Commit 92368c8

Browse files
committed
merge main
2 parents d5cf110 + beba51e commit 92368c8

File tree

84 files changed

+1528
-294
lines changed

Some content is hidden

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

84 files changed

+1528
-294
lines changed
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
name: Metadata Update
2+
3+
on:
4+
workflow_dispatch: # allow this to be manually triggered
5+
schedule:
6+
- cron: "00 1 * * *" # daily at 1:00 UTC
7+
8+
permissions:
9+
contents: read
10+
11+
# Should only be one job running at a time to avoid conflicts with the metadata update branch
12+
concurrency:
13+
group: metadata-update
14+
cancel-in-progress: true
15+
16+
jobs:
17+
update:
18+
runs-on: ubuntu-latest
19+
permissions:
20+
contents: write # for git push to PR branch
21+
pull-requests: write # for adding label and assignee to PR
22+
23+
steps:
24+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
25+
26+
- name: Free disk space
27+
run: .github/scripts/gha-free-disk-space.sh
28+
29+
- name: Set up JDK for running Gradle
30+
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
31+
with:
32+
distribution: temurin
33+
java-version-file: .java-version
34+
35+
- name: Set up gradle
36+
uses: gradle/actions/setup-gradle@ac638b010cf58a27ee6c972d7336334ccaf61c96 # v4.4.1
37+
38+
- name: Collect telemetry
39+
run: ./instrumentation-docs/ci-collect.sh
40+
41+
- name: Run documentation analyzer
42+
run: ./gradlew :instrumentation-docs:runAnalysis
43+
44+
- name: Check for diff
45+
id: diffcheck
46+
run: |
47+
git add docs/instrumentation-list.yaml
48+
if ! git diff --cached --quiet; then
49+
echo "has_diff=true" >> $GITHUB_OUTPUT
50+
else
51+
echo "has_diff=false" >> $GITHUB_OUTPUT
52+
fi
53+
54+
- name: Use CLA approved github bot
55+
if: steps.diffcheck.outputs.has_diff == 'true'
56+
run: .github/scripts/use-cla-approved-bot.sh
57+
58+
- uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6
59+
if: steps.diffcheck.outputs.has_diff == 'true'
60+
id: otelbot-token
61+
with:
62+
app-id: ${{ vars.OTELBOT_APP_ID }}
63+
private-key: ${{ secrets.OTELBOT_PRIVATE_KEY }}
64+
65+
- name: Find or create metadata update branch
66+
if: steps.diffcheck.outputs.has_diff == 'true'
67+
id: findbranch
68+
env:
69+
GH_TOKEN: ${{ steps.otelbot-token.outputs.token }}
70+
run: |
71+
BRANCH_NAME="metadata-update-main"
72+
echo "branch=$BRANCH_NAME" >> $GITHUB_OUTPUT
73+
if git ls-remote --exit-code --heads origin "$BRANCH_NAME"; then
74+
git fetch origin "$BRANCH_NAME"
75+
git checkout "$BRANCH_NAME"
76+
git merge origin/main --no-edit
77+
else
78+
git checkout -b "$BRANCH_NAME" origin/main
79+
fi
80+
81+
- name: Commit and push changes
82+
if: steps.diffcheck.outputs.has_diff == 'true'
83+
env:
84+
GH_TOKEN: ${{ steps.otelbot-token.outputs.token }}
85+
run: |
86+
BRANCH_NAME="${{ steps.findbranch.outputs.branch }}"
87+
git commit -m "chore: update instrumentation list [automated]" || echo "No changes to commit."
88+
git push origin "$BRANCH_NAME"
89+
90+
- name: Create PR if needed
91+
if: steps.diffcheck.outputs.has_diff == 'true'
92+
id: createpr
93+
env:
94+
GH_TOKEN: ${{ steps.otelbot-token.outputs.token }}
95+
run: |
96+
BRANCH_NAME="${{ steps.findbranch.outputs.branch }}"
97+
PR_EXISTS=$(gh pr list --state open --head "$BRANCH_NAME" --label automation --json url -q '.[0].url')
98+
if [ -z "$PR_EXISTS" ]; then
99+
gh pr create \
100+
--title "chore: update instrumentation list [automated]" \
101+
--body "This PR was created automatically by the metadata update workflow." \
102+
--head "$BRANCH_NAME" \
103+
--base main
104+
echo "new_pr=true" >> $GITHUB_OUTPUT
105+
else
106+
echo "PR already exists: $PR_EXISTS"
107+
echo "new_pr=false" >> $GITHUB_OUTPUT
108+
fi
109+
110+
- name: Add label to PR
111+
if: steps.createpr.outputs.new_pr == 'true'
112+
env:
113+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
114+
run: |
115+
BRANCH_NAME="${{ steps.findbranch.outputs.branch }}"
116+
PR_URL=$(gh pr list --state open --head "$BRANCH_NAME" --json url -q '.[0].url')
117+
if [ -n "$PR_URL" ]; then
118+
gh pr edit "$PR_URL" --add-label "automation" --add-assignee jaydeluca
119+
else
120+
echo "No open PR found for branch $BRANCH_NAME."
121+
fi

benchmark-overhead/src/test/java/io/opentelemetry/agents/LatestAgentSnapshotResolver.java

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import java.nio.file.Paths;
1414
import java.nio.file.StandardOpenOption;
1515
import java.util.Optional;
16+
import java.time.Duration;
1617
import okhttp3.OkHttpClient;
1718
import okhttp3.Request;
1819
import okhttp3.Response;
@@ -30,6 +31,11 @@ public class LatestAgentSnapshotResolver {
3031
"https://oss.sonatype.org/content/repositories/snapshots/io/opentelemetry/javaagent/opentelemetry-javaagent";
3132
static final String LATEST_SNAPSHOT_META = BASE_URL + "/maven-metadata.xml";
3233

34+
private static final OkHttpClient client = new OkHttpClient.Builder()
35+
.connectTimeout(Duration.ofMinutes(1))
36+
.readTimeout(Duration.ofMinutes(1))
37+
.build();
38+
3339
Optional<Path> resolve() throws IOException {
3440
String version = fetchLatestSnapshotVersion();
3541
logger.info("Latest snapshot version is {}", version);
@@ -81,11 +87,33 @@ private byte[] fetchBodyBytesFrom(String url) throws IOException {
8187
return fetchBodyFrom(url).bytes();
8288
}
8389

90+
// The sonatype repository can be very unreliable, so we retry a few times
8491
private ResponseBody fetchBodyFrom(String url) throws IOException {
8592
Request request = new Request.Builder().url(url).build();
86-
OkHttpClient client = new OkHttpClient();
87-
Response response = client.newCall(request).execute();
88-
ResponseBody body = response.body();
89-
return body;
93+
IOException lastException = null;
94+
95+
for (int attempt = 0; attempt < 3; attempt++) {
96+
try {
97+
try (Response response = client.newCall(request).execute()) {
98+
if (!response.isSuccessful()) {
99+
throw new IOException("Unexpected HTTP code " + response.code() + " for " + url);
100+
}
101+
ResponseBody body = response.body();
102+
if (body != null) {
103+
byte[] data = body.bytes();
104+
return ResponseBody.create(data, body.contentType());
105+
} else {
106+
throw new IOException("Response body is null");
107+
}
108+
}
109+
} catch (IOException e) {
110+
lastException = e;
111+
if (attempt < 2) {
112+
logger.warn("Attempt {} to fetch {} failed: {}. Retrying...", attempt + 1, url, e.getMessage());
113+
}
114+
}
115+
}
116+
throw lastException;
90117
}
91118
}
119+

conventions/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ dependencies {
5757
implementation("com.diffplug.spotless:spotless-plugin-gradle:7.2.1")
5858
implementation("com.google.guava:guava:33.4.8-jre")
5959
implementation("gradle.plugin.com.google.protobuf:protobuf-gradle-plugin:0.8.18")
60-
implementation("com.gradleup.shadow:shadow-gradle-plugin:8.3.8")
60+
implementation("com.gradleup.shadow:shadow-gradle-plugin:8.3.9")
6161
implementation("org.apache.httpcomponents:httpclient:4.5.14")
6262
implementation("com.gradle.develocity:com.gradle.develocity.gradle.plugin:4.1")
6363
implementation("org.owasp:dependency-check-gradle:12.1.3")

dependencyManagement/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ val DEPENDENCY_BOMS = listOf(
2828
// even if they are only used by test dependencies, so not using junit bom since it is LGPL
2929

3030
"com.fasterxml.jackson:jackson-bom:2.19.2",
31-
"com.squareup.okio:okio-bom:3.15.0", // see https://github.com/open-telemetry/opentelemetry-java/issues/5637
3231
"com.google.guava:guava-bom:33.4.8-jre",
3332
"org.apache.groovy:groovy-bom:${groovyVersion}",
3433
"io.opentelemetry:opentelemetry-bom:${otelSdkVersion}",

0 commit comments

Comments
 (0)