Skip to content

Commit 4592d8c

Browse files
Signed-off-by: jagpreetsinghsasan <[email protected]>
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
1 parent add9cd9 commit 4592d8c

File tree

14 files changed

+523
-8
lines changed

14 files changed

+523
-8
lines changed

packages/cactus-plugin-ledger-connector-fabric/package-lock.json

+44-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/cactus-plugin-ledger-connector-fabric/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"dist/*"
1313
],
1414
"scripts": {
15-
"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",
15+
"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",
1616
"pretsc": "npm run generate-sdk",
1717
"tsc": "tsc --project ./tsconfig.json",
1818
"watch": "npm-watch",
@@ -95,6 +95,7 @@
9595
"ngo": "2.6.2",
9696
"node-ssh": "11.0.0",
9797
"openapi-types": "7.0.1",
98+
"prom-client": "13.0.0",
9899
"temp": "0.9.1",
99100
"typescript-optional": "2.0.1",
100101
"uuid": "8.3.0",

packages/cactus-plugin-ledger-connector-fabric/src/main/json/openapi.json

+97
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,69 @@
286286
"type": "string"
287287
}
288288
}
289+
},
290+
"Transaction": {
291+
"type": "object",
292+
"required": [
293+
"startTime",
294+
"endTime"
295+
],
296+
"properties": {
297+
"startTime":{
298+
"format": "date-time",
299+
"type": "string"
300+
},
301+
"endTime":{
302+
"format": "date-time",
303+
"type": "string"
304+
}
305+
}
306+
},
307+
"Transactions": {
308+
"type": "array",
309+
"items":{
310+
"$ref": "#/components/schemas/Transaction"
311+
}
312+
},
313+
"PrometheusExporter": {
314+
"type": "object",
315+
"required": [
316+
"metricsPollingIntervalInMin"
317+
],
318+
"properties": {
319+
"metricsPollingIntervalInMin": {
320+
"description": "The polling interval for the prometheus exporter (in minutes)",
321+
"type": "number",
322+
"nullable": false
323+
},
324+
"transactions":{
325+
"description": "The transcation queue",
326+
"$ref": "#/components/schemas/Transactions"
327+
}
328+
}
329+
},
330+
"PrometheusExporterMetricsRequest": {
331+
"type": "object",
332+
"required": [
333+
"promExporter"
334+
],
335+
"properties": {
336+
"promExporter":{
337+
"description": "The prometheus exporter class object",
338+
"$ref": "#/components/schemas/PrometheusExporter"
339+
}
340+
}
341+
},
342+
"PrometheusExporterMetricsResponse": {
343+
"type": "object",
344+
"required": [
345+
"result"
346+
],
347+
"properties": {
348+
"result": {
349+
"type": "string"
350+
}
351+
}
289352
}
290353
}
291354
},
@@ -368,6 +431,40 @@
368431
}
369432
}
370433
}
434+
},
435+
"/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-fabric/get-prometheus-exporter-metrics": {
436+
"get": {
437+
"x-hyperledger-cactus": {
438+
"http": {
439+
"verbLowerCase": "get",
440+
"path": "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-fabric/get-prometheus-exporter-metrics"
441+
}
442+
},
443+
"operationId": "getPrometheusExporterMetricsV1",
444+
"summary": "Get the Prometheus Metrics",
445+
"parameters": [],
446+
"requestBody": {
447+
"content": {
448+
"application/json": {
449+
"schema": {
450+
"$ref": "#/components/schemas/PrometheusExporterMetricsRequest"
451+
}
452+
}
453+
}
454+
},
455+
"responses": {
456+
"200": {
457+
"description": "OK",
458+
"content": {
459+
"application/json": {
460+
"schema": {
461+
"$ref": "#/components/schemas/PrometheusExporterMetricsResponse"
462+
}
463+
}
464+
}
465+
}
466+
}
467+
}
371468
}
372469
}
373470
}

packages/cactus-plugin-ledger-connector-fabric/src/main/typescript/generated/openapi/typescript-axios/.openapi-generator-ignore

+1
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@
2424

2525
git_push.sh
2626
.npmignore
27+
.gitignore

packages/cactus-plugin-ledger-connector-fabric/src/main/typescript/generated/openapi/typescript-axios/.openapi-generator/FILES

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
.gitignore
21
api.ts
32
base.ts
43
configuration.ts

0 commit comments

Comments
 (0)