Skip to content

discretewater/sitometry

Repository files navigation

SITOMETRY

SITOMETRY is an offline static analysis tool for OpenTelemetry Collector configuration.

Current release target: v0.1.0.

What It Does

SITOMETRY analyzes a single OpenTelemetry Collector YAML file and reports the implemented first-priority static findings as stable text or JSON output.

The current implementation includes:

  • single-file YAML loading
  • intermediate model construction
  • registry and reference binding
  • first-priority rule evaluation (STM001 through STM007)
  • stable diagnostics
  • terminal-friendly text output
  • machine-friendly JSON output
  • stable analyze exit codes

What It Does Not Do

SITOMETRY does not currently provide:

  • second-priority rules such as STM008, STM009, or STM010
  • deep connector topology validation
  • multi-file configuration support
  • automatic fixes
  • advanced filtering flags

Supported Rules

  • STM001: pipeline references an undeclared receiver
  • STM002: pipeline references an undeclared processor
  • STM003: pipeline references an undeclared exporter
  • STM004: configuration is missing service.pipelines
  • STM005: declared receiver is unused
  • STM006: declared processor is unused
  • STM007: declared exporter is unused

See rule-ids.md for the current rule ID reference.

Build

go build ./cmd/sitometry
go build -race ./cmd/sitometry

Test

go vet ./...
golangci-lint run
go test ./...
go test -race ./...

Analyze Examples

sitometry analyze testdata/realish/k8s-mixed-findings.yaml
sitometry analyze testdata/realish/local-multipipeline-valid.yaml --format json

Text Output Example

Example command:

sitometry analyze testdata/realish/k8s-mixed-findings.yaml

Example output:

Input: testdata/realish/k8s-mixed-findings.yaml
Diagnostics: 6

[ERROR] STM001 pipeline traces
  Summary: Pipeline traces references receiver missing_receiver, but no matching declaration exists.
  Location: testdata/realish/k8s-mixed-findings.yaml:36:25
  Explanation: The receiver reference in slot receivers could not be resolved from the analyzed declarations.
  Recommendation: Check whether receiver missing_receiver is misspelled, missing, or should be replaced with an existing receiver.

[ERROR] STM002 pipeline traces
  Summary: Pipeline traces references processor missing_processor, but no matching declaration exists.
  Location: testdata/realish/k8s-mixed-findings.yaml:37:36
  Explanation: The processor reference in slot processors could not be resolved from the analyzed declarations.
  Recommendation: Check whether processor missing_processor is misspelled, missing, or should be replaced with an existing processor.

JSON Output Example

Example command:

sitometry analyze testdata/realish/local-multipipeline-valid.yaml --format json

Example output:

{
  "input": "testdata/realish/local-multipipeline-valid.yaml",
  "diagnostics_count": 0,
  "severity_counts": {
    "error": 0,
    "warning": 0
  },
  "diagnostics": []
}

Exit Codes

  • 0: analysis completed successfully and produced no error-level diagnostics
  • 1: analysis completed successfully and produced at least one error-level diagnostic
  • 2: analysis failed and did not complete normally

See exit-codes.md for the stable exit-code reference.

Additional Docs

License

Apache-2.0. See LICENSE.

About

Static Analyzer for Single-file OpenTelemetry Collector YAML Configs

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages