go-duck-cli 1.4.14 → 1.4.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/generators/telemetry.js
CHANGED
|
@@ -143,6 +143,63 @@ var globalMetrics = &AppMetrics{
|
|
|
143
143
|
StatusCodes: make(map[int]*StatusStats),
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
+
type MetricsBroker struct {
|
|
147
|
+
clients map[chan AppMetrics]bool
|
|
148
|
+
mu sync.Mutex
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
var GlobalMetricsBroker = &MetricsBroker{
|
|
152
|
+
clients: make(map[chan AppMetrics]bool),
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
func (b *MetricsBroker) AddClient(client chan AppMetrics) {
|
|
156
|
+
b.mu.Lock()
|
|
157
|
+
defer b.mu.Unlock()
|
|
158
|
+
b.clients[client] = true
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
func (b *MetricsBroker) RemoveClient(client chan AppMetrics) {
|
|
162
|
+
b.mu.Lock()
|
|
163
|
+
defer b.mu.Unlock()
|
|
164
|
+
delete(b.clients, client)
|
|
165
|
+
close(client)
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
func (b *MetricsBroker) Broadcast(metrics *AppMetrics) {
|
|
169
|
+
metrics.Mu.RLock()
|
|
170
|
+
safeCopy := AppMetrics{
|
|
171
|
+
StartTime: metrics.StartTime,
|
|
172
|
+
Endpoints: make(map[string]*EndpointStats),
|
|
173
|
+
StatusCodes: make(map[int]*StatusStats),
|
|
174
|
+
FailedCalls: metrics.FailedCalls,
|
|
175
|
+
}
|
|
176
|
+
for k, v := range metrics.Endpoints {
|
|
177
|
+
safeCopy.Endpoints[k] = &EndpointStats{Count: v.Count, MeanTime: v.MeanTime, MaxTime: v.MaxTime, TotalTime: v.TotalTime}
|
|
178
|
+
}
|
|
179
|
+
for k, v := range metrics.StatusCodes {
|
|
180
|
+
safeCopy.StatusCodes[k] = &StatusStats{Count: v.Count, MeanTime: v.MeanTime, MaxTime: v.MaxTime, TotalTime: v.TotalTime}
|
|
181
|
+
}
|
|
182
|
+
metrics.Mu.RUnlock()
|
|
183
|
+
|
|
184
|
+
b.mu.Lock()
|
|
185
|
+
defer b.mu.Unlock()
|
|
186
|
+
for client := range b.clients {
|
|
187
|
+
select {
|
|
188
|
+
case client <- safeCopy:
|
|
189
|
+
default:
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
func init() {
|
|
195
|
+
go func() {
|
|
196
|
+
for {
|
|
197
|
+
time.Sleep(1 * time.Second)
|
|
198
|
+
GlobalMetricsBroker.Broadcast(globalMetrics)
|
|
199
|
+
}
|
|
200
|
+
}()
|
|
201
|
+
}
|
|
202
|
+
|
|
146
203
|
func MetricsTrackingMiddleware(cfg *config.Config) gin.HandlerFunc {
|
|
147
204
|
return func(c *gin.Context) {
|
|
148
205
|
start := time.Now()
|
package/package.json
CHANGED
|
@@ -2,7 +2,6 @@ package router
|
|
|
2
2
|
|
|
3
3
|
import (
|
|
4
4
|
"context"
|
|
5
|
-
"encoding/json"
|
|
6
5
|
"fmt"
|
|
7
6
|
"io"
|
|
8
7
|
"log"
|
|
@@ -19,8 +18,6 @@ import (
|
|
|
19
18
|
"gorm.io/gorm"
|
|
20
19
|
"gorm.io/plugin/opentelemetry/tracing"
|
|
21
20
|
"github.com/prometheus/client_golang/prometheus/promhttp"
|
|
22
|
-
"github.com/shirou/gopsutil/v3/cpu"
|
|
23
|
-
"github.com/shirou/gopsutil/v3/mem"
|
|
24
21
|
{{#if multitenancy_enabled}}
|
|
25
22
|
"{{app_name}}/management"
|
|
26
23
|
{{/if}}
|
|
@@ -1540,7 +1537,7 @@ func SetupRouter(appConfig *config.Config) *gin.Engine {
|
|
|
1540
1537
|
}
|
|
1541
1538
|
|
|
1542
1539
|
document.getElementById('live-logs-btn').onclick = () => {
|
|
1543
|
-
if (!keycloak.authenticated && {{appConfig.GoDuck.Security.OIDC.Enabled}}) {
|
|
1540
|
+
if (!keycloak.authenticated && {{#if appConfig.GoDuck.Security.OIDC.Enabled}}true{{else}}false{{/if}}) {
|
|
1544
1541
|
alert('Please login to view Server Logs');
|
|
1545
1542
|
return;
|
|
1546
1543
|
}
|
|
@@ -1567,7 +1564,7 @@ func SetupRouter(appConfig *config.Config) *gin.Engine {
|
|
|
1567
1564
|
};
|
|
1568
1565
|
|
|
1569
1566
|
document.getElementById('compact-widget-btn').onclick = () => {
|
|
1570
|
-
if (!keycloak.authenticated && {{appConfig.GoDuck.Security.OIDC.Enabled}}) {
|
|
1567
|
+
if (!keycloak.authenticated && {{#if appConfig.GoDuck.Security.OIDC.Enabled}}true{{else}}false{{/if}}) {
|
|
1571
1568
|
alert('Please login to view system telemetry.');
|
|
1572
1569
|
return;
|
|
1573
1570
|
}
|