|
1 | 1 | #!/bin/bash -e |
2 | 2 |
|
3 | | -for dir in $(find instrumentation -name "*.java" | grep library/src/main/java | sed 's#/[^/]*$##' | sort -u); do |
| 3 | +check_source_set() { |
| 4 | + local source_set="$1" |
| 5 | + shift |
| 6 | + local expected_prefixes=("$@") |
4 | 7 |
|
5 | | - module_name=$(echo "$dir" | sed 's#.*/\([^/]*\)/library/src/main/java[0-9]*/.*#\1#') |
| 8 | + for dir in $(find instrumentation -name "*.java" | grep "/$source_set/src/main/java" | sed 's#/[^/]*$##' | sort -u); do |
6 | 9 |
|
7 | | - if [[ "$module_name" =~ ^java- ]]; then |
8 | | - continue |
9 | | - fi |
10 | | - if [[ "$module_name" == "jmx-metrics" ]]; then |
11 | | - continue |
12 | | - fi |
13 | | - if [[ "$module_name" == "runtime-telemetry" ]]; then |
14 | | - continue |
15 | | - fi |
16 | | - if [[ "$module_name" == "servlet-common" ]]; then |
17 | | - continue |
18 | | - fi |
19 | | - if [[ "$module_name" == "graphql-java-common-12.0" ]]; then |
20 | | - continue |
21 | | - fi |
| 10 | + module_name=$(echo "$dir" | sed "s#.*/\([^/]*\)/$source_set/src/main/java[0-9]*/.*#\1#") |
22 | 11 |
|
23 | | - # these are possibly problematic |
24 | | - if [[ "$dir" == "instrumentation/grpc-1.6/library/src/main/java/io/grpc/override" ]]; then |
25 | | - continue |
26 | | - fi |
27 | | - if [[ "$dir" == "instrumentation/lettuce/lettuce-5.1/library/src/main/java/io/lettuce/core/protocol" ]]; then |
28 | | - continue |
29 | | - fi |
30 | | - if [[ "$dir" == "instrumentation/nats/nats-2.17/library/src/main/java/io/nats/client/impl" ]]; then |
31 | | - continue |
32 | | - fi |
33 | | - if [[ "$dir" == "instrumentation/rxjava/rxjava-1.0/library/src/main/java/rx" ]]; then |
34 | | - continue |
35 | | - fi |
| 12 | + if [[ "$module_name" =~ ^java- ]]; then |
| 13 | + continue |
| 14 | + fi |
| 15 | + if [[ "$module_name" == "jmx-metrics" ]]; then |
| 16 | + continue |
| 17 | + fi |
| 18 | + if [[ "$module_name" == "runtime-telemetry" ]]; then |
| 19 | + continue |
| 20 | + fi |
| 21 | + if [[ "$module_name" == "servlet-common" ]]; then |
| 22 | + continue |
| 23 | + fi |
| 24 | + if [[ "$module_name" == "graphql-java-common-12.0" ]]; then |
| 25 | + continue |
| 26 | + fi |
36 | 27 |
|
37 | | - # some common modules don't have any base version (might have a variant instead, ex: javax) |
38 | | - # - jdbc |
39 | | - # - lettuce-common |
40 | | - # - netty-common |
41 | | - # - oshi |
42 | | - # - resources |
43 | | - # - servlet-common-javax |
44 | | - if [[ ! "$module_name" =~ [0-9]$ && "$module_name" != "jdbc" && "$module_name" != "lettuce-common" && "$module_name" != "netty-common" && "$module_name" != "oshi" && "$module_name" != "resources" && "$module_name" != "servlet-common-javax" ]]; then |
45 | | - echo "module name doesn't have a base version: $dir" |
46 | | - exit 1 |
47 | | - fi |
| 28 | + # these are possibly problematic |
| 29 | + if [[ "$source_set" == "library" ]]; then |
| 30 | + if [[ "$dir" == "instrumentation/grpc-1.6/library/src/main/java/io/grpc/override" ]]; then |
| 31 | + continue |
| 32 | + fi |
| 33 | + if [[ "$dir" == "instrumentation/lettuce/lettuce-5.1/library/src/main/java/io/lettuce/core/protocol" ]]; then |
| 34 | + continue |
| 35 | + fi |
| 36 | + if [[ "$dir" == "instrumentation/nats/nats-2.17/library/src/main/java/io/nats/client/impl" ]]; then |
| 37 | + continue |
| 38 | + fi |
| 39 | + if [[ "$dir" == "instrumentation/rxjava/rxjava-1.0/library/src/main/java/rx" ]]; then |
| 40 | + continue |
| 41 | + fi |
| 42 | + fi |
48 | 43 |
|
49 | | - # convention: if module ends with -java (followed by version), remove -java from the package name |
50 | | - simple_module_name=$(echo "$module_name" | sed 's/-[0-9.]*$//' | sed 's/-java$//' | sed 's/-//g') |
51 | | - base_version=$(echo "$module_name" | sed 's/.*-\([0-9.]*\)$/\1/' | sed 's/\./_/g') |
| 44 | + if [[ "$source_set" == "javaagent" ]]; then |
| 45 | + # advice packages that must live under the instrumented library's own namespace |
| 46 | + case "$dir" in |
| 47 | + instrumentation/clickhouse/clickhouse-client-v1-0.5/javaagent/src/main/java/com/clickhouse/client*) continue ;; |
| 48 | + instrumentation/finagle-http-23.11/javaagent/src/main/java/com/twitter/finagle*) continue ;; |
| 49 | + instrumentation/finagle-http-23.11/javaagent/src/main/java/io/netty/channel*) continue ;; |
| 50 | + instrumentation/reactor/reactor-netty/reactor-netty-1.0/javaagent/src/main/java/reactor/netty/http/client*) continue ;; |
| 51 | + instrumentation/spring/spring-webmvc/spring-webmvc-3.1/javaagent/src/main/java/org/springframework/web/servlet/v3_1*) continue ;; |
| 52 | + instrumentation/spring/spring-webmvc/spring-webmvc-6.0/javaagent/src/main/java/org/springframework/web/servlet/v6_0*) continue ;; |
| 53 | + instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/vertx/redis/client/impl*) continue ;; |
| 54 | + instrumentation/vertx/vertx-sql-client/vertx-sql-client-common-4.0/javaagent/src/main/java/io/vertx/sqlclient/impl*) continue ;; |
| 55 | + esac |
52 | 56 |
|
53 | | - if [[ "$module_name" =~ [0-9]$ ]]; then |
54 | | - expected_package_name="io/opentelemetry/instrumentation/$simple_module_name/v$base_version" |
55 | | - else |
56 | | - expected_package_name="io/opentelemetry/instrumentation/$simple_module_name" |
57 | | - fi |
| 57 | + # historical javaagent modules that do not follow the module-name <-> package-name convention |
| 58 | + case "$dir" in |
| 59 | + instrumentation/akka/akka-actor-fork-join-2.5/javaagent/*) continue ;; |
| 60 | + instrumentation/akka/akka-http-10.0/javaagent/*) continue ;; |
| 61 | + instrumentation/aws-sdk/aws-sdk-1.11/javaagent/*) continue ;; |
| 62 | + instrumentation/aws-sdk/aws-sdk-2.2/javaagent/*) continue ;; |
| 63 | + instrumentation/camel-2.20/javaagent/*) continue ;; |
| 64 | + instrumentation/clickhouse/clickhouse-client-common/javaagent/*) continue ;; |
| 65 | + instrumentation/elasticsearch/elasticsearch-api-client-7.16/javaagent/*) continue ;; |
| 66 | + instrumentation/elasticsearch/elasticsearch-rest-common-5.0/javaagent/*) continue ;; |
| 67 | + instrumentation/elasticsearch/elasticsearch-transport-common/javaagent/*) continue ;; |
| 68 | + instrumentation/external-annotations/javaagent/*) continue ;; |
| 69 | + instrumentation/hibernate/hibernate-procedure-call-4.3/javaagent/*) continue ;; |
| 70 | + instrumentation/internal/internal-application-logger/javaagent/*) continue ;; |
| 71 | + instrumentation/internal/internal-eclipse-osgi-3.6/javaagent/*) continue ;; |
| 72 | + instrumentation/jaxrs/jaxrs-2.0/jaxrs-2.0-annotations/javaagent/*) continue ;; |
| 73 | + instrumentation/jaxrs/jaxrs-2.0/jaxrs-2.0-common/javaagent/*) continue ;; |
| 74 | + instrumentation/jaxrs/jaxrs-3.0/jaxrs-3.0-annotations/javaagent/*) continue ;; |
| 75 | + instrumentation/jaxrs/jaxrs-3.0/jaxrs-3.0-common/javaagent/*) continue ;; |
| 76 | + instrumentation/jaxrs/jaxrs-common/javaagent/*) continue ;; |
| 77 | + instrumentation/jaxws/jaxws-jws-api-1.1/javaagent/*) continue ;; |
| 78 | + instrumentation/jsf/jsf-mojarra-1.2/javaagent/*) continue ;; |
| 79 | + instrumentation/jsf/jsf-mojarra-3.0/javaagent/*) continue ;; |
| 80 | + instrumentation/jsf/jsf-myfaces-1.2/javaagent/*) continue ;; |
| 81 | + instrumentation/jsf/jsf-myfaces-3.0/javaagent/*) continue ;; |
| 82 | + instrumentation/kotlinx-coroutines/kotlinx-coroutines-1.0/javaagent/*) continue ;; |
| 83 | + instrumentation/kotlinx-coroutines/kotlinx-coroutines-flow-1.3/javaagent/*) continue ;; |
| 84 | + instrumentation/liberty/liberty-dispatcher-20.0/javaagent/*) continue ;; |
| 85 | + instrumentation/opensearch/opensearch-rest-common/javaagent/*) continue ;; |
| 86 | + instrumentation/opentelemetry-api/opentelemetry-api-1.0/javaagent/*) continue ;; |
| 87 | + instrumentation/opentelemetry-extension-annotations-1.0/javaagent/*) continue ;; |
| 88 | + instrumentation/opentelemetry-extension-kotlin-1.0/javaagent/*) continue ;; |
| 89 | + instrumentation/opentelemetry-instrumentation-annotations-1.16/javaagent/*) continue ;; |
| 90 | + instrumentation/opentelemetry-instrumentation-api/javaagent/*) continue ;; |
| 91 | + instrumentation/play/play-mvc/play-mvc-2.4/javaagent/*) continue ;; |
| 92 | + instrumentation/play/play-mvc/play-mvc-2.6/javaagent/*) continue ;; |
| 93 | + instrumentation/play/play-ws/play-ws-common/javaagent/*) continue ;; |
| 94 | + instrumentation/scala-fork-join-2.8/javaagent/*) continue ;; |
| 95 | + instrumentation/spark-2.3/javaagent/*) continue ;; |
| 96 | + instrumentation/spring/spring-boot-actuator-autoconfigure-2.0/javaagent/*) continue ;; |
| 97 | + instrumentation/spring/spring-boot-resources/javaagent/*) continue ;; |
| 98 | + esac |
| 99 | + fi |
58 | 100 |
|
59 | | - package_name=$(echo "$dir" | sed 's#.*/src/main/java[0-9]*/##') |
| 101 | + if [[ "$source_set" == "testing" ]]; then |
| 102 | + # historical testing source sets that do not follow the module-name <-> package-name convention |
| 103 | + case "$dir" in |
| 104 | + instrumentation/alibaba-druid-1.0/testing/*) continue ;; |
| 105 | + instrumentation/apache-dbcp-2.0/testing/*) continue ;; |
| 106 | + instrumentation/c3p0-0.9/testing/*) continue ;; |
| 107 | + instrumentation/cassandra/cassandra-4.4/testing/*) continue ;; |
| 108 | + instrumentation/cassandra/cassandra-common-4.0/testing/*) continue ;; |
| 109 | + instrumentation/couchbase/couchbase-common/testing/*) continue ;; |
| 110 | + instrumentation/elasticsearch/elasticsearch-transport-common/testing/*) continue ;; |
| 111 | + instrumentation/hikaricp-3.0/testing/*) continue ;; |
| 112 | + instrumentation/jaxrs/jaxrs-2.0/jaxrs-2.0-common/testing/*) continue ;; |
| 113 | + instrumentation/jaxrs/jaxrs-3.0/jaxrs-3.0-common/testing/*) continue ;; |
| 114 | + instrumentation/jaxrs/jaxrs-common/testing/*) continue ;; |
| 115 | + instrumentation/jedis/jedis-1.4/testing/*) continue ;; |
| 116 | + instrumentation/kafka/kafka-clients/kafka-clients-0.11/testing/*) continue ;; |
| 117 | + instrumentation/log4j/log4j-context-data/log4j-context-data-common/testing/*) continue ;; |
| 118 | + instrumentation/mongo/mongo-common/testing/*) continue ;; |
| 119 | + instrumentation/opensearch/opensearch-rest-common/testing/*) continue ;; |
| 120 | + instrumentation/opentelemetry-api/opentelemetry-api-1.0/testing/*) continue ;; |
| 121 | + instrumentation/opentelemetry-instrumentation-api/testing/*) continue ;; |
| 122 | + instrumentation/oracle-ucp-11.2/testing/*) continue ;; |
| 123 | + instrumentation/play/play-ws/play-ws-common/testing/*) continue ;; |
| 124 | + instrumentation/ratpack/ratpack-1.4/testing/*) continue ;; |
| 125 | + instrumentation/reactor/reactor-3.1/testing/*) continue ;; |
| 126 | + instrumentation/redisson/redisson-common-3.0/testing/*) continue ;; |
| 127 | + instrumentation/spring/spring-boot-autoconfigure/testing/*) continue ;; |
| 128 | + instrumentation/spring/spring-cloud-gateway/spring-cloud-gateway-common/testing/*) continue ;; |
| 129 | + instrumentation/spring/spring-data/spring-data-common/testing/*) continue ;; |
| 130 | + instrumentation/spring/spring-kafka-2.7/testing/*) continue ;; |
| 131 | + instrumentation/spring/spring-webflux/spring-webflux-5.0/testing/*) continue ;; |
| 132 | + instrumentation/spring/spring-webflux/spring-webflux-5.3/testing/*) continue ;; |
| 133 | + instrumentation/spring/spring-webmvc/spring-webmvc-common/testing/*) continue ;; |
| 134 | + instrumentation/vaadin-14.2/testing/*) continue ;; |
| 135 | + instrumentation/vertx/vertx-kafka-client-3.6/testing/*) continue ;; |
| 136 | + instrumentation/vibur-dbcp-11.0/testing/*) continue ;; |
| 137 | + esac |
| 138 | + fi |
60 | 139 |
|
61 | | - # deal with differences like module name elasticsearch-rest and package name elasticsearch.rest |
62 | | - expected_package_name_normalized=$(echo "$expected_package_name" | sed 's#/##g') |
63 | | - package_name_normalized=$(echo "$package_name" | sed 's#/##g') |
| 140 | + # some common modules don't have any base version (might have a variant instead, ex: javax) |
| 141 | + if [[ ! "$module_name" =~ [0-9]$ ]]; then |
| 142 | + case "$source_set:$module_name" in |
| 143 | + # library: |
| 144 | + library:jdbc) ;; |
| 145 | + library:lettuce-common) ;; |
| 146 | + library:netty-common) ;; |
| 147 | + library:oshi) ;; |
| 148 | + library:resources) ;; |
| 149 | + library:servlet-common-javax) ;; |
| 150 | + # javaagent: |
| 151 | + javaagent:clickhouse-client-common) ;; |
| 152 | + javaagent:elasticsearch-transport-common) ;; |
| 153 | + javaagent:executors) ;; |
| 154 | + javaagent:external-annotations) ;; |
| 155 | + javaagent:http-url-connection) ;; |
| 156 | + javaagent:internal-application-logger) ;; |
| 157 | + javaagent:internal-class-loader) ;; |
| 158 | + javaagent:internal-lambda) ;; |
| 159 | + javaagent:internal-reflection) ;; |
| 160 | + javaagent:internal-url-class-loader) ;; |
| 161 | + javaagent:jaxrs-common) ;; |
| 162 | + javaagent:jdbc) ;; |
| 163 | + javaagent:jetty-common) ;; |
| 164 | + javaagent:jsf-common-jakarta) ;; |
| 165 | + javaagent:jsf-common-javax) ;; |
| 166 | + javaagent:methods) ;; |
| 167 | + javaagent:opensearch-rest-common) ;; |
| 168 | + javaagent:opentelemetry-instrumentation-api) ;; |
| 169 | + javaagent:oshi) ;; |
| 170 | + javaagent:payara) ;; |
| 171 | + javaagent:play-ws-common) ;; |
| 172 | + javaagent:quarkus-resteasy-reactive) ;; |
| 173 | + javaagent:rmi) ;; |
| 174 | + javaagent:spring-boot-resources) ;; |
| 175 | + javaagent:spring-cloud-gateway-common) ;; |
| 176 | + javaagent:spring-webmvc-common) ;; |
| 177 | + javaagent:tomcat-common) ;; |
| 178 | + javaagent:tomcat-jdbc) ;; |
| 179 | + # testing: |
| 180 | + testing:couchbase-common) ;; |
| 181 | + testing:elasticsearch-transport-common) ;; |
| 182 | + testing:executors) ;; |
| 183 | + testing:hibernate) ;; |
| 184 | + testing:javalin) ;; |
| 185 | + testing:jaxrs-2.0-common) ;; |
| 186 | + testing:jaxrs-3.0-common) ;; |
| 187 | + testing:jaxrs-common) ;; |
| 188 | + testing:jdbc) ;; |
| 189 | + testing:jsf-common-jakarta) ;; |
| 190 | + testing:jsf-common-javax) ;; |
| 191 | + testing:log4j-context-data-common) ;; |
| 192 | + testing:mongo-common) ;; |
| 193 | + testing:opensearch-rest-common) ;; |
| 194 | + testing:opentelemetry-instrumentation-api) ;; |
| 195 | + testing:oshi) ;; |
| 196 | + testing:play-ws-common) ;; |
| 197 | + testing:spring-boot-autoconfigure) ;; |
| 198 | + testing:spring-cloud-gateway-common) ;; |
| 199 | + testing:spring-data-common) ;; |
| 200 | + testing:spring-webmvc-common) ;; |
| 201 | + *) |
| 202 | + echo "module name doesn't have a base version: $dir" |
| 203 | + exit 1 |
| 204 | + ;; |
| 205 | + esac |
| 206 | + fi |
64 | 207 |
|
65 | | - if [[ "$package_name_normalized" != "$expected_package_name_normalized"* ]]; then |
66 | | - echo "ERROR: $dir" |
67 | | - exit 1 |
68 | | - fi |
| 208 | + # build expected package name by walking the module name's dash-separated tokens: |
| 209 | + # a version token (e.g. "3.0") becomes "/v3_0", any other token becomes "/<token>"; |
| 210 | + # the literal token "java" is elided (e.g. graphql-java-20.0 -> graphql/v20_0). |
| 211 | + # this also handles multi-version modules like jaxrs-2.0-resteasy-3.1 -> jaxrs/v2_0/resteasy/v3_1. |
| 212 | + expected_module_path="" |
| 213 | + IFS='-' read -ra module_parts <<< "$module_name" |
| 214 | + for part in "${module_parts[@]}"; do |
| 215 | + if [[ "$part" == "java" ]]; then |
| 216 | + continue |
| 217 | + fi |
| 218 | + if [[ "$part" =~ ^[0-9][0-9.]*$ ]]; then |
| 219 | + expected_module_path="$expected_module_path/v${part//./_}" |
| 220 | + else |
| 221 | + expected_module_path="$expected_module_path/$part" |
| 222 | + fi |
| 223 | + done |
69 | 224 |
|
70 | | -done |
| 225 | + package_name=$(echo "$dir" | sed 's#.*/src/main/java[0-9]*/##') |
| 226 | + package_name_normalized=$(echo "$package_name" | sed 's#/##g') |
| 227 | + |
| 228 | + # accept if package starts with any of the allowed prefixes followed by the module path |
| 229 | + matched=0 |
| 230 | + for expected_prefix in "${expected_prefixes[@]}"; do |
| 231 | + expected_package_name="$expected_prefix$expected_module_path" |
| 232 | + # deal with differences like module name elasticsearch-rest and package name elasticsearch.rest |
| 233 | + expected_package_name_normalized=$(echo "$expected_package_name" | sed 's#/##g') |
| 234 | + if [[ "$package_name_normalized" == "$expected_package_name_normalized"* ]]; then |
| 235 | + matched=1 |
| 236 | + break |
| 237 | + fi |
| 238 | + done |
| 239 | + |
| 240 | + if [[ "$matched" == 0 ]]; then |
| 241 | + echo "ERROR: $dir" |
| 242 | + exit 1 |
| 243 | + fi |
| 244 | + |
| 245 | + done |
| 246 | +} |
| 247 | + |
| 248 | +check_source_set "library" "io/opentelemetry/instrumentation" |
| 249 | +check_source_set "javaagent" "io/opentelemetry/javaagent/instrumentation" |
| 250 | +check_source_set "testing" "io/opentelemetry/instrumentation" "io/opentelemetry/javaagent/instrumentation" |
0 commit comments