This file provides guidance for AI assistants working with the Apache SkyWalking codebase.
Apache SkyWalking is an open-source APM (Application Performance Monitoring) system designed for microservices, cloud-native, and container-based architectures. It provides distributed tracing, service mesh telemetry analysis, metrics aggregation, alerting, and observability capabilities.
skywalking/
├── oap-server/ # OAP (Observability Analysis Platform) backend server
│ ├── server-core/ # Core module with fundamental services
│ ├── server-library/ # Shared libraries (module system, util, etc.)
│ ├── server-receiver-plugin/ # Data receivers (gRPC, HTTP, Kafka, etc.)
│ ├── server-storage-plugin/ # Storage implementations (BanyanDB, Elasticsearch, etc.)
│ ├── server-cluster-plugin/ # Cluster coordination (Zookeeper, K8s, etc.)
│ ├── server-query-plugin/ # Query interfaces (GraphQL)
│ ├── server-alarm-plugin/ # Alerting system
│ ├── server-fetcher-plugin/ # Data fetchers
│ ├── server-configuration/ # Dynamic configuration providers
│ ├── oal-grammar/ # OAL (Observability Analysis Language) grammar
│ ├── oal-rt/ # OAL runtime
│ ├── mqe-grammar/ # MQE (Metrics Query Engine) grammar
│ ├── mqe-rt/ # MQE runtime
│ ├── server-testing/ # Shared test utilities (DSL test framework)
│ ├── analyzer/ # Log and trace analyzers
│ ├── ai-pipeline/ # AI/ML pipeline components
│ └── exporter/ # Data export functionality
├── apm-protocol/ # Protocol definitions (submodule)
│ └── apm-network/ # gRPC/Protobuf network protocols
├── skywalking-ui/ # Web UI (submodule - skywalking-booster-ui)
├── apm-webapp/ # Web application packaging
├── apm-dist/ # Distribution packaging
├── docs/ # Documentation
├── docker/ # Docker build files
├── test/ # E2E and integration tests
└── tools/ # Development tools
SkyWalking uses a custom module/provider architecture based on Java SPI:
- ModuleDefine: Declares a module and its required services
- ModuleProvider: Implements a module with specific technology/approach
- Service: Interface that modules expose to other modules
Key pattern:
public class XxxModule extends ModuleDefine {
public Class[] services() {
return new Class[] { XxxService.class };
}
}
public class XxxModuleProvider extends ModuleProvider {
public void prepare() { /* initialize */ }
public void start() { /* start services */ }
}- OAL (Observability Analysis Language): DSL for defining metrics aggregation rules
- MQE (Metrics Query Engine): DSL for querying metrics
- LAL (Log Analysis Language): DSL for log processing
- MAL (Meter Analysis Language): DSL for meter data processing
- Source/Scope: Data model definitions for telemetry data
- Stream Processing: Metrics, Records, and TopN processing pipelines
- Agents/Collectors send data via gRPC/HTTP/Kafka
- Receiver plugins parse and validate data
- Analysis engine processes data using OAL/LAL/MAL
- Storage plugins persist aggregated data
- Query plugins serve data to UI/API
Prohibited patterns:
- No
System.out.println- use proper logging (SLF4J) - No
@authortags - ASF projects don't use author annotations - No Chinese characters in source files
- No tab characters (use 4 spaces)
- No star imports (
import xxx.*) - No unused or redundant imports
- No empty statements (standalone
;)
Required patterns:
@Overrideannotation required for overridden methodsequals()andhashCode()must be overridden together- Javadoc
@param,@return,@throwsmust have descriptions - Long constants must use uppercase
L(e.g.,100Lnot100l) defaultcase must come last in switch statements- One statement per line
Naming conventions:
- Constants/static variables:
UPPER_CASE_WITH_UNDERSCORES - Type parameters:
UPPER_CASE(e.g.,TYPE,KEY,VALUE) - Package names:
org.apache.skywalking.*ortest.apache.skywalking.* - Type names:
PascalCaseorUPPER_CASE_WITH_UNDERSCORES - Local variables/parameters/members:
camelCase
File limits:
- Max file length: 3000 lines
Whitespace:
- Whitespace required after commas, semicolons, type casts
- Whitespace required around operators
- No multiple consecutive blank lines
- Empty line separators between class members (fields can be grouped)
Indentation:
- 4-space indentation
- 4-space continuation indent
Imports:
- No star imports (threshold set to 999)
- Import order: regular imports, blank line, static imports
Formatting:
whilein do-while on new line- Align multiline chained method calls
- Align multiline parameters in calls
- Array initializer braces on new lines
- Wrap long method call chains
General:
- Use
finalfor local variables and parameters - Use Lombok annotations (
@Getter,@Setter,@Builder,@Data,@Slf4j, etc.) - Follow existing patterns in similar files
Java, XML, and YAML/YML files must include the Apache 2.0 license header (see HEADER file).
JSON and Markdown files are excluded (JSON doesn't support comments, see .licenserc.yaml).
All code must be compatible with JDK 11 (LTS). The project supports JDK 11, 17, and 21.
Prohibited Java features (post-JDK 11):
| Feature | JDK Version | Use Instead |
|---|---|---|
Switch expressions (->) |
14+ | Traditional switch with case: and break |
Stream.toList() |
16+ | .collect(Collectors.toList()) |
Text blocks ("""...""") |
15+ | String concatenation or + |
| Records | 14+ | Regular classes with Lombok @Data |
Pattern matching for instanceof |
14+ | Traditional cast after instanceof |
| Sealed classes/interfaces | 15+ | Regular classes/interfaces |
Allowed Java features (JDK 11 compatible):
List.of(),Set.of(),Map.of()- Immutable collections (Java 9+)Optionalmethods -orElseThrow(),ifPresentOrElse()(Java 9+)- Lambda expressions and method references (Java 8+)
- Stream API (Java 8+)
- Lombok annotations (
@Getter,@Builder,@Data,@Slf4j)
Verification commands:
# Check for switch expressions (should return no matches)
grep -r "switch.*->" src/ --include="*.java"
# Check for Stream.toList() (should return no matches)
grep -r "\.toList()" src/ --include="*.java"
# Check for text blocks (should return no matches)
grep -r '"""' src/ --include="*.java"The project uses submodules for protocol definitions and UI:
apm-protocol/apm-network/src/main/proto- skywalking-data-collect-protocoloap-server/server-query-plugin/.../query-protocol- skywalking-query-protocolskywalking-ui- skywalking-booster-uioap-server/server-library/library-banyandb-client/src/main/proto- banyandb-client-proto
Always use --recurse-submodules when cloning or update submodules manually.
oap-server/server-core/src/main/java/.../CoreModule.java- Core module definitionoap-server/server-library/library-module/src/main/java/.../ModuleDefine.java- Module system baseoap-server/oal-grammar/src/main/antlr4/.../OALParser.g4- OAL grammar definitionoap-server/server-starter/- Application entry pointdocs/en/concepts-and-designs/- Architecture documentation
- Create module in
server-receiver-plugin/ - Implement
ModuleDefineandModuleProvider - Register via SPI in
META-INF/services/ - Add configuration to
application.yml
- Create module in
server-storage-plugin/ - Implement storage DAOs for each data type
- Follow existing plugin patterns (e.g., BanyanDB, elasticsearch)
- Edit
.oalfiles inoap-server/server-starter/src/main/resources/oal/ - Regenerate by building the project
- Update storage schema if needed
otel-rules/- OpenTelemetry metrics (Prometheus, etc.)meter-analyzer-config/- SkyWalking native meter protocol
lal/- Log processing ruleslog-mal-rules/- Metrics extracted from logs
concepts-and-designs/- Architecture and core concepts (OAL, MAL, LAL, profiling)setup/- Installation and configuration guidesapi/- Telemetry and query protocol documentationguides/- Contributing guides, build instructions, testingchanges/changes.md- Changelog (update when making changes)swip/- SkyWalking Improvement Proposals
Use the /gh-pull-request skill for committing and pushing to a PR branch. It runs pre-flight checks (compile, checkstyle, license headers) before every push, and creates the PR if one doesn't exist yet.
Apache enforces an allow list for third-party GitHub Actions. All third-party actions must be pinned to an approved SHA from: https://github.com/apache/infrastructure-actions/blob/main/approved_patterns.yml
If a PR is blocked by "action is not allowed" errors, check the approved list and update .github/workflows/ files to use the approved SHA pin instead of a version tag.
Actions owned by actions/* (GitHub), github/*, and apache/* are always allowed (enterprise-owned).
- Always check submodules: Protocol changes may require submodule updates
- Generate sources first: Run
mvnw compilebefore analyzing generated code - Install package: Use
mvnw flatten:flatten installto build the precompiler and export generated classes before running tests. ref to compile skill doc - Respect checkstyle: No System.out, no @author, no Chinese characters
- Follow module patterns: Use existing modules as templates
- Check multiple storage implementations: Logic may vary by storage type
- OAL generates code: Don't manually edit generated metrics classes
- Use Lombok: Prefer annotations over boilerplate code
- Test both unit and integration: Different test patterns for different scopes
- Documentation is rendered via markdown: When reviewing docs, consider how they will be rendered by a markdown engine
- Relative paths in docs are valid: Relative file paths (e.g.,
../../../oap-server/...) in documentation work both in the repo and on the documentation website, supported by website build tooling
Never guess or speculate. All analysis must be grounded in source code, documentation, or verified behavior.
- Read the source code — don't assume how a feature works based on naming or convention. Check the actual implementation.
- Read the documentation — check
docs/en/, CLAUDE.md files in submodules, and README files before proposing designs. - Check configuration and flags — verify what flags/env vars exist, their default values, and how they are parsed (e.g., BanyanDB uses viper with
BYDB_prefix to auto-bind flags to env vars). - Check dependent projects — SkyWalking depends on BanyanDB, infra-e2e, Helm charts, etc. Read their source code and docs before assuming capabilities (e.g., check Helm chart
values.yamlfor supported fields, check infra-e2e for supported config options). Forskywalking-*projects, ask the developer if they have the source code locally — searching a local clone is much faster than fetching files via GitHub API.
- Verify locally first — run the code, start the container, execute the test before pushing to CI. Don't use CI as a trial-and-error environment.
- Validate file paths and directory structures — check where data actually goes (e.g., BanyanDB
--stream-root-path /tmpcreates/tmp/stream/,--access-log-root-path /tmpcreates/tmp/accesslog/). Don't assume directory names. - Validate YAML syntax — after editing YAML files (especially with sed/awk), validate with a YAML parser before committing. Corrupted YAML causes silent failures in CI.
- Check the actual Docker image — verify what's available in the container (binaries, shell, directories) before writing commands that depend on them.
- Say "I don't know" and investigate — reading the code is always better than guessing. Use grep, find, and read tools to locate the answer.
- Ask the developer first — if you can't find the source code, don't know how to run something, or the code doesn't make the answer clear, ask the developer where to find it rather than speculate.
- Test with real data — when investigating runtime behavior (e.g., what model names an API returns, what directory structure BanyanDB creates), set up a local test and observe the actual output.
- Apache SkyWalking projects — images are on
ghcr.io/apache/(e.g.,ghcr.io/apache/skywalking-banyandb:${COMMIT_SHA}). Tags are full commit SHAs, not short SHAs or version tags. - Official and 3rd-party images — on Docker Hub (e.g.,
ollama/ollama,otel/opentelemetry-collector,envoyproxy/gateway). - Always verify the image exists —
docker pullbefore writing CI or e2e configs. Image tags depend on CI publish workflows completing successfully.