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
45 changes: 10 additions & 35 deletions cmd/health/health_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,39 +118,14 @@ func RunStreamStatus(cli *di.Deps, api *stackstate_api.APIClient, args *StatusAr
return nil
}

func metricValueOrDash(bucket []stackstate_api.MetricBucketValue, index int) interface{} {
if index < len(bucket) && bucket[index].HasValue() {
return bucket[index].GetValue()
}
return "-"
}

func metricBucketToJson(name string, bucket []stackstate_api.MetricBucketValue, size int32) map[string]interface{} {
return map[string]interface{}{
"name": name,
fmt.Sprintf("now-%d", size): metricValueOrDash(bucket, 0),
fmt.Sprintf("%d-%d", size, 2*size): metricValueOrDash(bucket, 1), //nolint:mnd
fmt.Sprintf("%d-%d", 2*size, 3*size): metricValueOrDash(bucket, 2), //nolint:mnd
}
}

func streamMetricsToJson(metrics stackstate_api.HealthStreamMetrics) []map[string]interface{} {
size := metrics.BucketSizeSeconds
return []map[string]interface{}{
metricBucketToJson("latency seconds", metrics.LatencySeconds, size),
metricBucketToJson("messages per seconds", metrics.MessagePerSecond, size),
metricBucketToJson("creates per seconds", metrics.CreatesPerSecond, size),
metricBucketToJson("updates per seconds", metrics.UpdatesPerSecond, size),
metricBucketToJson("deletes per seconds", metrics.DeletesPerSecond, size),
}
}

func metricBucketToRow(name string, bucket []stackstate_api.MetricBucketValue) []interface{} {
return []interface{}{
name,
metricValueOrDash(bucket, 0),
metricValueOrDash(bucket, 1),
metricValueOrDash(bucket, 2), //nolint:mnd
printer.MetricBucketToJson("latency seconds", metrics.LatencySeconds, size),
printer.MetricBucketToJson("messages per seconds", metrics.MessagePerSecond, size),
printer.MetricBucketToJson("creates per seconds", metrics.CreatesPerSecond, size),
printer.MetricBucketToJson("updates per seconds", metrics.UpdatesPerSecond, size),
printer.MetricBucketToJson("deletes per seconds", metrics.DeletesPerSecond, size),
}
}

Expand All @@ -159,11 +134,11 @@ func streamMetricsToTable(metrics stackstate_api.HealthStreamMetrics) printer.Ta
return printer.TableData{
Header: []string{"Metric", fmt.Sprintf("%ds ago", size), fmt.Sprintf("%d-%ds ago", size, 2*size), fmt.Sprintf("%d-%ds ago", 2*size, 3*size)}, //nolint:mnd
Data: [][]interface{}{
metricBucketToRow("latency seconds", metrics.LatencySeconds),
metricBucketToRow("messages per seconds", metrics.MessagePerSecond),
metricBucketToRow("creates per seconds", metrics.CreatesPerSecond),
metricBucketToRow("updates per seconds", metrics.UpdatesPerSecond),
metricBucketToRow("deletes per seconds", metrics.DeletesPerSecond),
printer.MetricBucketToRow("latency seconds", metrics.LatencySeconds),
printer.MetricBucketToRow("messages per seconds", metrics.MessagePerSecond),
printer.MetricBucketToRow("creates per seconds", metrics.CreatesPerSecond),
printer.MetricBucketToRow("updates per seconds", metrics.UpdatesPerSecond),
printer.MetricBucketToRow("deletes per seconds", metrics.DeletesPerSecond),
},
MissingTableDataMsg: printer.NotFoundMsg{Types: "metrics"},
}
Expand Down
12 changes: 12 additions & 0 deletions cmd/topologysync/topologysync_describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,18 @@ func RunDescribeCommand(args *DescribeArgs) di.CmdWithApiFn {
sync.Item,
}))

if sync.Metrics != nil {
cli.Printer.PrintLn("\nTopology Synchronization Metrics:")
size := sync.Metrics.BucketSizeSeconds
cli.Printer.Table(printer.TableData{
Header: []string{"Metric", fmt.Sprintf("%ds ago", size), fmt.Sprintf("%d-%ds ago", size, 2*size), fmt.Sprintf("%d-%ds ago", 2*size, 3*size)}, //nolint:mnd
Data: [][]interface{}{
printer.MetricBucketToRow("latency seconds", sync.Metrics.LatencySeconds),
},
MissingTableDataMsg: printer.NotFoundMsg{Types: "metrics"},
})
}

