Skip to content

Commit 6d2f014

Browse files
committed
Merge remote-tracking branch 'upstream/main' into contains-points-satisfying
# Conflicts: # CHANGELOG.md # docs/apidiffs/current_vs_latest/opentelemetry-sdk-testing.txt
2 parents 91281c7 + f674cdd commit 6d2f014

17 files changed

Lines changed: 228 additions & 17 deletions

File tree

.github/workflows/benchmark-tags.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
name: Benchmark SDK
1414
runs-on: oracle-bare-metal-64cpu-1024gb-x86-64-ubuntu-24
1515
container:
16-
image: ubuntu:24.04@sha256:84e77dee7d1bc93fb029a45e3c6cb9d8aa4831ccfcc7103d36e876938d28895b
16+
image: ubuntu:24.04@sha256:c4a8d5503dfb2a3eb8ab5f807da5bc69a85730fb49b5cfca2330194ebcc41c7b
1717
timeout-minutes: 20 # since there is only a single bare metal runner across all repos
1818
strategy:
1919
fail-fast: false

.github/workflows/benchmark.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
name: Benchmark SDK
1616
runs-on: oracle-bare-metal-64cpu-1024gb-x86-64-ubuntu-24
1717
container:
18-
image: ubuntu:24.04@sha256:84e77dee7d1bc93fb029a45e3c6cb9d8aa4831ccfcc7103d36e876938d28895b
18+
image: ubuntu:24.04@sha256:c4a8d5503dfb2a3eb8ab5f807da5bc69a85730fb49b5cfca2330194ebcc41c7b
1919
timeout-minutes: 20 # since there is only a single bare metal runner across all repos
2020
steps:
2121
- name: Install Git

.github/workflows/codeql.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
uses: gradle/actions/setup-gradle@50e97c2cd7a37755bbfafc9c5b7cafaece252f6e # v6.1.0
4646

4747
- name: Initialize CodeQL
48-
uses: github/codeql-action/init@c10b8064de6f491fea524254123dbe5e09572f13 # v4.35.1
48+
uses: github/codeql-action/init@95e58e9a2cdfd71adc6e0353d5c52f41a045d225 # v4.35.2
4949
with:
5050
languages: ${{ matrix.language }}
5151
# using "linked" helps to keep up with the latest Kotlin support
@@ -62,6 +62,6 @@ jobs:
6262
DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
6363

6464
- name: Perform CodeQL analysis
65-
uses: github/codeql-action/analyze@c10b8064de6f491fea524254123dbe5e09572f13 # v4.35.1
65+
uses: github/codeql-action/analyze@95e58e9a2cdfd71adc6e0353d5c52f41a045d225 # v4.35.2
6666
with:
6767
category: "/language:${{matrix.language}}"

.github/workflows/detect-api-changes.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
name: Detect API surface area changes
1818
runs-on: ubuntu-latest
1919
steps:
20-
- uses: actions/create-github-app-token@f8d387b68d61c58ab83c6c016672934102569859 # v3.0.0
20+
- uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1
2121
id: otelbot-token
2222
with:
2323
app-id: ${{ vars.OTELBOT_APP_ID }}

.github/workflows/ossf-scorecard.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@ jobs:
4343
# Upload the results to GitHub's code scanning dashboard (optional).
4444
# Commenting out will disable upload of results to your repo's Code Scanning dashboard
4545
- name: "Upload to code-scanning"
46-
uses: github/codeql-action/upload-sarif@c10b8064de6f491fea524254123dbe5e09572f13 # v4.35.1
46+
uses: github/codeql-action/upload-sarif@95e58e9a2cdfd71adc6e0353d5c52f41a045d225 # v4.35.2
4747
with:
4848
sarif_file: results.sarif

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#### Testing
88

9+
* Add `hasValueSatisfying` to `LongPointAssert` and `DoublePointAssert` for fuzzy value matching
910
* Add `containsPointsSatisfying` to metric data asserts for "each given assertion must be
1011
satisfied by at least one point, extras allowed" checks on sum, gauge, histogram, exponential
1112
histogram, and summary data

animal-sniffer-signature/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ val generatedSignature = configurations.create("generatedSignature") {
2424
}
2525

