mirror of
https://github.com/Unleash/unleash.git
synced 2025-10-27 11:02:16 +01:00
feat: add histogram to impact metrics (#10728)
This commit is contained in:
parent
adada932b9
commit
3ef2a7f93b
@ -3,55 +3,150 @@ import type { FromSchema } from 'json-schema-to-ts';
|
|||||||
export const impactMetricsSchema = {
|
export const impactMetricsSchema = {
|
||||||
$id: '#/components/schemas/impactMetricsSchema',
|
$id: '#/components/schemas/impactMetricsSchema',
|
||||||
type: 'object',
|
type: 'object',
|
||||||
required: ['name', 'help', 'type', 'samples'],
|
|
||||||
description: 'Used for reporting impact metrics from SDKs',
|
description: 'Used for reporting impact metrics from SDKs',
|
||||||
properties: {
|
oneOf: [
|
||||||
name: {
|
{
|
||||||
type: 'string',
|
required: ['name', 'help', 'type', 'samples'],
|
||||||
description: 'Name of the impact metric',
|
properties: {
|
||||||
example: 'my-counter',
|
name: {
|
||||||
},
|
type: 'string',
|
||||||
help: {
|
description: 'Name of the impact metric',
|
||||||
description:
|
example: 'my-counter',
|
||||||
'Human-readable description of what the metric measures',
|
},
|
||||||
type: 'string',
|
help: {
|
||||||
example: 'Counts the number of operations',
|
description:
|
||||||
},
|
'Human-readable description of what the metric measures',
|
||||||
type: {
|
type: 'string',
|
||||||
description: 'Type of the metric',
|
example: 'Counts the number of operations',
|
||||||
type: 'string',
|
},
|
||||||
enum: ['counter', 'gauge'],
|
type: {
|
||||||
example: 'counter',
|
description: 'Type of the metric',
|
||||||
},
|
type: 'string',
|
||||||
samples: {
|
enum: ['counter', 'gauge'],
|
||||||
description: 'Samples of the metric',
|
example: 'counter',
|
||||||
type: 'array',
|
},
|
||||||
items: {
|
samples: {
|
||||||
type: 'object',
|
description: 'Samples of the numeric metric',
|
||||||
required: ['value'],
|
type: 'array',
|
||||||
description:
|
items: {
|
||||||
'A sample of a metric with a value and optional labels',
|
|
||||||
properties: {
|
|
||||||
value: {
|
|
||||||
type: 'number',
|
|
||||||
description: 'The value of the metric sample',
|
|
||||||
example: 10,
|
|
||||||
},
|
|
||||||
labels: {
|
|
||||||
description: 'Optional labels for the metric sample',
|
|
||||||
type: 'object',
|
type: 'object',
|
||||||
additionalProperties: {
|
required: ['value'],
|
||||||
type: 'string',
|
description:
|
||||||
},
|
'A sample of a numeric metric with a value and optional labels',
|
||||||
example: {
|
properties: {
|
||||||
application: 'my-app',
|
value: {
|
||||||
environment: 'production',
|
type: 'number',
|
||||||
|
description: 'The value of the metric sample',
|
||||||
|
example: 10,
|
||||||
|
},
|
||||||
|
labels: {
|
||||||
|
description:
|
||||||
|
'Optional labels for the metric sample',
|
||||||
|
type: 'object',
|
||||||
|
additionalProperties: {
|
||||||
|
oneOf: [
|
||||||
|
{ type: 'string' },
|
||||||
|
{ type: 'number' },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
example: {
|
||||||
|
application: 'my-app',
|
||||||
|
environment: 'production',
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
{
|
||||||
|
required: ['name', 'help', 'type', 'samples'],
|
||||||
|
properties: {
|
||||||
|
name: {
|
||||||
|
type: 'string',
|
||||||
|
description: 'Name of the impact metric',
|
||||||
|
example: 'my-histogram',
|
||||||
|
},
|
||||||
|
help: {
|
||||||
|
description:
|
||||||
|
'Human-readable description of what the metric measures',
|
||||||
|
type: 'string',
|
||||||
|
example: 'Measures request duration',
|
||||||
|
},
|
||||||
|
type: {
|
||||||
|
description: 'Type of the metric',
|
||||||
|
type: 'string',
|
||||||
|
enum: ['histogram'],
|
||||||
|
example: 'histogram',
|
||||||
|
},
|
||||||
|
samples: {
|
||||||
|
description: 'Samples of the histogram metric',
|
||||||
|
type: 'array',
|
||||||
|
items: {
|
||||||
|
type: 'object',
|
||||||
|
required: ['count', 'sum', 'buckets'],
|
||||||
|
description:
|
||||||
|
'A sample of a histogram metric with count, sum, buckets and optional labels',
|
||||||
|
properties: {
|
||||||
|
count: {
|
||||||
|
type: 'number',
|
||||||
|
description: 'Total count of observations',
|
||||||
|
example: 100,
|
||||||
|
},
|
||||||
|
sum: {
|
||||||
|
type: 'number',
|
||||||
|
description: 'Sum of all observed values',
|
||||||
|
example: 1500,
|
||||||
|
},
|
||||||
|
buckets: {
|
||||||
|
type: 'array',
|
||||||
|
description: 'Histogram buckets',
|
||||||
|
items: {
|
||||||
|
type: 'object',
|
||||||
|
required: ['le', 'count'],
|
||||||
|
properties: {
|
||||||
|
le: {
|
||||||
|
oneOf: [
|
||||||
|
{ type: 'number' },
|
||||||
|
{
|
||||||
|
type: 'string',
|
||||||
|
enum: ['+Inf'],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
description:
|
||||||
|
'Upper bound of the bucket',
|
||||||
|
example: 0.5,
|
||||||
|
},
|
||||||
|
count: {
|
||||||
|
type: 'number',
|
||||||
|
description:
|
||||||
|
'Count of observations in this bucket',
|
||||||
|
example: 30,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
labels: {
|
||||||
|
description:
|
||||||
|
'Optional labels for the metric sample',
|
||||||
|
type: 'object',
|
||||||
|
additionalProperties: {
|
||||||
|
oneOf: [
|
||||||
|
{ type: 'string' },
|
||||||
|
{ type: 'number' },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
example: {
|
||||||
|
application: 'my-app',
|
||||||
|
environment: 'production',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
components: {
|
components: {
|
||||||
schemas: {},
|
schemas: {},
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user