data := make([][]interface{}, len(sync.ErrorDetails))
for i, error := range sync.ErrorDetails {
id := "-"
Expand Down
1 change: 0 additions & 1 deletion generated/stackstate_api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ Class | Method | HTTP request | Description
*TopicApi* | [**Describe**](docs/TopicApi.md#describe) | **Get** /topic/{topic} | Describe a topic
*TopicApi* | [**List**](docs/TopicApi.md#list) | **Get** /topic | List topics
*TopologySynchronizationApi* | [**GetTopologySynchronizationStreamById**](docs/TopologySynchronizationApi.md#gettopologysynchronizationstreambyid) | **Get** /synchronization/topology/streams/sync | Overview of a specific Topology Stream, queried by node id or sync identifier
*TopologySynchronizationApi* | [**GetTopologySynchronizationStreamStatusById**](docs/TopologySynchronizationApi.md#gettopologysynchronizationstreamstatusbyid) | **Get** /synchronization/topology/streams/status | Metrics of a specific Topology Stream, queried by node id
*TopologySynchronizationApi* | [**GetTopologySynchronizationStreams**](docs/TopologySynchronizationApi.md#gettopologysynchronizationstreams) | **Get** /synchronization/topology/streams | Overview of the topology synchronization streams
*TopologySynchronizationApi* | [**PostTopologySynchronizationStreamClearErrors**](docs/TopologySynchronizationApi.md#posttopologysynchronizationstreamclearerrors) | **Post** /synchronization/topology/streams/clearErrors | Clear all the errors related to a specific sync
*TracesApi* | [**GetSpan**](docs/TracesApi.md#getspan) | **Get** /traces/{traceId}/spans/{spanId} | Get a span
Expand Down
79 changes: 23 additions & 56 deletions generated/stackstate_api/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3402,46 +3402,6 @@ paths:
required: true
schema:
$ref: '#/components/schemas/IdentifierType'
/synchronization/topology/streams/status:
get:
description: "Metrics of a specific Topology Stream, queried by node id"
operationId: getTopologySynchronizationStreamStatusById
parameters:
- allowReserved: true
in: query
name: identifier
required: true
schema:
type: string
responses:
"200":
content:
application/json:
schema:
$ref: '#/components/schemas/TopologyStreamMetrics'
description: A specific topology stream metrics
"400":
content:
application/json:
schema:
$ref: '#/components/schemas/InvalidSyncIdentifier'
description: Bad request when specifying an invalid identifier
"404":
content:
application/json:
schema:
$ref: '#/components/schemas/TopologySyncError'
description: Sync with given identifier not found
summary: "Metrics of a specific Topology Stream, queried by node id"
tags:
- topologySynchronization
parameters:
- allowReserved: true
in: query
name: identifier
required: true
schema:
type: string
/synchronization/topology/streams/clearErrors:
parameters:
- allowReserved: true
Expand Down Expand Up @@ -10230,6 +10190,11 @@ components:
errors: 2
createdComponents: 5
status: null
metrics:
latencySeconds:
- value: 5.637376656633329
- value: 5.637376656633329
bucketSizeSeconds: 0
errorDetails:
- level: null
externalId: externalId
Expand All @@ -10244,6 +10209,8 @@ components:
items:
$ref: '#/components/schemas/TopologyStreamError'
type: array
metrics:
$ref: '#/components/schemas/TopologyStreamMetrics'
required:
- errorDetails
- item
Expand All @@ -10268,6 +10235,22 @@ components:
- level
- message
type: object
TopologyStreamMetrics:
example:
latencySeconds:
- value: 5.637376656633329
- value: 5.637376656633329
bucketSizeSeconds: 0
properties:
bucketSizeSeconds:
type: integer
latencySeconds:
items:
$ref: '#/components/schemas/MetricBucketValue'
type: array
required:
- bucketSizeSeconds
type: object
IdentifierType:
enum:
- NodeId
Expand All @@ -10287,22 +10270,6 @@ components:
required:
- message
type: object
TopologyStreamMetrics:
example:
latencySeconds:
- value: 5.637376656633329
- value: 5.637376656633329
bucketSizeSeconds: 0
properties:
bucketSizeSeconds:
type: integer
latencySeconds:
items:
$ref: '#/components/schemas/MetricBucketValue'
type: array
required:
- bucketSizeSeconds
type: object
ExecuteScriptResponse:
example:
result: "{}"
Expand Down
Loading