Skip to content

Commit

Permalink
Signed-off-by: jagpreetsinghsasan <jagpreet.singh.sasan@accenture.com>
Browse files Browse the repository at this point in the history
feat(fabric): add prometheus metrics support to the OpenAPI specs of the plugin

	Primary Change
	--------------

	1. The fabric ledger connector plugin now includes the prometheus metrics exporter integration
	2. OpenAPI spec now has api endpoint for the getting the prometheus metrics

	Refactorings that were also necessary to accomodate 1) and 2)
	------------------------------------------------------------

	3. The generate-sdk command now has DateTime mapping to Date (to read Date as Date object instead of string)
	4. GetPrometheusMetricsV1 class is created to handle the corresponding api endpoint
	5. IPluginLedgerConnectorFabricOptions interface in PluginLedgerConnectorFabric class now has a prometheusExporter optional field
	6. The PluginLedgerConnectorFabric class has relevant functions and codes to incorporate prometheus exporter
	7. run-transaction-endpoint-v1.test is changed to incorporate the prometheus exporter for both fabric 1.4.x and 2.x versions

	Fixes hyperledger-cacti#531
  • Loading branch information
jagpreetsinghsasan committed Feb 10, 2021
1 parent add9cd9 commit 32d95d4
Show file tree
Hide file tree
Showing 14 changed files with 530 additions and 8 deletions.
48 changes: 44 additions & 4 deletions packages/cactus-plugin-ledger-connector-fabric/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion packages/cactus-plugin-ledger-connector-fabric/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"dist/*"
],
"scripts": {
"generate-sdk": "openapi-generator generate --input-spec src/main/json/openapi.json -g typescript-axios -o ./src/main/typescript/generated/openapi/typescript-axios/ --reserved-words-mappings protected=protected",
"generate-sdk": "openapi-generator generate --input-spec src/main/json/openapi.json -g typescript-axios -o ./src/main/typescript/generated/openapi/typescript-axios/ --reserved-words-mappings protected=protected --type-mappings=DateTime=Date",
"pretsc": "npm run generate-sdk",
"tsc": "tsc --project ./tsconfig.json",
"watch": "npm-watch",
Expand Down Expand Up @@ -95,6 +95,7 @@
"ngo": "2.6.2",
"node-ssh": "11.0.0",
"openapi-types": "7.0.1",
"prom-client": "13.0.0",
"temp": "0.9.1",
"typescript-optional": "2.0.1",
"uuid": "8.3.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,69 @@
"type": "string"
}
}
},
"Transaction": {
"type": "object",
"required": [
"startTime",
"endTime"
],
"properties": {
"startTime":{
"format": "date-time",
"type": "string"
},
"endTime":{
"format": "date-time",
"type": "string"
}
}
},
"Transactions": {
"type": "array",
"items":{
"$ref": "#/components/schemas/Transaction"
}
},
"PrometheusExporter": {
"type": "object",
"required": [
"metricsPollingIntervalInMin"
],
"properties": {
"metricsPollingIntervalInMin": {
"description": "The polling interval for the prometheus exporter (in minutes)",
"type": "number",
"nullable": false
},
"transactions":{
"description": "The transcation queue",
"$ref": "#/components/schemas/Transactions"
}
}
},
"PrometheusExporterMetricsRequest": {
"type": "object",
"required": [
"promExporter"
],
"properties": {
"promExporter":{
"description": "The prometheus exporter class object",
"$ref": "#/components/schemas/PrometheusExporter"
}
}
},
"PrometheusExporterMetricsResponse": {
"type": "object",
"required": [
"result"
],
"properties": {
"result": {
"type": "string"
}
}
}
}
},
Expand Down Expand Up @@ -368,6 +431,40 @@
}
}
}
},
"/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-fabric/get-prometheus-exporter-metrics": {
"get": {
"x-hyperledger-cactus": {
"http": {
"verbLowerCase": "get",
"path": "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-fabric/get-prometheus-exporter-metrics"
}
},
"operationId": "getPrometheusExporterMetricsV1",
"summary": "Get the Prometheus Metrics",
"parameters": [],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PrometheusExporterMetricsRequest"
}
}
}
},
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PrometheusExporterMetricsResponse"
}
}
}
}
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@

git_push.sh
.npmignore
.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.gitignore
api.ts
base.ts
configuration.ts
Expand Down
Loading

0 comments on commit 32d95d4

Please sign in to comment.