Monolith API
Optionale, read-only Betriebsdaten für Plugins – Paper-APIs bleiben der Standard.
MonolithRuntime Monolith.runtime()Liefert den registrierten Runtime-Service oder wirft IllegalStateException, wenn er nicht verfügbar ist.
MonolithRuntimeMonolithDiagnostics Monolith.diagnostics()Liefert den Diagnose-Service oder wirft IllegalStateException, wenn er nicht verfügbar ist.
MonolithDiagnosticsimport dev.monolith.api.Monolith;
import dev.monolith.api.RuntimeSnapshot;
RuntimeSnapshot snapshot = Monolith.runtime().snapshot();
double p95 = snapshot.p95Mspt();
int health = Monolith.runtime().health().score();RuntimeSnapshot snapshot()Neueste unveränderliche Runtime-Stichprobe.
RuntimeSnapshotHealthAssessment health()Transparente Health-Bewertung mit Score, Band und allen Abzügen.
HealthAssessmentAdaptiveState adaptiveState()NORMAL, CONSTRAINED, RECOVERING oder DISABLED.
AdaptiveStateRuntimeProfile profile()Aktuelles oder zuletzt abgeschlossenes begrenztes Pluginprofil.
RuntimeProfileAllocationProfile allocationProfile()Allokationsevidenz des expliziten Profils samt Messqualität.
AllocationProfilevoid startProfile(int durationSeconds)Startet ein Profil für 5–300 Sekunden; außerhalb des Bereichs folgt IllegalArgumentException.
void stopProfile()Stoppt das Profil und behält den gesammelten Snapshot.
Der Record enthält Zeit, Uptime, TPS 1/5/15, vollständige MSPT-Perzentile, Spieler, Chunks, Entitäten, Heap, GC, Allokation, CPU, Threads, Netzwerk, Chunk-Lifecycles sowie Hotpath-Millisekunden und -Aufrufe. Nicht verfügbare numerische Metriken sind -1 oder NaN gemäß Feldvertrag.
double tickBudgetUsed()Average MSPT geteilt durch das 50-ms-Tickbudget.
doubleTickBudgetClass tickBudgetClass()Klassifiziert Average MSPT in EXCELLENT, HEALTHY, HEAVY, SATURATED, OVER_BUDGET oder SEVERE.
TickBudgetClassDiagnosticReport analyze(Throwable throwable, DiagnosticContext context)Analysiert und persistiert den Originalfehler mit nicht sensiblem Kontext.
DiagnosticReportList<DiagnosticReport> recent(int limit)Liefert die jüngsten Berichte zuerst.
List<DiagnosticReport>try {
runOperation();
} catch (Throwable throwable) {
var context = DiagnosticContext.plugin("MyPlugin", "cache refresh");
DiagnosticReport report = Monolith.diagnostics().analyze(throwable, context);
logger.warning("Monolith error ID: " + report.errorId());
}| Wert | Bedeutung | Verwendung |
|---|---|---|
| EXACT | Jedes Ereignis an der Grenze gezählt | Direkte Zähler |
| SAMPLED | Periodische Beobachtung | Runtime-Stichproben |
| ESTIMATED | Modell oder indirekte Zähler | Explizit kennzeichnen |
| UNAVAILABLE | Kein belastbarer Wert | Nicht durch Null ersetzen |
