本文へ移動
cccskills
無料GitHub で公開

project-knowledge

LoongCollector project knowledge: architecture, terminology, codebase map, and coding standards (C++/Go).

インストール方法を見る

含まれるファイル(1)

  • SKILL.md9.0 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

LoongCollector Project Knowledge

Architecture Overview

The LoongCollector architecture is based on a plugin system with the following key components:

  1. Core Application: Main entry point in core/logtail.cpp, initializes Application class in core/application/Application.cpp. Follows singleton pattern, manages overall lifecycle.

  2. Plugin System: Supports plugins for data collection, processing, and flushing:

    • Inputs: Collect data from various sources (files, network, system metrics, etc.)
    • Processors: Transform and process collected data
    • Flushers: Send processed data to various backends
  3. Pipeline Management: Collection pipelines managed by CollectionPipelineManager handle data flow from inputs through processors to flushers.

  4. Configuration: Supports both local and remote configuration management with watchers that monitor for configuration changes.

  5. Queuing System: Implements various queue types including bounded queues, circular queues, and exactly-once delivery queues for reliable data transmission.

  6. Monitoring: Built-in monitoring and metrics collection for tracking the collector's own performance and health.

Project Structure

core/                    # Core C++ code
  plugin/                # Plugin system
    input/               # Data collection input plugins
    processor/           # Data processing plugins
    flusher/             # Data output plugins (SLS, file, etc.)
  collection_pipeline/   # Main pipeline flow (queue, batch, serialization)
  config/                # Configuration (loading, providers, feedback)
    provider/            # Config providers (Enterprise, Legacy)
  common/                # Common utilities, data structures, network, string, crypto
  monitor/               # Monitoring, metrics collection, alerting
  logger/                # Logging system
  checkpoint/            # Checkpoint, state management
  app_config/            # Global configuration
  models/                # Core data structures (events, logs, metrics)
  parser/                # Log parsers
  task_pipeline/         # Task scheduling
  go_pipeline/           # Go plugin integration
  ebpf/                  # eBPF collection and plugins
  host_monitor/          # Host-level monitoring
  shennong/              # Shennong metrics
  prometheus/            # Prometheus collection
  file_server/           # File collection and management
  container_manager/     # Container environment management
  application/           # Main application entry
  protobuf/              # Protobuf protocol definitions
  metadata/              # K8s and other metadata collection
  constants/             # Constants
  tools/                 # Internal utility scripts
  unittest/              # Unit tests
  legacy_test/           # Historical test cases

pkg/                     # Go packages
  helper/                # Go helper functions
    containercenter/     # Go container-related functions

plugin_main/             # Plugin main entry
pluginmanager/           # Go plugin manager (lifecycle, registration)
plugins/                 # Go plugin packages
  input/                 # Go input plugins (docker, etc.)
  processor/             # Go processor plugins
  flusher/               # Go flusher plugins
  aggregator/            # Go aggregator plugins
  extension/             # Go extension plugins
  all/                   # Plugin registration and init
  test/                  # Go plugin tests

test/                    # Integration tests
e2e/                     # E2E test cases (open source Go plugins)
e2e_enterprise/          # E2E enterprise test cases (host + K8s)
docs/                    # Project documentation
scripts/                 # Build, deploy, test scripts
docker/                  # Docker-related files
rpm/                     # RPM packaging
external/                # External dependencies

Key Dependencies

Header-Only Libraries

  • spdlog - Logging
  • rapidjson - JSON parsing

Compiled Libraries

  • Testing: gtest, gmock
  • Serialization: protobuf
  • Regex: re2
  • Hash: cityhash
  • Config: jsoncpp, yamlcpp
  • Compression: lz4, zlib, zstd
  • Network: curl, ssl, crypto
  • System: boost, gflags, leveldb, uuid
  • Memory: tcmalloc (optional)

Tech Stack

  • C++ (main implementation, C++17/20)
  • Protobuf (data serialization)
  • eBPF (kernel-level data collection)
  • Prometheus (metrics collection)
  • Go (plugin adaptation)
  • Shell/Python (build and test scripts)

Terminology Glossary

TermDescription
LoongCollectorThe observability data collection agent (formerly iLogtail)
PipelineA data processing chain: Input -> Processor(s) -> Flusher
PluginA modular component that performs specific data operations
Input PluginCollects data from a source (file, network, metric, etc.)
Processor PluginTransforms data (parse, filter, enrich, etc.)
Flusher PluginSends data to a destination (SLS, stdout, Prometheus, etc.)
ConfigCollection configuration defining pipeline behavior
CheckpointPersistent state tracking for exactly-once delivery
RunnerExecution wrapper for a specific plugin instance
QueueData buffer between pipeline stages
BatchGroup of events processed/sent together
SLSAlibaba Cloud Simple Log Service
eBPFExtended Berkeley Packet Filter (kernel tracing)
SPLStructured Processing Language

Codebase Map

Key Entry Points and Core Flows

