stuff
This commit is contained in:
+232
@@ -0,0 +1,232 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>OTel Debug Visualizer</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
margin: 0;
|
||||
padding: 20px;
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
.container {
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
h1 {
|
||||
color: #333;
|
||||
text-align: center;
|
||||
}
|
||||
.status {
|
||||
padding: 10px;
|
||||
margin-bottom: 20px;
|
||||
border-radius: 5px;
|
||||
text-align: center;
|
||||
}
|
||||
.connected {
|
||||
background-color: #d4edda;
|
||||
color: #155724;
|
||||
border: 1px solid #c3e6cb;
|
||||
}
|
||||
.disconnected {
|
||||
background-color: #f8d7da;
|
||||
color: #721c24;
|
||||
border: 1px solid #f5c6cb;
|
||||
}
|
||||
.data-section {
|
||||
background: white;
|
||||
border-radius: 8px;
|
||||
padding: 20px;
|
||||
margin-bottom: 20px;
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
.data-section h2 {
|
||||
margin-top: 0;
|
||||
color: #333;
|
||||
border-bottom: 2px solid #007bff;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
.data-content {
|
||||
max-height: 400px;
|
||||
overflow-y: auto;
|
||||
background: #f8f9fa;
|
||||
padding: 10px;
|
||||
border-radius: 4px;
|
||||
font-family: monospace;
|
||||
font-size: 12px;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
.clear-btn {
|
||||
background: #dc3545;
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 8px 16px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
margin-top: 10px;
|
||||
}
|
||||
.clear-btn:hover {
|
||||
background: #c82333;
|
||||
}
|
||||
.stats {
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.stat {
|
||||
background: white;
|
||||
padding: 15px;
|
||||
border-radius: 8px;
|
||||
text-align: center;
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
||||
flex: 1;
|
||||
margin: 0 10px;
|
||||
}
|
||||
.stat h3 {
|
||||
margin: 0;
|
||||
color: #007bff;
|
||||
}
|
||||
.stat p {
|
||||
margin: 5px 0 0 0;
|
||||
font-size: 24px;
|
||||
font-weight: bold;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>OpenTelemetry Debug Visualizer</h1>
|
||||
|
||||
<div id="status" class="status disconnected">
|
||||
Disconnected from server
|
||||
</div>
|
||||
|
||||
<div class="stats">
|
||||
<div class="stat">
|
||||
<h3>Traces</h3>
|
||||
<p id="traces-count">0</p>
|
||||
</div>
|
||||
<div class="stat">
|
||||
<h3>Metrics</h3>
|
||||
<p id="metrics-count">0</p>
|
||||
</div>
|
||||
<div class="stat">
|
||||
<h3>Logs</h3>
|
||||
<p id="logs-count">0</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="data-section">
|
||||
<h2>Traces</h2>
|
||||
<div id="traces" class="data-content"></div>
|
||||
<button class="clear-btn" onclick="clearData('traces')">
|
||||
Clear Traces
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="data-section">
|
||||
<h2>Metrics</h2>
|
||||
<div id="metrics" class="data-content"></div>
|
||||
<button class="clear-btn" onclick="clearData('metrics')">
|
||||
Clear Metrics
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="data-section">
|
||||
<h2>Logs</h2>
|
||||
<div id="logs" class="data-content"></div>
|
||||
<button class="clear-btn" onclick="clearData('logs')">
|
||||
Clear Logs
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
let ws;
|
||||
let tracesCount = 0;
|
||||
let metricsCount = 0;
|
||||
let logsCount = 0;
|
||||
|
||||
function connect() {
|
||||
ws = new WebSocket("ws://localhost:8080/ws");
|
||||
|
||||
ws.onopen = function () {
|
||||
document.getElementById("status").className = "status connected";
|
||||
document.getElementById("status").textContent = "Connected to server";
|
||||
};
|
||||
|
||||
ws.onmessage = function (event) {
|
||||
try {
|
||||
const data = JSON.parse(event.data);
|
||||
displayData(data);
|
||||
} catch (e) {
|
||||
console.error("Failed to parse data:", e);
|
||||
}
|
||||
};
|
||||
|
||||
ws.onclose = function () {
|
||||
document.getElementById("status").className = "status disconnected";
|
||||
document.getElementById("status").textContent =
|
||||
"Disconnected from server - reconnecting...";
|
||||
setTimeout(connect, 1000);
|
||||
};
|
||||
|
||||
ws.onerror = function (error) {
|
||||
console.error("WebSocket error:", error);
|
||||
};
|
||||
}
|
||||
|
||||
function displayData(data) {
|
||||
let container;
|
||||
let countElement;
|
||||
|
||||
if (data.resourceSpans) {
|
||||
// Traces
|
||||
container = document.getElementById("traces");
|
||||
countElement = document.getElementById("traces-count");
|
||||
tracesCount++;
|
||||
countElement.textContent = tracesCount;
|
||||
} else if (data.resourceMetrics) {
|
||||
// Metrics
|
||||
container = document.getElementById("metrics");
|
||||
countElement = document.getElementById("metrics-count");
|
||||
metricsCount++;
|
||||
countElement.textContent = metricsCount;
|
||||
} else if (data.resourceLogs) {
|
||||
// Logs
|
||||
container = document.getElementById("logs");
|
||||
countElement = document.getElementById("logs-count");
|
||||
logsCount++;
|
||||
countElement.textContent = logsCount;
|
||||
} else {
|
||||
return; // Unknown data type
|
||||
}
|
||||
|
||||
const timestamp = new Date().toLocaleTimeString();
|
||||
const dataDiv = document.createElement("div");
|
||||
dataDiv.innerHTML = `<strong>[${timestamp}]</strong> ${JSON.stringify(
|
||||
data,
|
||||
null,
|
||||
2
|
||||
)}<hr>`;
|
||||
container.appendChild(dataDiv);
|
||||
container.scrollTop = container.scrollHeight;
|
||||
}
|
||||
|
||||
function clearData(type) {
|
||||
const container = document.getElementById(type);
|
||||
container.innerHTML = "";
|
||||
const countElement = document.getElementById(type + "-count");
|
||||
if (type === "traces") tracesCount = 0;
|
||||
else if (type === "metrics") metricsCount = 0;
|
||||
else if (type === "logs") logsCount = 0;
|
||||
countElement.textContent = "0";
|
||||
}
|
||||
|
||||
// Connect on page load
|
||||
connect();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user