Skip to content

Commit 7dad902

Browse files
wu-shengclaude
andcommitted
Fix license headers and javadoc issues for CI compliance
Add Apache license headers to SPI service files and YAML config that were missing them. Fix javadoc error (HTML entity for `>` in MALExpressionModel) and add missing @throws tags in MALClassGenerator. Update DSL compiler design doc to reflect LAL ExecutionContext refactoring. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 8f02a2f commit 7dad902

File tree

8 files changed

+103
-15
lines changed

8 files changed

+103
-15
lines changed

docs/en/academy/dsl-compiler-design.md

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Phase 3: Javassist Bytecode Generation
4242
| OAL | Extends metrics function class (e.g., `LongAvgMetrics`) | `id()`, `serialize()`, `deserialize()`, plus dispatcher `dispatch(source)` |
4343
| MAL metric | `MalExpression` | `SampleFamily run(Map<String, SampleFamily> samples)` |
4444
| MAL filter | `Predicate<Map<String, String>>` | `boolean test(Map<String, String> tags)` |
45-
| LAL | `LalExpression` | `void execute(FilterSpec filterSpec, Binding binding)` |
45+
| LAL | `LalExpression` | `void execute(FilterSpec filterSpec, ExecutionContext ctx)` |
4646
| Hierarchy | `BiFunction<Service, Service, Boolean>` | `Boolean apply(Service upper, Service lower)` |
4747

4848
OAL is the most complex -- it generates **three classes per metric** (metrics class with storage annotations,
@@ -65,8 +65,9 @@ classes at build time; these are then used at runtime to parse DSL strings.
6565

6666
Javassist compiles Java source strings into bytecode but has limitations that shape the code generation:
6767

68-
- **No anonymous inner classes or lambdas** -- Callback-based APIs (e.g., LAL's `filterSpec.extractor(Consumer)`)
69-
require pre-compiling each callback as a separate `CtClass` implementing the needed interface.
68+
- **No anonymous inner classes or lambdas** -- Callback-based APIs require workarounds.
69+
LAL uses private methods called directly from `execute()` instead of Consumer callbacks.
70+
OAL pre-compiles callbacks as separate `CtClass` instances where needed.
7071
- **No generics in method bodies** -- Generated source uses raw types with explicit casts.
7172
- **Class loading anchor** -- Each DSL uses a `PackageHolder` marker class so that
7273
`ctClass.toClass(PackageHolder.class)` loads the generated class into the correct module/package
@@ -151,19 +152,12 @@ The checker mechanism:
151152
For `increase()`/`rate()` expressions, the `CounterWindow` is primed with an initial run before
152153
comparing the second run's output.
153154
- **LAL**: Runtime execution comparison -- both v1 and v2 execute with mock LogData,
154-
then compare Binding state (service, layer, tags, abort/save flags).
155+
then compare execution state (service, layer, tags, abort/save flags).
156+
For rules requiring extraLog (e.g., envoy-als), mock proto data is built from `.input.data` files
157+
and the `LALSourceTypeProvider` SPI resolves the proto type per layer.
155158
Test scripts include both copies of production configs (`oap-cases/`) and
156159
dedicated feature-coverage rules (`feature-cases/`).
157160
- **Hierarchy**: Compare `BiFunction` evaluation with test Service pairs
158161

159162
This ensures 100% behavioral parity. The Groovy v1 modules are **test-only dependencies** -- they are not
160-
included in the OAP distribution.
161-
162-
#### Current Checker Results
163-
164-
| Checker | Expressions Tested | Status |
165-
|---------|-------------------|--------|
166-
| MAL metric expressions | 1,187 | All pass (metadata + runtime execution) |
167-
| MAL filter expressions | 29 | All pass |
168-
| LAL scripts | 29 | All pass |
169-
| Hierarchy rules | 22 | All pass |
163+
included in the OAP distribution.
Original file line numberDiff line numberDiff line change
@@ -1 +1,19 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
#
18+
119
org.apache.skywalking.oap.server.core.config.v2.compiler.CompiledHierarchyRuleProvider
Original file line numberDiff line numberDiff line change
@@ -1 +1,19 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
#
18+
119
org.apache.skywalking.oap.log.analyzer.v2.compiler.TestMeshLALSourceTypeProvider

oap-server/analyzer/meter-analyzer/src/main/java/org/apache/skywalking/oap/meter/analyzer/v2/compiler/MALClassGenerator.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ private void addRunLocalVariableTable(final javassist.CtMethod method,
208208
* @param metricName the metric name (used in the generated class name)
209209
* @param expression the MAL expression string
210210
* @return a MalExpression instance
211+
* @throws Exception if parsing or compilation fails
211212
*/
212213
public MalExpression compile(final String metricName,
213214
final String expression) throws Exception {
@@ -228,6 +229,7 @@ public MalExpression compile(final String metricName,
228229
*
229230
* @param filterExpression e.g. {@code "{ tags -> tags.job_name == 'mysql-monitoring' }"}
230231
* @return a MalFilter instance
232+
* @throws Exception if parsing or compilation fails
231233
*/
232234
@SuppressWarnings("unchecked")
233235
public MalFilter compileFilter(final String filterExpression) throws Exception {
@@ -298,6 +300,11 @@ public MalFilter compileFilter(final String filterExpression) throws Exception {
298300

299301
/**
300302
* Compiles from a pre-parsed AST model.
303+
*
304+
* @param metricName the metric name (used in the generated class name)
305+
* @param ast the pre-parsed AST model
306+
* @return a MalExpression instance
307+
* @throws Exception if compilation fails
301308
*/
302309
public MalExpression compileFromModel(final String metricName,
303310
final MALExpressionModel.Expr ast) throws Exception {

oap-server/analyzer/meter-analyzer/src/main/java/org/apache/skywalking/oap/meter/analyzer/v2/compiler/MALExpressionModel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
* <pre>
2929
* metric_name.tagEqual("k","v").sum(["tag"]).rate("PT1M").service(["svc"], Layer.GENERAL)
3030
* (metric1 + metric2) * 100
31-
* metric.tag({tags -> tags.key = "val"}).histogram().histogram_percentile([50,75,90,95,99])
31+
* metric.tag({tags -&gt; tags.key = "val"}).histogram().histogram_percentile([50,75,90,95,99])
3232
* </pre>
3333
*/
3434
public final class MALExpressionModel {
Original file line numberDiff line numberDiff line change
@@ -1 +1,19 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
#
18+
119
org.apache.skywalking.oap.server.receiver.envoy.EnvoyHTTPLALSourceTypeProvider
Original file line numberDiff line numberDiff line change
@@ -1 +1,19 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
#
18+
119
org.apache.skywalking.oap.server.checker.lal.TestMeshLALSourceTypeProvider

test/script-cases/scripts/mal/test-otel-rules/service-gstring-regex-split.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one or more
2+
# contributor license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright ownership.
4+
# The ASF licenses this file to You under the Apache License, Version 2.0
5+
# (the "License"); you may not use this file except in compliance with
6+
# the License. You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
116
# Metric Values
217
# 0 = Not Satisfied
318
# 1 = Satisfied

0 commit comments

Comments
 (0)