Categorygithub.com/skpr/compass
module
1.2.0
Repository: https://github.com/skpr/compass.git
Documentation: pkg.go.dev

# README

Compass

A tool designed to guide developers in the right direction for identifying and resolving performance issues.


Architecture

flowchart LR
   Extension["PECL Extension (Rust)"] --> compass_php_function["compass_php_function (USDT)"]
   Extension --> compass_request_shutdown["compass_request_shutdown (USDT)"]

   compass_php_function --> eBPF[eBPF Program]
   compass_request_shutdown --> eBPF

   eBPF --> Events["Events (Ring Buffer)"]

   Events --> CLI["CLI (Go)"]
   Events --> Sidecar["Sidecar (Go)"]

   Sidecar --> Stdout
   Sidecar --> OpenTelemetry

Performance

Performance data can be found in Github Actions for this build.

Components

DirectoryDescription
bpftracebpftrace scripts for testing the extension and demonstrating how the probes can be utilised.
extensionPHP extension which implements USDT probes.
cliCommandline interface that collects telemetry from USDT probes.
sidecarSidecar that collects telemetry from USDT probes and log to stdout.

CLI

Trace

Compass provides developers with 2 types of traces:

  • Complete - All function calls.
  • Aggregated - Functions executed within the same span are combined.

Below is a condensed example:

{
  "requestID": "55eefc9aa6008d539ef954aff41806a7",
  "startTime": 1726972907007464,
  "executionTime": 6054,
  "functionCalls": [
    {
      "name": "Symfony\\Component\\DependencyInjection\\Compiler\\Compiler::compile",
      "startTime": 1726972907128013,
      "endTime": 1726972907517795
    },
    {
      "name": "Symfony\\Component\\DependencyInjection\\ContainerBuilder::compile",
      "startTime": 1726972907128009,
      "endTime": 1726972907518593
    },
    {
      "name": "Drupal\\Core\\DrupalKernel::compileContainer",
      "startTime": 1726972907009684,
      "endTime": 1726972907518625
    },
    {
      "name": "Drupal\\Core\\DrupalKernel::initializeContainer",
      "startTime": 1726972907008223,
      "endTime": 1726972907612239
    },
    {
      "name": "Drupal\\Core\\DrupalKernel::boot",
      "startTime": 1726972907008040,
      "endTime": 1726972907612295
    },
  ],
}

Images

PHP Extension

ghcr.io/skpr/compass:extension-8.3-latest
ghcr.io/skpr/compass:extension-8.2-latest
ghcr.io/skpr/compass:extension-8.1-latest

Collector

ghcr.io/skpr/compass:collector-latest

Configuration

COMPONENTENVIRONMENT VARIABLEDEFAULT VALUEDescription
ExtensionCOMPASS_ENABLEDfalseEnable the Compass extension
ExtensionCOMPASS_MODEWhat mode the extension should operate. Empty will collect all executions. Setting to "header" will only collect executions when a specific header is set (see COMPASS_HEADER).
ExtensionCOMPASS_HEADERUsed to lock down which executions are traced. Need to set X-Compass for requests and needs to match this config.
ExtensionCOMPASS_FUNCTION_THRESHOLD10000Watermark for which functions to trace.
CLI + SidecarCOMPASS_PROCESS_NAMEphp-fpmName of the process to trace.
CLI + SidecarCOMPASS_EXTENSION_PATH/usr/lib/php/modules/compass.soPath to extension library which has probes.
SidecarCOMPASS_SIDECAR_REQUEST_THRESHOLD100Watermark for which requests to trace.
SidecarCOMPASS_SIDECAR_FUNCTION_THRESHOLD10Watermark for which functions to trace.
SidecarCOMPASS_SIDECAR_LOG_LEVELinfoLogging level for the collector component. Set to "debug" for debug notices.
SidecarCOMPASS_SIDECAR_SINKstdoutChoose which metrics sink to use.
SidecarCOMPASS_SIDECAR_OTEL_ENDPOINThttp://jaeger:4318/v1/tracesEndpoint to send OpenTelemetry traces to.
SidecarCOMPASS_SIDECAR_OTEL_SERVICE_NAMEName of the service assign this trace to.

# Packages

Package main for handling the main application.
Package collector implements the collection of PHP telemetry data.
Package main provides the entrypoint for the sidecar.
Package trace implements complete tracing data.