Skip to content

Commit

Permalink
Added server metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
mdaneri committed Dec 14, 2024
1 parent 3885fcc commit 14ade7a
Show file tree
Hide file tree
Showing 19 changed files with 434 additions and 58 deletions.
67 changes: 44 additions & 23 deletions docs/Getting-Started/Console.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Server Control Commands:
Ctrl+h : Hide Help
Ctrl+b : Open the first HTTP endpoint in the default browser.
----
Ctrl+m : Show Metrics
Ctrl+e : Hide Endpoints
Ctrl+t : Hide OpenAPI
Ctrl+l : Clear the Console
Expand All @@ -62,15 +63,15 @@ The behavior, appearance, and functionality of the console are highly customizab

### Configurable Settings via `Start-PodeServer`

| **Parameter** | **Description** |
|-------------------------|-----------------------------------------------------------------------------------------------------|
| `DisableTermination` | Prevents termination, suspension, or resumption of the server via keyboard interactive commands. |
| `DisableConsoleInput` | Disables all console keyboard interactions for the server. |
| `ClearHost` | Clears the console whenever the server changes state (e.g., running → suspend → resume). |
| `Quiet` | Suppresses all console output for a clean execution experience. |
| `HideOpenAPI` | Hides OpenAPI details such as specification and documentation URLs in the console output. |
| `HideEndpoints` | Hides the list of active endpoints in the console output. |
| `ShowHelp` | Displays a help menu in the console with available control commands. |
| **Parameter** | **Description** |
|-----------------------|--------------------------------------------------------------------------------------------------|
| `DisableTermination` | Prevents termination, suspension, or resumption of the server via keyboard interactive commands. |
| `DisableConsoleInput` | Disables all console keyboard interactions for the server. |
| `ClearHost` | Clears the console whenever the server changes state (e.g., running → suspend → resume). |
| `Quiet` | Suppresses all console output for a clean execution experience. |
| `HideOpenAPI` | Hides OpenAPI details such as specification and documentation URLs in the console output. |
| `HideEndpoints` | Hides the list of active endpoints in the console output. |
| `ShowHelp` | Displays a help menu in the console with available control commands. |

#### Example Usage

Expand Down Expand Up @@ -120,6 +121,9 @@ Here is the default `Server.Console` configuration:
HelpDescription = 'White' # Descriptions for each Help section key binding.
HelpDivider = 'Gray' # Dividers used in the Help section.
Divider = 'DarkGray' # Dividers between console sections.
MetricsHeader = 'Yellow' # Header for the Metric section.
MetricsLabel = 'White' # Labels for values displayed in the Metrics section.
MetricsValue = 'Green' # The actual values displayed in the Metrics section.
}
KeyBindings = @{ # Define custom key bindings for controls.
Expand All @@ -133,6 +137,7 @@ Here is the default `Server.Console` configuration:
Restart = 'r' # Restart the server.
Disable = 'd' # Disable the server.
Suspend = 'u' # Suspend the server.
Metrics = 'm' # Show Metrics.
}
}
}
Expand Down Expand Up @@ -190,20 +195,23 @@ The console colors are fully customizable via the `Colors` section of the config

### Color Settings

| **Key** | **Default Value** | **Description** |
|-----------------------|-------------------|---------------------------------------------------------------------------------|
| `Header` | `White` | The server's header section, including the Pode version and timestamp. |
| `EndpointsHeader` | `Yellow` | The header for the endpoints list. |
| `Endpoints` | `Cyan` | The endpoints themselves, including protocol and URLs. |
| `OpenApiUrls` | `Cyan` | URLs listed under the OpenAPI information section. |
| `OpenApiHeaders` | `Yellow` | Section headers for OpenAPI information. |
| `OpenApiTitles` | `White` | The OpenAPI "default" title. |
| `OpenApiSubtitles` | `Yellow` | Subtitles under OpenAPI (e.g., Specification, Documentation). |
| `HelpHeader` | `Yellow` | Header for the Help section. |
| `HelpKey` | `Green` | Key bindings listed in the Help section (e.g., `Ctrl+c`). |
| `HelpDescription` | `White` | Descriptions for each Help section key binding. |
| `HelpDivider` | `Gray` | Dividers used in the Help section. |
| `Divider` | `DarkGray` | Dividers between console sections. |
| **Key** | **Default Value** | **Description** |
|--------------------|-------------------|------------------------------------------------------------------------|
| `Header` | `White` | The server's header section, including the Pode version and timestamp. |
| `EndpointsHeader` | `Yellow` | The header for the endpoints list. |
| `Endpoints` | `Cyan` | The endpoints themselves, including protocol and URLs. |
| `OpenApiUrls` | `Cyan` | URLs listed under the OpenAPI information section. |
| `OpenApiHeaders` | `Yellow` | Section headers for OpenAPI information. |
| `OpenApiTitles` | `White` | The OpenAPI "default" title. |
| `OpenApiSubtitles` | `Yellow` | Subtitles under OpenAPI (e.g., Specification, Documentation). |
| `HelpHeader` | `Yellow` | Header for the Help section. |
| `HelpKey` | `Green` | Key bindings listed in the Help section (e.g., `Ctrl+c`). |
| `HelpDescription` | `White` | Descriptions for each Help section key binding. |
| `HelpDivider` | `Gray` | Dividers used in the Help section. |
| `Divider` | `DarkGray` | Dividers between console sections. |
| `MetricsHeader` | `Yellow` | Header for the Metrics section. |
| `MetricsLabel` | `White` | Labels for values displayed in the Metrics section. |
| `MetricsValue` | `Green` | The actual values displayed in the Metrics section. |

