Skip to content

Commit

Permalink
Implement flattened stats API
Browse files Browse the repository at this point in the history
This implements the API changes of spec commit a731d12, and the protocol
version bump from spec commit dfe9476. Documentation taken from
sdk-api-reference commit 570728b.

Resolves #1269.
  • Loading branch information
lawrence-forooghian committed Dec 15, 2023
1 parent 717733d commit 120adb5
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 463 deletions.
152 changes: 10 additions & 142 deletions ably.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -751,122 +751,6 @@ declare namespace Types {
constructor(message: string, code: number, statusCode: number, cause?: string | Error | ErrorInfo);
}

/**
* Contains the aggregate counts for messages and data transferred.
*/
interface StatsMessageCount {
/**
* The count of all messages.
*/
count: number;
/**
* The total number of bytes transferred for all messages.
*/
data: number;
}

/**
* Contains a breakdown of summary stats data for different (channel vs presence) message types.
*/
interface StatsMessageTypes {
/**
* A {@link StatsMessageCount} object containing the count and byte value of messages and presence messages.
*/
all: StatsMessageCount;
/**
* A {@link StatsMessageCount} object containing the count and byte value of messages.
*/
messages: StatsMessageCount;
/**
* A {@link StatsMessageCount} object containing the count and byte value of presence messages.
*/
presence: StatsMessageCount;
}

/**
* Contains the aggregate counts for requests made.
*/
interface StatsRequestCount {
/**
* The number of requests that failed.
*/
failed: number;
/**
* The number of requests that were refused, typically as a result of permissions or a limit being exceeded.
*/
refused: number;
/**
* The number of requests that succeeded.
*/
succeeded: number;
}

/**
* Contains the aggregate data for usage of a resource in a specific scope.
*/
interface StatsResourceCount {
/**
* The average number of resources of this type used for this period.
*/
mean: number;
/**
* The minimum total resources of this type used for this period.
*/
min: number;
/**
* The total number of resources opened of this type.
*/
opened: number;
/**
* The peak number of resources of this type used for this period.
*/
peak: number;
/**
* The number of resource requests refused within this period.
*/
refused: number;
}

/**
* Contains a breakdown of summary stats data for different (TLS vs non-TLS) connection types.
*/
interface StatsConnectionTypes {
/**
* A {@link StatsResourceCount} object containing a breakdown of usage by scope over TLS connections (both TLS and non-TLS).
*/
all: StatsResourceCount;
/**
* A {@link StatsResourceCount} object containing a breakdown of usage by scope over non-TLS connections.
*/
plain: StatsResourceCount;
/**
* A {@link StatsResourceCount} object containing a breakdown of usage by scope over TLS connections.
*/
tls: StatsResourceCount;
}

/**
* Contains a breakdown of summary stats data for traffic over various transport types.
*/
interface StatsMessageTraffic {
/**
* A {@link StatsMessageTypes} object containing a breakdown of usage by message type for all messages (includes `realtime`, `rest` and `webhook` messages).
*/
all: StatsMessageTypes;
/**
* A {@link StatsMessageTypes} object containing a breakdown of usage by message type for messages transferred over a realtime transport such as WebSocket.
*/
realtime: StatsMessageTypes;
/**
* A {@link StatsMessageTypes} object containing a breakdown of usage by message type for messages transferred over a rest transport such as WebSocket.
*/
rest: StatsMessageTypes;
/**
* A {@link StatsMessageTypes} object containing a breakdown of usage by message type for messages delivered using webhooks.
*/
webhook: StatsMessageTypes;
}

/**
* Contains an Ably Token and its associated metadata.
*/
Expand Down Expand Up @@ -2563,42 +2447,26 @@ declare namespace Types {
* Contains application statistics for a specified time interval and time period.
*/
class Stats {
/**
* A {@link StatsMessageTypes} object containing the aggregate count of all message stats.
*/
all: StatsMessageTypes;
/**
* A {@link StatsRequestCount} object containing a breakdown of API Requests.
*/
apiRequests: StatsRequestCount;
/**
* A {@link StatsResourceCount} object containing a breakdown of channels.
*/
channels: StatsResourceCount;
/**
* A {@link StatsConnectionTypes} object containing a breakdown of connection related stats, such as min, mean and peak connections.
*/
connections: StatsConnectionTypes;
/**
* A {@link StatsMessageTraffic} object containing the aggregate count of inbound message stats.
*/
inbound: StatsMessageTraffic;
/**
* The UTC time at which the time period covered begins. If `unit` is set to `minute` this will be in the format `YYYY-mm-dd:HH:MM`, if `hour` it will be `YYYY-mm-dd:HH`, if `day` it will be `YYYY-mm-dd:00` and if `month` it will be `YYYY-mm-01:00`.
*/
intervalId: string;
/*
* For entries that are still in progress, such as the current month: the last sub-interval included in this entry (in format yyyy-mm-dd:hh:mm:ss), else undefined.
*/
inProgress?: string;
/**
* A {@link StatsMessageTraffic} object containing the aggregate count of outbound message stats.
* The statistics for this time interval and time period. See the JSON schema which the {@link Stats.schema | `schema`} property points to for more information.
*/
outbound: StatsMessageTraffic;
entries: Partial<Record<string, number>>;
/**
* A {@link StatsMessageTypes} object containing the aggregate count of persisted message stats.
* The URL of a [JSON Schema](https://json-schema.org/) which describes the structure of this `Stats` object.
*/
persisted: StatsMessageTypes;
schema: string;
/**
* A {@link StatsRequestCount} object containing a breakdown of Ably Token requests.
* The ID of the Ably application the statistics are for.
*/
tokenRequests: StatsRequestCount;
appId: string;
}

/**
Expand Down
Loading

0 comments on commit 120adb5

Please sign in to comment.