From c28672ed30be82497317c8f8ba6638e196dc85ae Mon Sep 17 00:00:00 2001 From: Pedro Ramos Date: Tue, 30 Apr 2024 11:32:23 +0200 Subject: [PATCH] Make some adjustments --- README.md | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 8148389..1efd56d 100644 --- a/README.md +++ b/README.md @@ -6,56 +6,56 @@ It aids in comprehending how AsyncAPI tools are used and adopted, facilitating o ## Installation Requires NodeJS v18 or greater. ```bash -npm install @smoya/@asyncapi-adoption-metrics -yarn add @smoya/@asyncapi-adoption-metrics +npm install @smoya/asyncapi-adoption-metrics +yarn add @smoya/asyncapi-adoption-metrics ``` ## Usage The package exposes several classes, from which we can remark: - class `Metric`: Used to create an object containing all the properties needed to identify the metrics collected. These properties are: -```ts + ```ts name: string; type: MetricType; value: any; metadata: { [key: string]: any }; -``` + ``` - class `Recorder`: Contains all the functions needed to record the different metrics we collect, like: - `asyncapi_adoption.action.invoked`: With this metric we are tracking any action started (but not finished) in a tool. For example, a command that got executed on the [CLI](https://github.com/asyncapi/cli/) but didn't finish yet. We just want to know which commands are used, regardless they have failed or succeeded. - ```ts - async recordActionInvoked(actionName: string, metadata: MetricMetadata = {}) { + ```ts + async recordActionInvoked(actionName: string, metadata: MetricMetadata = {}) { metadata['action'] = actionName; this.record(new Metric('action.invoked', MetricType.Counter, 1, metadata)); } - ``` - Example where this function is used: - ```ts + ``` + Example where this function is used: + ```ts async init(): Promise { await super.init(); const commandName : string = this.id || ''; await this.recordActionInvoked(commandName, this.metricsMetadata); } - ``` + ``` - `asyncapi_adoption.action.finished`: With this metric we are tracking the action executed once it has already finished, carrying the result of the execution and some metadata. - ```ts + ```ts async recordActionFinished(actionName: string, metadata: MetricMetadata = {}) { metadata['action'] = actionName; this.record(new Metric('action.finished', MetricType.Counter, 1, metadata)); } - ``` - Example where this function is used: - ```ts + ``` + Example where this function is used: + ```ts async finally(error: Error | undefined): Promise { await super.finally(error); this.metricsMetadata['success'] = error === undefined; await this.recordActionFinished(this.id as string, this.metricsMetadata, this.specFile?.text()); } - ``` + ``` Utils exposed by the library to operate mainly with the `Sink` interface and the metadata retrieved from the asyncapi files: ```ts