Skip to content

Commit bb55940

Browse files
authored
export prom metrics from the printer (#121)
add in prom metrics to export machine information where available
1 parent 6d2dcae commit bb55940

File tree

13 files changed

+285
-63
lines changed

13 files changed

+285
-63
lines changed

Cargo.lock

Lines changed: 65 additions & 44 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ multer = { version = "3.1.0", features = ["json"] }
4141
opentelemetry = "0.25.0"
4242
opentelemetry-otlp = "0.25.0"
4343
opentelemetry_sdk = { version = "0.25.0", features = ["rt-tokio"] }
44+
prometheus-client = "0.22.3"
4445
reqwest = { version = "0.12", default-features = false, features = ["json", "rustls-tls"] }
4546
schemars = { version = "0.8", features = ["chrono", "uuid1", "bigdecimal"] }
4647
serde = { version = "1.0", features = ["derive"] }

moonraker/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ pub use print::InfoResponse;
2121
pub use upload::{DeleteResponse, DeleteResponseItem, UploadResponse, UploadResponseItem};
2222

2323
/// Client is a moonraker instance which can accept gcode for printing.
24+
#[derive(Clone, Debug, PartialEq)]
2425
pub struct Client {
2526
pub(crate) url_base: String,
2627
}

openapi/api-tags.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
API operations found with tag "hidden"
2+
OPERATION ID URL PATH
3+
get_metrics /metrics
4+
15
API operations found with tag "machines"
26
OPERATION ID URL PATH
37
get_machine /machines/{id}

openapi/api.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,34 @@
425425
]
426426
}
427427
},
428+
"/metrics": {
429+
"get": {
430+
"operationId": "get_metrics",
431+
"responses": {
432+
"200": {
433+
"content": {
434+
"application/json": {
435+
"schema": {
436+
"title": "String",
437+
"type": "string"
438+
}
439+
}
440+
},
441+
"description": "successful operation"
442+
},
443+
"4XX": {
444+
"$ref": "#/components/responses/Error"
445+
},
446+
"5XX": {
447+
"$ref": "#/components/responses/Error"
448+
}
449+
},
450+
"summary": "List available machines and their statuses",
451+
"tags": [
452+
"hidden"
453+
]
454+
}
455+
},
428456
"/ping": {
429457
"get": {
430458
"operationId": "ping",
@@ -492,6 +520,13 @@
492520
}
493521
},
494522
"tags": [
523+
{
524+
"description": "Hidden API endpoints that should not show up in the docs.",
525+
"externalDocs": {
526+
"url": "https://docs.zoo.dev/api/machines"
527+
},
528+
"name": "hidden"
529+
},
495530
{
496531
"description": "Utilities for making parts and discovering machines.",
497532
"externalDocs": {

openapi/tag-config.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@
1313
"external_docs": {
1414
"url": "https://docs.zoo.dev/api/machines"
1515
}
16+
},
17+
"hidden": {
18+
"description": "Hidden API endpoints that should not show up in the docs.",
19+
"external_docs": {
20+
"url": "https://docs.zoo.dev/api/machines"
21+
}
1622
}
1723
}
1824
}

0 commit comments

Comments
 (0)