Skip to content

Commit daef0c6

Browse files
authored
Transfer semconv code from opentelemetry-java (#1)
* Transfer semconv code from opentelemetry-java * Add gradle enterprise config * PR feedback
1 parent f8a7606 commit daef0c6

25 files changed

+5613
-0
lines changed

.editorconfig

Lines changed: 763 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash -e
2+
3+
# this script helps to reduce sporadic link check failures by retrying at a file-by-file level
4+
5+
retry_count=3
6+
7+
for file in "$@"; do
8+
for i in $(seq 1 $retry_count); do
9+
if markdown-link-check --config "$(dirname "$0")/../config/markdown-link-check-config.json" \
10+
"$file"; then
11+
break
12+
elif [[ $i -eq $retry_count ]]; then
13+
exit 1
14+
fi
15+
sleep 5
16+
done
17+
done

.github/workflows/build.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
workflow_dispatch:
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
build:
16+
name: Build
17+
runs-on: ${{ matrix.os }}
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
os:
22+
- macos-latest
23+
- ubuntu-latest
24+
test-java-version:
25+
- 8
26+
- 11
27+
- 17
28+
- 19
29+
30+
steps:
31+
- uses: actions/checkout@v3
32+
33+
- id: setup-java-test
34+
name: Set up Java ${{ matrix.test-java-version }} for tests
35+
uses: actions/setup-java@v3
36+
with:
37+
distribution: temurin
38+
java-version: ${{ matrix.test-java-version }}
39+
40+
- id: setup-java
41+
name: Set up Java for build
42+
uses: actions/setup-java@v3
43+
with:
44+
distribution: temurin
45+
java-version: 17
46+
47+
- uses: gradle/gradle-build-action@v2
48+
with:
49+
arguments: |
50+
build
51+
-PtestJavaVersion=${{ matrix.test-java-version }}
52+
-Porg.gradle.java.installations.paths=${{ steps.setup-java-test.outputs.path }},${{ steps.setup-java.outputs.path }}
53+
env:
54+
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
55+
56+
markdown-link-check:
57+
# release branches are excluded to avoid unnecessary maintenance
58+
if: ${{ !startsWith(github.ref_name, 'release/') }}
59+
uses: ./.github/workflows/reusable-markdown-link-check.yml
60+
61+
misspell-check:
62+
# release branches are excluded to avoid unnecessary maintenance
63+
if: ${{ !startsWith(github.ref_name, 'release/') }}
64+
uses: ./.github/workflows/reusable-misspell-check.yml
65+
66+
required-status-check:
67+
# markdown-link-check is not required so pull requests are not blocked if external links break
68+
# misspell-check is not required so pull requests are not blocked if the misspell dictionary is
69+
# updated
70+
needs:
71+
- build
72+
runs-on: ubuntu-latest
73+
if: always()
74+
steps:
75+
- if: |
76+
needs.build.result != 'success'
77+
run: exit 1
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Gradle wrapper validation
2+
on:
3+
pull_request:
4+
paths:
5+
- '**/gradle/wrapper/**'
6+
push:
7+
paths:
8+
- '**/gradle/wrapper/**'
9+
10+
jobs:
11+
validation:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v3
15+
16+
- uses: gradle/[email protected]
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Reusable - Markdown link check
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
markdown-link-check:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v3
11+
12+
- name: Install markdown-link-check
13+
# TODO(jack-berg): use latest when config file reading bug is fixed: https://github.com/tcort/markdown-link-check/issues/246
14+
run: npm install -g [email protected]
15+
16+
- name: Run markdown-link-check
17+
run: |
18+
find . -type f \
19+
-name '*.md' \
20+
-not -path './CHANGELOG.md' \
21+
| xargs .github/scripts/markdown-link-check-with-retry.sh
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Reusable - Misspell check
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
misspell-check:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v3
11+
12+
- name: Install misspell
13+
run: |
14+
curl -L -o install-misspell.sh https://raw.githubusercontent.com/client9/misspell/master/install-misspell.sh
15+
sh ./install-misspell.sh
16+
17+
- name: Run misspell
18+
run: bin/misspell -error .

build.gradle.kts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
plugins {
2+
id("otel.java-conventions")
3+
4+
id("otel.animalsniffer-conventions")
5+
}
6+
7+
dependencies {
8+
implementation(platform("io.opentelemetry:opentelemetry-bom:1.29.0"))
9+
implementation("io.opentelemetry:opentelemetry-api")
10+
11+
testImplementation(platform("org.junit:junit-bom:5.10.0"))
12+
testImplementation("org.junit.jupiter:junit-jupiter-api")
13+
testImplementation("org.junit.jupiter:junit-jupiter-engine")
14+
15+
testImplementation(platform("org.assertj:assertj-bom:3.24.2"))
16+
testImplementation("org.assertj:assertj-core")
17+
}

buildSrc/build.gradle.kts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
plugins {
2+
`kotlin-dsl`
3+
}
4+
5+
repositories {
6+
mavenCentral()
7+
gradlePluginPortal()
8+
mavenLocal()
9+
}
10+
11+
dependencies {
12+
implementation("com.diffplug.spotless:spotless-plugin-gradle:6.20.0")
13+
implementation("ru.vyarus:gradle-animalsniffer-plugin:1.7.1")
14+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import ru.vyarus.gradle.plugin.animalsniffer.AnimalSniffer
2+
3+
plugins {
4+
`java-library`
5+
6+
id("ru.vyarus.animalsniffer")
7+
}
8+
9+
dependencies {
10+
add("signature", "com.toasttab.android:gummy-bears-api-21:0.3.0:coreLib@signature")
11+
}
12+
13+
animalsniffer {
14+
sourceSets = listOf(java.sourceSets.main.get())
15+
}
16+
17+
tasks.withType<AnimalSniffer> {
18+
// always having declared output makes this task properly participate in tasks up-to-date checks
19+
reports.text.required.set(true)
20+
}
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
2+
3+
plugins {
4+
`java-library`
5+
6+
checkstyle
7+
eclipse
8+
idea
9+
10+
id("otel.spotless-conventions")
11+
}
12+
13+
java {
14+
toolchain {
15+
languageVersion.set(JavaLanguageVersion.of(17))
16+
}
17+
18+
withJavadocJar()
19+
withSourcesJar()
20+
}
21+
22+
checkstyle {
23+
configDirectory.set(file("$rootDir/buildscripts/"))
24+
toolVersion = "8.12"
25+
isIgnoreFailures = false
26+
configProperties["rootDir"] = rootDir
27+
}
28+
29+
val testJavaVersion = gradle.startParameter.projectProperties.get("testJavaVersion")?.let(JavaVersion::toVersion)
30+
31+
tasks {
32+
withType<JavaCompile>().configureEach {
33+
with(options) {
34+
release.set(8)
35+
36+
//disable deprecation warnings for the protobuf module
37+
compilerArgs.addAll(
38+
listOf(
39+
// Fail build on any warning
40+
"-Werror"
41+
)
42+
)
43+
44+
encoding = "UTF-8"
45+
}
46+
}
47+
48+
withType<Test>().configureEach {
49+
useJUnitPlatform()
50+
51+
if (testJavaVersion != null) {
52+
javaLauncher.set(
53+
javaToolchains.launcherFor {
54+
languageVersion.set(JavaLanguageVersion.of(testJavaVersion.majorVersion))
55+
},
56+
)
57+
}
58+
59+
testLogging {
60+
exceptionFormat = TestExceptionFormat.FULL
61+
showExceptions = true
62+
showCauses = true
63+
showStackTraces = true
64+
}
65+
}
66+
67+
withType<Javadoc>().configureEach {
68+
exclude("io/opentelemetry/**/internal/**")
69+
70+
with(options as StandardJavadocDocletOptions) {
71+
source = "8"
72+
encoding = "UTF-8"
73+
docEncoding = "UTF-8"
74+
breakIterator(true)
75+
76+
addBooleanOption("html5", true)
77+
78+
links("https://docs.oracle.com/javase/8/docs/api/")
79+
addBooleanOption("Xdoclint:all,-missing", true)
80+
}
81+
}
82+
83+
withType<Jar>().configureEach {
84+
manifest {
85+
attributes(
86+
"Automatic-Module-Name" to "io.opentelemetry.semconv",
87+
"Built-By" to System.getProperty("user.name"),
88+
"Built-JDK" to System.getProperty("java.version"),
89+
"Implementation-Title" to project.name,
90+
"Implementation-Version" to project.version)
91+
}
92+
}
93+
94+
afterEvaluate {
95+
withType<Javadoc>().configureEach {
96+
with(options as StandardJavadocDocletOptions) {
97+
val title = "${project.description}"
98+
docTitle = title
99+
windowTitle = title
100+
}
101+
}
102+
}
103+
}
104+
105+
configurations.configureEach {
106+
resolutionStrategy {
107+
failOnVersionConflict()
108+
}
109+
}

0 commit comments

Comments
 (0)