From c74f830b763bbc144ade921729972e4832deb9d4 Mon Sep 17 00:00:00 2001 From: Harrison Healey Date: Tue, 10 Sep 2024 17:11:05 -0400 Subject: [PATCH] MM-60283 Add standard response and API docs to /client_perf API (#28124) * MM-60283 Add standard response to /client_perf API * Add API docs for /client_perf endpoint * Fix invalid response schema --- api/Makefile | 1 + api/v4/source/metrics.yaml | 102 ++++++++++++++++++++++++++++++++ server/channels/api4/metrics.go | 2 + 3 files changed, 105 insertions(+) create mode 100644 api/v4/source/metrics.yaml diff --git a/api/Makefile b/api/Makefile index ef9aa0a5c3..546b67dea5 100644 --- a/api/Makefile +++ b/api/Makefile @@ -56,6 +56,7 @@ build-v4: node_modules playbooks @cat $(V4_SRC)/limits.yaml >> $(V4_YAML) @cat $(V4_SRC)/logs.yaml >> $(V4_YAML) @cat $(V4_SRC)/outgoing_oauth_connections.yaml >> $(V4_YAML) + @cat $(V4_SRC)/metrics.yaml >> $(V4_YAML) @if [ -r $(PLAYBOOKS_SRC)/paths.yaml ]; then cat $(PLAYBOOKS_SRC)/paths.yaml >> $(V4_YAML); fi @if [ -r $(PLAYBOOKS_SRC)/merged-definitions.yaml ]; then cat $(PLAYBOOKS_SRC)/merged-definitions.yaml >> $(V4_YAML); else cat $(V4_SRC)/definitions.yaml >> $(V4_YAML); fi @echo Extracting code samples diff --git a/api/v4/source/metrics.yaml b/api/v4/source/metrics.yaml new file mode 100644 index 0000000000..870b9327fd --- /dev/null +++ b/api/v4/source/metrics.yaml @@ -0,0 +1,102 @@ + /api/v4/client_perf: + post: + summary: Report client performance metrics + description: > + Uploads client performance measurements to the server as part of the Client Performance Monitoring feature. + + __Minimum server version__: 9.9.0 + operationId: SubmitPerformanceReport + requestBody: + content: + application/json: + schema: + type: object + required: + - version + - start + - end + properties: + version: + type: string + description: An identifier for the schema of the data being submitted which currently must be "0.1.0" + client_id: + type: string + description: Not currently used + labels: + type: array + items: + type: string + description: Labels to be applied to all metrics when recorded by the metrics backend + start: + type: integer + format: int64 + description: The time in milliseconds of the first metric in this report + end: + type: integer + format: int64 + description: The time in milliseconds of the last metric in this report + counters: + type: array + items: + type: object + required: + - metric + - value + properties: + metric: + type: string + description: The name of the counter + value: + type: number + format: double + description: The value to increment the counter by + timestamp: + type: integer + format: int64 + description: The time that the counter was incremented + labels: + type: array + items: + type: string + description: Labels to be applied to this metric when recorded by the metrics backend + description: An array of counter metrics to be reported + histograms: + type: array + items: + type: object + required: + - metric + - value + properties: + metric: + type: string + description: The name of the measurement + value: + type: number + format: double + description: The value of the measurement + timestamp: + type: integer + format: int64 + description: The time that the measurement was taken + labels: + type: array + items: + type: string + description: Labels to be applied to this metric when recorded by the metrics backend + description: An array of histogram measurements to be reported + responses: + "200": + description: Measurements reported successfully + content: + application/json: + schema: + $ref: "#/components/schemas/StatusOK" + "400": + $ref: "#/components/responses/BadRequest" + "401": + $ref: "#/components/responses/Unauthorized" + "403": + $ref: "#/components/responses/Forbidden" + "500": + $ref: "#/components/responses/InternalServerError" diff --git a/server/channels/api4/metrics.go b/server/channels/api4/metrics.go index f3c1412d48..9fb656b408 100644 --- a/server/channels/api4/metrics.go +++ b/server/channels/api4/metrics.go @@ -35,4 +35,6 @@ func submitPerformanceReport(c *Context, w http.ResponseWriter, r *http.Request) c.Err = appErr return } + + ReturnStatusOK(w) }