2626
dependencies {
27-
signature("com.toasttab.android:gummy-bears-api-23:0.13.0@signature")
27+
signature("com.toasttab.android:gummy-bears-api-23:0.14.0@signature")
2828
signatureJar("com.android.tools:desugar_jdk_libs")
2929
}
3030

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package io.opentelemetry.gradle.customchecks;
7+
8+
import static com.google.errorprone.BugPattern.LinkType.NONE;
9+
import static com.google.errorprone.BugPattern.SeverityLevel.WARNING;
10+
11+
import com.google.errorprone.BugPattern;
12+
import com.google.errorprone.VisitorState;
13+
import com.google.errorprone.bugpatterns.BugChecker;
14+
import com.google.errorprone.matchers.Description;
15+
import com.sun.source.doctree.DocCommentTree;
16+
import com.sun.source.tree.ClassTree;
17+
import com.sun.source.tree.PackageTree;
18+
import com.sun.tools.javac.api.JavacTrees;
19+
import java.util.regex.Pattern;
20+
import javax.annotation.Nullable;
21+
import javax.lang.model.element.Modifier;
22+
23+
@BugPattern(
24+
summary =
25+
"This public impl class is missing the required javadoc disclaimer: \""
26+
+ OtelImplJavadoc.EXPECTED_IMPL_COMMENT
27+
+ "\"",
28+
severity = WARNING,
29+
linkType = NONE)
30+
public class OtelImplJavadoc extends BugChecker implements BugChecker.ClassTreeMatcher {
31+
32+
private static final long serialVersionUID = 1L;
33+
34+
private static final Pattern IMPL_PACKAGE_PATTERN = Pattern.compile("\\bimpl\\b");
35+
36+
static final String EXPECTED_IMPL_COMMENT =
37+
"This class is not intended for use by application developers."
38+
+ " Its API is stable and will not be changed or removed in a backwards-incompatible"
39+
+ " manner.";
40+
41+
@Override
42+
public Description matchClass(ClassTree tree, VisitorState state) {
43+
if (!isPublic(tree) || !isImpl(state) || tree.getSimpleName().toString().endsWith("Test")) {
44+
return Description.NO_MATCH;
45+
}
46+
String javadoc = getJavadoc(state);
47+
if (javadoc != null && javadoc.contains(EXPECTED_IMPL_COMMENT)) {
48+
return Description.NO_MATCH;
49+
}
50+
return describeMatch(tree);
51+
}
52+
53+
private static boolean isPublic(ClassTree tree) {
54+
return tree.getModifiers().getFlags().contains(Modifier.PUBLIC);
55+
}
56+
57+
private static boolean isImpl(VisitorState state) {
58+
PackageTree packageTree = state.getPath().getCompilationUnit().getPackage();
59+
if (packageTree == null) {
60+
return false;
61+
}
62+
String packageName = state.getSourceForNode(packageTree.getPackageName());
63+
return packageName != null && IMPL_PACKAGE_PATTERN.matcher(packageName).find();
64+
}
65+
66+
@Nullable
67+
private static String getJavadoc(VisitorState state) {
68+
DocCommentTree docCommentTree =
69+
JavacTrees.instance(state.context).getDocCommentTree(state.getPath());
70+
if (docCommentTree == null) {
71+
return null;
72+
}
73+
return docCommentTree.toString().replace("\n", " ").replace(" * ", " ").replaceAll("\\s+", " ");
74+
}
75+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
io.opentelemetry.gradle.customchecks.OtelDeprecatedApiUsage
2+
io.opentelemetry.gradle.customchecks.OtelImplJavadoc
23
io.opentelemetry.gradle.customchecks.OtelInternalJavadoc
34
io.opentelemetry.gradle.customchecks.OtelPrivateConstructorForUtilityClass
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package io.opentelemetry.gradle.customchecks;
7+
8+
import com.google.errorprone.CompilationTestHelper;
9+
import org.junit.jupiter.api.Test;
10+
11+
class OtelImplJavadocTest {
12+
13+
@Test
14+
void positiveCases() {
15+
CompilationTestHelper.newInstance(OtelImplJavadoc.class, OtelImplJavadocTest.class)
16+
.addSourceLines(
17+
"impl/ImplJavadocPositiveCases.java",
18+
"/*",
19+
" * Copyright The OpenTelemetry Authors",
20+
" * SPDX-License-Identifier: Apache-2.0",
21+
" */",
22+
"package io.opentelemetry.gradle.customchecks.impl;",
23+
"// BUG: Diagnostic contains: missing the required javadoc disclaimer",
24+
"public class ImplJavadocPositiveCases {",
25+
" // BUG: Diagnostic contains: missing the required javadoc disclaimer",
26+
" public static class One {}",
27+
" /** Doesn't have the disclaimer. */",
28+
" // BUG: Diagnostic contains: missing the required javadoc disclaimer",
29+
" public static class Two {}",
30+
"}")
31+
.doTest();
32+
}
33+
34+
@Test
35+
void negativeCases() {
36+
CompilationTestHelper.newInstance(OtelImplJavadoc.class, OtelImplJavadocTest.class)
37+
.addSourceLines(
38+
"impl/ImplJavadocNegativeCases.java",
39+
"/*",
40+
" * Copyright The OpenTelemetry Authors",
41+
" * SPDX-License-Identifier: Apache-2.0",
42+
" */",
43+
"package io.opentelemetry.gradle.customchecks.impl;",
44+
"/**",
45+
" * This class is not intended for use by application developers. Its API is stable and",
46+
" * will not be changed or removed in a backwards-incompatible manner.",
47+
" */",
48+
"public class ImplJavadocNegativeCases {",
49+
" /**",
50+
" * This class is not intended for use by application developers. Its API is stable",
51+
" * and will not be changed or removed in a backwards-incompatible manner.",
52+
" */",
53+
" public static class One {}",
54+
" // Non-public class without disclaimer is fine.",
55+
" static class Two {}",
56+
"}")
57+
.doTest();
58+
}
59+
60+
@Test
61+
void nonImplPackageIgnored() {
62+
CompilationTestHelper.newInstance(OtelImplJavadoc.class, OtelImplJavadocTest.class)
63+
.addSourceLines(
64+
"other/NonImplPackageCases.java",
65+
"/*",
66+
" * Copyright The OpenTelemetry Authors",
67+
" * SPDX-License-Identifier: Apache-2.0",
68+
" */",
69+
"package io.opentelemetry.gradle.customchecks.other;",
70+
"public class NonImplPackageCases {",
71+
" public static class One {}",
72+
"}")
73+
.doTest();
74+
}
75+
}

0 commit comments

Comments
 (0)