Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,26 @@ patterner metrics

The metrics command outputs detailed JSON data about your workspace resources.

#### Available Metrics

The following metrics are collected and displayed:

**Pipeline Metrics:**
- `pipelines_total` - Total number of pipelines
- `pipeline_resolvers_total` - Total number of pipeline resolvers
- `pipeline_resolver_steps_total` - Total number of pipeline resolver steps
- `pipeline_resolver_execution_paths_total` - Total number of pipeline resolver execution paths
- Calculated based on the number of steps and tests in each resolver (steps^tests)
- Used to understand the total number of execution paths based on testable step combinations

**TailorDB Metrics:**
- `tailordbs_total` - Total number of TailorDBs
- `tailordb_types_total` - Total number of TailorDB types
- `tailordb_type_fields_total` - Total number of TailorDB type fields

**StateFlow Metrics:**
- `stateflows_total` - Total number of StateFlows

## Configuration

Patterner uses a `.patterner.yml` file for configuration. The configuration includes various lint rules for different Tailor Platform components:
Expand Down
15 changes: 15 additions & 0 deletions tailor/metrics.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package tailor

import "math"

const (
pageSize = 100
)
Expand All @@ -21,10 +23,18 @@ func (c *Client) Metrics(resources *Resources) ([]Metric, error) {
})
resolversTotal := 0
stepsTotal := 0
executionPathsTotal := 0
for _, p := range resources.Pipelines {
resolversTotal += len(p.Resolvers)
for _, r := range p.Resolvers {
testsCount := 0
stepsTotal += len(r.Steps)
for _, s := range r.Steps {
if s.Operation.Test != "" {
testsCount++
}
}
executionPathsTotal += int(math.Pow(float64(len(r.Steps)), float64(testsCount)))
}
}
metrics = append(metrics, Metric{
Expand All @@ -37,6 +47,11 @@ func (c *Client) Metrics(resources *Resources) ([]Metric, error) {
Description: "Total number of pipeline resolver steps",
Value: float64(stepsTotal),
})
metrics = append(metrics, Metric{
Name: "pipeline_resolver_execution_paths_total",
Description: "Total number of pipeline resolver execution paths",
Value: float64(executionPathsTotal),
})

// TailorDB Metrics
metrics = append(metrics, Metric{
Expand Down
Loading