> **Tip:** Test your chosen colors against your terminal's background to ensure readability.
Expand All @@ -230,6 +238,7 @@ The console colors are fully customizable via the `Colors` section of the config
- **Ctrl+d**: Disable the server, preventing new requests.
- **Ctrl+u**: Suspend the server temporarily.
- **Ctrl+h**: Display or hide help instructions.
- **Ctrl+m**: Display the server metrics.

### **4. OpenAPI Integration**

Expand Down Expand Up @@ -282,3 +291,15 @@ Reduce the use of vibrant colors for a subtle appearance:
}
}
```

### **Change Metrics Section Colors**

```powershell
@{
Colors = @{
MetricsHeader = 'Blue' # Change the header color to Blue
MetricsLabel = 'Gray' # Use Gray for the value labels
MetricsValue = 'Red' # Display metric values in Red
}
}
```
28 changes: 16 additions & 12 deletions examples/server.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,21 @@
DividerLength = 75 # Length of dividers in the console.
ShowTimeStamp = $true # Display timestamp in the header.
Colors = @{ # Customize console colors.
Header = 'White'
EndpointsHeader = 'Yellow'
Endpoints = 'Cyan'
OpenApiUrls = 'Cyan'
OpenApiHeaders = 'Yellow'
OpenApiTitles = 'White'
OpenApiSubtitles = 'Yellow'
HelpHeader = 'Yellow'
HelpKey = 'Green'
HelpDescription = 'White'
HelpDivider = 'Gray'
Divider = 'DarkGray'
Header = 'White' # The server's header section, including the Pode version and timestamp.
EndpointsHeader = 'Yellow' # The header for the endpoints list.
Endpoints = 'Cyan' # The endpoints themselves, including protocol and URLs.
OpenApiUrls = 'Cyan' # URLs listed under the OpenAPI information section.
OpenApiHeaders = 'Yellow' # Section headers for OpenAPI information.
OpenApiTitles = 'White' # The OpenAPI "default" title.
OpenApiSubtitles = 'Yellow' # Subtitles under OpenAPI (e.g., Specification, Documentation).
HelpHeader = 'Yellow' # Header for the Help section.
HelpKey = 'Green' # Key bindings listed in the Help section (e.g., Ctrl+c).
HelpDescription = 'White' # Descriptions for each Help section key binding.
HelpDivider = 'Gray' # Dividers used in the Help section.
Divider = 'DarkGray' # Dividers between console sections.
MetricsHeader = 'Yellow' # Header for the Metric section.
MetricsLabel = 'White' # Labels for values displayed in the Metrics section.
MetricsValue = 'Green' # The actual values displayed in the Metrics section.
}
KeyBindings = @{ # Define custom key bindings for controls.
Browser = 'b' # Open the default browser.
Expand All @@ -108,6 +111,7 @@
Restart = 'r' # Restart the server.
Disable = 'd' # Disable the server.
Suspend = 'u' # Suspend the server.
Metrics = 'm' # Show Metrics.
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/Locales/ar/Pode.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -309,4 +309,10 @@
waitingforSuspendingMessage = 'انتظار الإيقاف...'
waitingforResumingMessage = 'انتظار الاستئناف...'
terminatedMessage = 'تم الإنهاء'
showMetricsMessage = 'عرض المقاييس'
clearConsoleMessage = 'مسح وحدة التحكم'
serverMetricsMessage = 'مقاييس الخادم'
totalUptimeMessage = 'إجمالي وقت التشغيل:'
uptimeSinceLastRestartMessage = 'وقت التشغيل منذ آخر إعادة تشغيل:'
totalRestartMessage = 'إجمالي عدد عمليات إعادة التشغيل:'
}
6 changes: 6 additions & 0 deletions src/Locales/de/Pode.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -309,4 +309,10 @@
waitingforSuspendingMessage = 'Warten auf das Suspendieren ...'
waitingforResumingMessage = 'Warten auf das Fortsetzen ...'
terminatedMessage = 'Beendet'
showMetricsMessage = 'Metriken anzeigen'
clearConsoleMessage = 'Konsole löschen'
serverMetricsMessage = 'Servermetriken'
totalUptimeMessage = 'Gesamtlaufzeit:'
uptimeSinceLastRestartMessage = 'Laufzeit seit dem letzten Neustart:'
totalRestartMessage = 'Gesamtanzahl der Neustarts:'
}
6 changes: 6 additions & 0 deletions src/Locales/en-us/Pode.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -309,4 +309,10 @@
waitingforSuspendingMessage = 'Waiting for suspending ...'
waitingforResumingMessage = 'Waiting for resuming ...'
terminatedMessage = 'Terminated'
showMetricsMessage = 'Show Metrics'
clearConsoleMessage = 'Clear the Console'
serverMetricsMessage = 'Server Metrics'
totalUptimeMessage = 'Total Uptime:'
uptimeSinceLastRestartMessage = 'Uptime Since Last Restart:'
totalRestartMessage = 'Total Number of Restart:'
}
6 changes: 6 additions & 0 deletions src/Locales/en/Pode.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -309,4 +309,10 @@
waitingforSuspendingMessage = 'Waiting for suspending ...'
waitingforResumingMessage = 'Waiting for resuming ...'
terminatedMessage = 'Terminated'
showMetricsMessage = 'Show Metrics'
clearConsoleMessage = 'Clear the Console'
serverMetricsMessage = 'Server Metrics'
totalUptimeMessage = 'Total Uptime:'
uptimeSinceLastRestartMessage = 'Uptime Since Last Restart:'
totalRestartMessage = 'Total Number of Restart:'
}
6 changes: 6 additions & 0 deletions src/Locales/es/Pode.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -309,4 +309,10 @@
waitingforSuspendingMessage = 'Esperando para suspender ...'
waitingforResumingMessage = 'Esperando para reanudar ...'
terminatedMessage = 'Terminado'
showMetricsMessage = 'Mostrar métricas'
clearConsoleMessage = 'Limpiar la consola'
serverMetricsMessage = 'Métricas del servidor'
totalUptimeMessage = 'Tiempo total de actividad:'
uptimeSinceLastRestartMessage = 'Tiempo de actividad desde el último reinicio:'
totalRestartMessage = 'Número total de reinicios:'
}
6 changes: 6 additions & 0 deletions src/Locales/fr/Pode.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -309,4 +309,10 @@
waitingforSuspendingMessage = 'En attente de la suspension ...'
waitingforResumingMessage = 'En attente de la reprise ...'
terminatedMessage = 'Terminé'
showMetricsMessage = 'Afficher les métriques'
clearConsoleMessage = 'Effacer la console'
serverMetricsMessage = 'Métriques du serveur'
totalUptimeMessage = 'Temps de fonctionnement total :'
uptimeSinceLastRestartMessage = 'Temps de fonctionnement depuis le dernier redémarrage :'
totalRestartMessage = 'Nombre total de redémarrages :'
}
6 changes: 6 additions & 0 deletions src/Locales/it/Pode.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -309,4 +309,10 @@
waitingforSuspendingMessage = 'Attesa per sospensione ...'
waitingforResumingMessage = 'Attesa per ripresa ...'
terminatedMessage = 'Terminato'
showMetricsMessage = 'Mostra metriche'
clearConsoleMessage = 'Cancella la console'
serverMetricsMessage = 'Metriche del server'
totalUptimeMessage = 'Tempo totale di attività:'
uptimeSinceLastRestartMessage = "Tempo di attività dall'ultimo riavvio:"
totalRestartMessage = 'Numero totale di riavvii:'
}
6 changes: 6 additions & 0 deletions src/Locales/ja/Pode.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -309,4 +309,10 @@
waitingforSuspendingMessage = '停止待機中...'
waitingforResumingMessage = '再開待機中...'
terminatedMessage = '終了しました'
showMetricsMessage = 'メトリクスを表示'
clearConsoleMessage = 'コンソールをクリア'
serverMetricsMessage = 'サーバーメトリクス'
totalUptimeMessage = '総稼働時間:'
uptimeSinceLastRestartMessage = '最後の再起動からの稼働時間:'
totalRestartMessage = '再起動の総数:'
}
6 changes: 6 additions & 0 deletions src/Locales/ko/Pode.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -309,4 +309,10 @@
waitingforSuspendingMessage = '일시 정지 대기 중...'
waitingforResumingMessage = '재개 대기 중...'
terminatedMessage = '종료됨'
showMetricsMessage = '메트릭 표시'
clearConsoleMessage = '콘솔 지우기'
serverMetricsMessage = '서버 메트릭'
totalUptimeMessage = '총 가동 시간:'
uptimeSinceLastRestartMessage = '마지막 재시작 이후 가동 시간:'
totalRestartMessage = '총 재시작 횟수:'
}
6 changes: 6 additions & 0 deletions src/Locales/nl/Pode.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -309,4 +309,10 @@
waitingforSuspendingMessage = 'Oczekiwanie na zawieszenie ...'
waitingforResumingMessage = 'Oczekiwanie na wznowienie ...'
terminatedMessage = 'Beëindigd'
showMetricsMessage = 'Toon statistieken'
clearConsoleMessage = 'Console wissen'
serverMetricsMessage = 'Serverstatistieken'
totalUptimeMessage = 'Totale uptime:'
uptimeSinceLastRestartMessage = 'Uptime sinds laatste herstart:'
totalRestartMessage = 'Totaal aantal herstarts:'
}
Loading

0 comments on commit 14ade7a

Please sign in to comment.