Route LAL rules within a layer by input type; add envoy-als-tcp rule#13955
Merged
Conversation
LAL rules within a layer now dispatch by their effective input type, so a single layer can host rules over different proto inputs. Each compiled rule carries the proto class its parsed.* getters cast to (null for parser-based or untyped rules), and LogFilterListener skips any rule whose type does not match the incoming log instead of running every rule in the layer. This fixes a latent ClassCastException on the MESH layer (caught and logged per log) that fired whenever a log of one shape reached a rule compiled for another - e.g. an Envoy TCP access log, or a network-profiling LogData, hitting the HTTP envoy-als rule. Adds an envoy-als-tcp rule (inputType: TCPAccessLogEntry) alongside the existing HTTP envoy-als; both share the MESH layer and each now only sees its own entry type. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This pull request updates the Log Analyzer (LAL) runtime to route rules within the same telemetry layer by each rule’s effective input type, preventing cross-proto evaluation that can trigger ClassCastException when multiple input shapes share a layer (notably Layer.MESH). It also adds a TCP Envoy ALS rule to complement the existing HTTP rule.
Changes:
- Add input-type-aware rule dispatch in
LogFilterListenerby skipping rules whose effective input type doesn’t match the incoming log object. - Thread “effective input type” from compile-time (
LALClassGenerator) into runtime rule metadata (DSL) for routing. - Add
envoy-als-tcpLAL rule plus unit/data-driven tests, and document the behavior change indocs/en/changes/changes.md.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| oap-server/server-starter/src/main/resources/lal/envoy-als.yaml | Adds the new envoy-als-tcp rule (typed to TCPAccessLogEntry) alongside existing MESH rules. |
| oap-server/analyzer/log-analyzer/src/test/resources/scripts/lal/test-lal/oap-cases/envoy-als.yaml | Mirrors the shipped rules for script-based test execution cases, including envoy-als-tcp. |
| oap-server/analyzer/log-analyzer/src/test/resources/scripts/lal/test-lal/oap-cases/envoy-als.data.yaml | Adds data-driven execution cases for envoy-als-tcp. |
| oap-server/analyzer/log-analyzer/src/test/java/org/apache/skywalking/oap/log/analyzer/v2/provider/log/listener/LogFilterListenerRoutingTest.java | Adds unit tests asserting typed rules only run for matching proto inputs, while untyped/parser rules still run. |
| oap-server/analyzer/log-analyzer/src/test/java/org/apache/skywalking/oap/log/analyzer/v2/compiler/LALClassGeneratorExtractorTest.java | Adds tests for effective input type derivation and a compile guard for the new TCP rule’s parsed.* chains. |
| oap-server/analyzer/log-analyzer/src/main/java/org/apache/skywalking/oap/log/analyzer/v2/provider/log/listener/LogFilterListener.java | Implements per-log active rule selection based on dsl.getInputType().isInstance(input). |
| oap-server/analyzer/log-analyzer/src/main/java/org/apache/skywalking/oap/log/analyzer/v2/dsl/DSL.java | Stores the compile-derived effective input type on each compiled rule for runtime routing. |
| oap-server/analyzer/log-analyzer/src/main/java/org/apache/skywalking/oap/log/analyzer/v2/compiler/LALClassGenerator.java | Derives and exposes effectiveInputType (null when a parser is present) during compilation. |
| docs/en/changes/changes.md | Documents the new routing behavior and the addition of envoy-als-tcp. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…e comment - Rename DSL#inputType / getInputType() to effectiveInputType / getEffectiveInputType() so it reads clearly as the effective (parsed.* cast) type, distinct from the declared/resolved input type (LALConfig#getInputType / LalTestRule#getInputType). Updates the caller in LogFilterListener and the routing test. - Fix a stale comment in envoy-als.data.yaml that referenced connection byte-count tags the rule no longer sets (it only tags response.flag). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
mrproliu
approved these changes
Jul 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Route LAL rules within a layer by input type; add
envoy-als-tcpLAL rules keyed to the same telemetry layer are all evaluated against every log of
that layer. When a layer carries more than one proto input shape this breaks: the
generated
parsed.*code casts the input unconditionally, so a rule compiled for oneproto throws
ClassCastExceptionon another. OnLayer.MESHboth HTTP and TCP Envoyaccess logs (and network-profiling
LogData) share the bucket, so the HTTPenvoy-alsrule already throws — caught in
LogFilterListener.build()and logged per log — whenevera TCP entry or a network-profiling log arrives.
This PR makes rule dispatch input-type aware:
parsed.*getters cast to, ornullfor parser-based (json/yaml/text) anduntyped rules, which continue to run against any input. Derived once at compile time
in
LALClassGeneratorand threaded onto theDSL.LogFilterListener.parse()skips any rule whose declared input type does not match theincoming object (
inputType.isInstance(input)), so each entry only reaches the rulesmeant for it. This removes the latent
ClassCastExceptionand the per-log WARN spam.such as
network-profiling-slow-trace(whose SPI-resolved type isHTTPAccessLogEntrybut which reads a parsed map) is never wrongly filtered.
Adds an
envoy-als-tcprule (inputType: io.envoyproxy.envoy.data.accesslog.v3.TCPAccessLogEntry)alongside the existing HTTP
envoy-als; both shareLayer.MESHand each now only seesits own entry type. TCP entries have no HTTP status code, so the rule filters on
commonProperties.responseFlagsand samples byservice:responseFlags.New feature / behavior
inputType+LALSourceTypeProviderSPImechanism (documented in
oap-server/analyzer/log-analyzer/CLAUDE.md); no separate design doc.Also fixes a latent bug
LogFilterListenerRoutingTest):an HTTP entry reaches only the HTTP + parser rules, a TCP entry only the TCP + parser rules,
no cross-type
ClassCastException.parsed.*codegen emits an unguarded proto cast, and every rule in a layerruns against every input; fix routes by the rule's effective input type before evaluation.
Tests added
LogFilterListenerRoutingTest— routing selection (3 cases).LALClassGeneratorExtractorTest—effectiveInputTypederivation (parser ⇒null) and acompile guard for the shipped
envoy-als-tcprule againstTCPAccessLogEntry.envoy-als-tcpdata-driven execution cases inLALScriptExecutionTest(abnormal ⇒ tag +save; normal ⇒ abort).
If this pull request closes/resolves/fixes an existing issue, replace the issue number. Closes #.
Update the
CHANGESlog.🤖 Generated with Claude Code