You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by oc...@apache.org on 2022/10/13 18:46:32 UTC

[trafficcontrol-trafficops-types] 26/38: Add missing DSStats type

This is an automated email from the ASF dual-hosted git repository.

ocket8888 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol-trafficops-types.git

commit 9e40d9b6829c148c54d2b7d1f2617306c550ad39
Author: ocket8888 <oc...@apache.org>
AuthorDate: Tue Jul 19 13:26:46 2022 -0600

    Add missing DSStats type
---
 package-lock.json |  4 +--
 package.json      |  2 +-
 src/stats.ts      | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++----
 3 files changed, 73 insertions(+), 8 deletions(-)

diff --git a/package-lock.json b/package-lock.json
index ccbdbe8..a1299c4 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
 {
 	"name": "trafficops-types",
-	"version": "3.1.0-beta-15",
+	"version": "3.1.0-beta-16",
 	"lockfileVersion": 2,
 	"requires": true,
 	"packages": {
 		"": {
 			"name": "trafficops-types",
-			"version": "3.1.0-beta-9",
+			"version": "3.1.0-beta-16",
 			"license": "GPL-3.0-or-later",
 			"devDependencies": {
 				"@typescript-eslint/eslint-plugin": "^5.0.0",
diff --git a/package.json b/package.json
index 7da2f08..e84386c 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
 	"name": "trafficops-types",
-	"version": "3.1.0-beta-15",
+	"version": "3.1.0-beta-16",
 	"description": "A library for dealing with Apache Traffic Control objects",
 	"main": "dist/index.js",
 	"scripts": {
diff --git a/src/stats.ts b/src/stats.ts
index b38df27..c082f0e 100644
--- a/src/stats.ts
+++ b/src/stats.ts
@@ -16,11 +16,48 @@
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-/** CacheStatsSeries is a set of data collected by Traffic Stats. */
-export interface CacheStatsSeries {
-	columns: ["time", "sum_count"];
+/**
+ * The types of metrics reported by Traffic Stats through the
+ * `/deliveryservice_stats` Traffic Ops API endpoint.
+ */
+export const enum DSStatsMetricType {
+	/**
+	 * The total traffic rate in kilobytes per second served by the Delivery
+	 * Service.
+	 */
+	KBPS = "kbps",
+	/**
+	 * The total traffic rate in transactions per second served by the Delivery
+	 * Service.
+	 */
+	TPS_TOTAL = "tps_total",
+	/**
+	 * The total traffic rate in transactions per second serviced with 200-299
+	 * HTTP status codes.
+	 */
+	TPS_2XX = "tps_2xx",
+	/**
+	 * The total traffic rate in transactions per second serviced with 300-399
+	 * HTTP status codes
+	 */
+	TPS_3XX = "tps_3xx",
+	/**
+	 * The total traffic rate in transactions per second serviced with 400-499
+	 * HTTP status codes
+	 */
+	TPS_4XX = "tps_4xx",
+	/**
+	 * The total traffic rate in transactions per second serviced with 500-599
+	 * HTTP status codes
+	 */
+	TPS_5XX = "tps_5xx",
+}
+
+/** Properties common to all stats series data. */
+interface StatsSeries {
+	columns: ["time", string];
 	count: number;
-	name: `${"bandwidth" | "connections" | "maxkbps"}.cdn.1min`;
+	name: string;
 	/**
 	 * Each first tuple element is actually a string that represents a
 	 * date/time, in a custom format. Refer to
@@ -30,7 +67,21 @@ export interface CacheStatsSeries {
 	values: Array<[Date, number | null]>;
 }
 
-/** CacheStatsSummary is a summary of some statistics set. */
+/**
+ * DSStatsSeries is a set of Delivery Service data collected by Traffic Stats.
+ */
+export interface DSStatsSeries extends StatsSeries {
+	columns: ["time", "mean"];
+	name: `${DSStatsMetricType}.ds.1min`;
+}
+
+/** CacheStatsSeries is a set of cache data collected by Traffic Stats. */
+export interface CacheStatsSeries extends StatsSeries {
+	columns: ["time", "sum_count"];
+	name: `${"bandwidth" | "connections" | "maxkbps"}.cdn.1min`;
+}
+
+/** CacheStatsSummary is a summary of some cache statistics set. */
 export interface CacheStatsSummary {
 	average: number;
 	count: number;
@@ -41,6 +92,20 @@ export interface CacheStatsSummary {
 	ninetyFifthPercentile: number;
 }
 
+/** Represents a response from `/deliveryservice_stats` */
+export interface DSStats {
+	/**
+	 * This will be excluded if the 'exclude' query string parameter was
+	 * "series" **or** if there were no data points for the requested data set.
+	 */
+	series?: DSStatsSeries;
+	/**
+	 * This will be excluded **only** if the 'exclude' query string parameter
+	 * was "summary".
+	 */
+	summary?: CacheStatsSummary;
+}
+
 /** Represents a response from /cache_stats.*/
 export interface CacheStats {
 	/**