PathPurpose
core/logtail.cppMain entry point
core/application/Application.cppApplication singleton, lifecycle management
core/collection_pipeline/CollectionPipelineManager.cppPipeline lifecycle
core/collection_pipeline/CollectionPipeline.cppPipeline execution
core/runner/ProcessorRunner.cppProcessor execution
core/runner/FlusherRunner.cppFlusher execution
core/config/watcher/PipelineConfigWatcher.cppConfig change detection
core/file_server/FileServer.cppFile collection management
core/file_server/checkpoint/CheckpointManagerV2.cppExactly-once checkpoint

Invariant Rules

  • Lifecycle: All plugins follow Init -> Start -> Stop -> Close lifecycle
  • Resource Release: Every thread/future/queue must be properly cleaned up on stop
  • Config: Environment variables are case-insensitive with default fallbacks
  • Queue: Bounded queue with backpressure; pop on disabled queue should not hang
  • Hot Reload: After config change, system must return to consistent "collect+process+send" state

Common Patterns

  • RAII for resource management
  • Smart pointers over raw pointers
  • Singleton pattern for managers (Application, AlarmManager, WriteMetrics)
  • Thread-safe queues with condition variables
  • Plugin registration via static initialization

C++ Coding Standards

Naming

  • PascalCase for class names, global functions, public methods
  • camelCase for variable names and private methods
  • SCREAMING_SNAKE_CASE for macros and constants
  • m prefix for member variables (e.g., mUserId)
  • k prefix for constants (e.g., kMaxSendBufferSize)

Modern C++

  • Prefer C++17/20 features (auto, range-based loops, smart pointers)
  • Use std::unique_ptr / std::shared_ptr for memory management
  • Prefer std::optional, std::variant, std::any for type-safe alternatives
  • Use constexpr and const for compile-time computations
  • Use std::string_view for read-only string operations

Error Handling

  • Use exceptions for error handling (std::runtime_error, std::invalid_argument)
  • RAII for resource management to avoid memory leaks
  • Validate inputs at function boundaries
  • Log errors using spdlog

Performance

  • Avoid unnecessary heap allocations; prefer stack-based objects
  • Use std::move for move semantics
  • Optimize loops with <algorithm> (e.g., std::sort, std::for_each)
  • Use std::array or std::vector over raw arrays

Security

  • Avoid C-style casts; use static_cast, dynamic_cast, reinterpret_cast
  • Enforce const-correctness
  • Avoid global variables; use singletons sparingly
  • Use enum class for strongly typed enumerations

Testing

  • Unit tests using Google Test (GTest) / Google Mock
  • Integration tests for system components

Go Coding Standards

Naming

  • PascalCase for exported types and functions
  • camelCase for unexported types and functions
  • snake_case for variables and constants
  • Package names use lowercase

Error Handling

  • Return errors explicitly, do not panic
  • Use fmt.Errorf with %w for error wrapping
  • Check errors at every call site

Concurrency

  • Use goroutines for concurrent operations
  • Use channels or sync primitives for communication
  • Avoid goroutine leaks; always provide exit paths

Testing

  • Use standard testing package
  • Table-driven tests for function coverage
  • Integration tests via E2E framework

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

同じリポジトリのスキル

概要と使いどころ

在进行 Code Review 时,使用这个技能对 LoongCollector 变更进行安全导向、架构一致性优先的深度代码评审。

日本語の概要は準備中です。原文の説明を表示しています。

alibaba/loongcollector2,2042026年10月9日 更新

commit

無料

按 Conventional Commits 规范编写提交信息。在创建 git commit 时使用。

日本語の概要は準備中です。原文の説明を表示しています。

alibaba/loongcollector2,2042026年10月9日 更新

compile

無料

编译 LoongCollector C++ 与 Go 组件。涉及构建、单元测试或镜像时使用。

日本語の概要は準備中です。原文の説明を表示しています。

alibaba/loongcollector2,2042026年10月9日 更新

Design document writing conventions. Use when writing or reviewing technical design documents.

日本語の概要は準備中です。原文の説明を表示しています。

alibaba/loongcollector2,2042026年10月9日 更新

e2e

無料

LoongCollector E2E 测试全流程指南:设计、编写、运行和调试。当需要编写新 E2E 测试、运行现有测试、或排查 E2E 测试失败时使用此 skill。

日本語の概要は準備中です。原文の説明を表示しています。

alibaba/loongcollector2,2042026年10月9日 更新

LoongCollector E2E Testing Framework Development Guide. Use this rule when you need to understand E2E testing framework architecture, develop new test behavior functions, or extend testing capabilities. Contains detailed BDD testing framework usage, test behavior function development and registration workflows, and comprehensive reference of existing testing capabilities. Example: When adding custom test behaviors for new plugins, use this rule to understand how to write and register new test functions. Example: When developing E2E tests, use this rule to understand the e2e framework.

日本語の概要は準備中です。原文の説明を表示しています。

alibaba/loongcollector2,2042026年10月9日 更新

alibaba のスキルをすべて見る

このスキルの問題を報告する