MATIH Platform is in active MVP development. Documentation reflects current implementation status.
8. Platform Services
Profiling

Profiling

The ProfilingController provides continuous profiling capabilities for platform services. Profiling captures CPU, memory, and I/O profiles at the application level, enabling developers to identify performance bottlenecks and memory leaks without impacting production traffic.


Start a Profile

Endpoint: POST /api/v1/observability/profiling/start

curl -X POST http://localhost:8088/api/v1/observability/profiling/start \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ${TOKEN}" \
  -H "X-Tenant-ID: 550e8400" \
  -d '{
    "service": "ai-service",
    "profileType": "cpu",
    "durationSeconds": 60,
    "sampleRate": 100
  }'

ProfileRequest Structure

FieldTypeDescription
serviceStringTarget service name
profileTypeStringcpu, memory, alloc, block, mutex, goroutine
durationSecondsintProfile duration in seconds
sampleRateintSampling rate (samples per second)

Profile Types

TypeDescriptionBest For
cpuCPU time spent in each functionIdentifying slow code paths
memoryCurrent memory allocation by functionFinding memory-heavy operations
allocCumulative memory allocationsDetecting allocation-heavy code
blockGoroutine blocking eventsFinding lock contention
mutexMutex contentionIdentifying synchronization bottlenecks
goroutineActive goroutine stacksDetecting goroutine leaks

Get Profile Results

Endpoint: GET /api/v1/observability/profiling/:profileId

ProfileResult Structure

FieldTypeDescription
idStringProfile identifier
serviceStringProfiled service
profileTypeStringType of profile
statusStringrunning, completed, failed
startedAtInstantProfile start time
completedAtInstantProfile completion time
durationSecondsintActual profile duration
sampleCountintNumber of samples collected
topFunctionsListTop functions by resource usage
flameGraphUrlStringURL to the flame graph visualization

Compare Profiles

Endpoint: GET /api/v1/observability/profiling/compare

Compares two profiles to identify performance regressions or improvements.

ParameterTypeDescription
baseProfileIdStringBaseline profile ID
comparisonProfileIdStringComparison profile ID

ProfileComparison Structure

FieldTypeDescription
baseProfileStringBase profile identifier
comparisonProfileStringComparison profile identifier
improvementsListFunctions that improved
regressionsListFunctions that regressed
unchangedintNumber of unchanged functions
overallDeltadoubleOverall performance delta percentage

Continuous Profiling

Endpoint: POST /api/v1/observability/profiling/continuous

Enables continuous profiling for a service with low-overhead sampling.

ContinuousProfile Structure

FieldTypeDescription
serviceStringTarget service
profileTypesListTypes to profile continuously
sampleRateintSampling rate
retentionDaysintHow long to retain profiles
enabledbooleanWhether continuous profiling is active

Profile History

Endpoint: GET /api/v1/observability/profiling/history

Returns historical profiles for a service, enabling trend analysis of performance over time.