go-duck-cli 1.3.371 → 1.4.5
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/README.md +20 -1
- package/generators/config.js +8 -0
- package/generators/devops.js +25 -18
- package/generators/logger.js +50 -1
- package/generators/mqtt-topics.js +54 -0
- package/generators/postman.js +2 -1
- package/generators/swagger.js +18 -18
- package/generators/telemetry.js +167 -0
- package/index.js +1 -0
- package/package.json +1 -1
- package/templates/docs/pages/configuration.hbs +46 -5
- package/templates/docs/pages/mosquitto.hbs +6 -0
- package/templates/docs/pages/observability.hbs +55 -0
- package/templates/go/router.go.hbs +808 -0
|
@@ -68,11 +68,15 @@
|
|
|
68
68
|
gcs: { enabled: false, bucket: "bucket-name", credentials-file: "keys.json" }
|
|
69
69
|
minio: { enabled: true, bucket: "dev", endpoint: "localhost:9000" }
|
|
70
70
|
|
|
71
|
-
# ---
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
71
|
+
# --- Telemetry & Metrics ---
|
|
72
|
+
telemetry:
|
|
73
|
+
otel:
|
|
74
|
+
enabled: true
|
|
75
|
+
endpoint: "localhost:4317"
|
|
76
|
+
metrics:
|
|
77
|
+
prometheus-enabled: true
|
|
78
|
+
stream-enabled: true
|
|
79
|
+
stream-interval: "1s"
|
|
76
80
|
</div>
|
|
77
81
|
|
|
78
82
|
<!-- PARAMETER REFERENCE -->
|
|
@@ -203,6 +207,43 @@
|
|
|
203
207
|
</div>
|
|
204
208
|
</section>
|
|
205
209
|
|
|
210
|
+
<!-- SECTION: TELEMETRY -->
|
|
211
|
+
<section class="mb-16">
|
|
212
|
+
<h3 class="text-xl font-bold text-rose-700 mb-4 flex items-center">
|
|
213
|
+
<span class="w-2 h-2 rounded-full bg-rose-600 mr-2"></span>
|
|
214
|
+
5. Telemetry & Metrics (telemetry)
|
|
215
|
+
</h3>
|
|
216
|
+
<p class="text-sm text-slate-500 mb-4 italic leading-relaxed">Integrated observability stack powering OpenTelemetry traces, Prometheus metrics, and Server-Sent Events (SSE) streaming dashboards.</p>
|
|
217
|
+
<div class="overflow-hidden border border-slate-200 rounded-2xl shadow-sm">
|
|
218
|
+
<table class="w-full text-left border-collapse">
|
|
219
|
+
<thead class="bg-slate-50 border-b border-slate-200">
|
|
220
|
+
<tr>
|
|
221
|
+
<th class="p-4 text-xs font-black text-slate-500 uppercase tracking-widest">Parameter</th>
|
|
222
|
+
<th class="p-4 text-xs font-black text-slate-500 uppercase tracking-widest">Purpose</th>
|
|
223
|
+
</tr>
|
|
224
|
+
</thead>
|
|
225
|
+
<tbody class="text-sm text-slate-600">
|
|
226
|
+
<tr class="border-b border-slate-100 italic">
|
|
227
|
+
<td class="p-4 font-mono text-rose-600">otel.enabled</td>
|
|
228
|
+
<td class="p-4 text-slate-600">Enables OpenTelemetry context propagation across Gin routers and GORM database drivers.</td>
|
|
229
|
+
</tr>
|
|
230
|
+
<tr class="border-b border-slate-100 italic font-medium">
|
|
231
|
+
<td class="p-4 font-mono text-rose-600">metrics.prometheus-enabled</td>
|
|
232
|
+
<td class="p-4 text-slate-600">Exposes a <code>/metrics</code> endpoint for Kubernetes Horizontal Pod Autoscaling (HPA) and Prometheus scraping.</td>
|
|
233
|
+
</tr>
|
|
234
|
+
<tr class="border-b border-slate-100 italic">
|
|
235
|
+
<td class="p-4 font-mono text-rose-600">metrics.stream-enabled</td>
|
|
236
|
+
<td class="p-4 text-slate-600">Exposes a <code>/api/system/stream</code> Server-Sent Events endpoint streaming CPU, Memory, and Load percentages.</td>
|
|
237
|
+
</tr>
|
|
238
|
+
<tr>
|
|
239
|
+
<td class="p-4 font-mono text-rose-600">metrics.stream-interval</td>
|
|
240
|
+
<td class="p-4 text-slate-600">The refresh rate of the SSE stream (e.g., "1s", "500ms").</td>
|
|
241
|
+
</tr>
|
|
242
|
+
</tbody>
|
|
243
|
+
</table>
|
|
244
|
+
</div>
|
|
245
|
+
</section>
|
|
246
|
+
|
|
206
247
|
<!-- RESILIENCE & SEARCH -->
|
|
207
248
|
<div class="grid grid-cols-1 md:grid-cols-2 gap-8 mb-20">
|
|
208
249
|
<div class="p-8 bg-rose-50 rounded-[2.5rem] border border-rose-100">
|
|
@@ -29,6 +29,12 @@ messaging.Publish("events/users", event)</code></pre>
|
|
|
29
29
|
mosquitto_sub -h localhost -p {{mqttPort}} -t "audit/logs/#" -v</code></pre>
|
|
30
30
|
</section>
|
|
31
31
|
|
|
32
|
+
<section class="mb-10">
|
|
33
|
+
<h2 class="text-2xl font-bold text-gray-800 mb-4 border-b pb-2">Interactive Swagger Console</h2>
|
|
34
|
+
<p class="mb-4">GO-DUCK's automatically generated Swagger UI features a built-in <strong>Interactive MQTT Topics Dictionary</strong>. By connecting via WebSockets, it allows authenticated users to dynamically <strong>SUBSCRIBE</strong> to event streams or <strong>PUBLISH</strong> payloads directly from the documentation interface!</p>
|
|
35
|
+
<p class="mb-4 text-sm text-gray-600 italic">Note: Ensure your Mosquitto broker is configured to accept WebSocket connections (default port 9001) for this feature to work.</p>
|
|
36
|
+
</section>
|
|
37
|
+
|
|
32
38
|
<section class="mb-10">
|
|
33
39
|
<h2 class="text-2xl font-bold text-gray-800 mb-4 border-b pb-2">External Resources</h2>
|
|
34
40
|
<ul class="space-y-2">
|
|
@@ -32,3 +32,58 @@ go-duck:
|
|
|
32
32
|
<h3 class="font-semibold mb-2 mt-6">3. System Infrastructure Metrics (Statsd)</h3>
|
|
33
33
|
<p class="mb-4 text-gray-700">The <code>logger</code> package has a sidecar implementation for Datadog's <code>statsd</code>. A developer can quickly drop custom <code>logger.Count("api.hit")</code> or <code>logger.Histogram("db.latency")</code> functions into their services to populate dashboard charts.</p>
|
|
34
34
|
</section>
|
|
35
|
+
|
|
36
|
+
<section class="mb-10">
|
|
37
|
+
<h2 class="text-2xl font-bold text-gray-800 mb-4 border-b pb-2">4. Prometheus & Kubernetes Autoscaling (HPA)</h2>
|
|
38
|
+
<p class="mb-4">For Kubernetes environments, the generated microservices automatically expose a standard <code>GET /metrics</code> Prometheus scraping endpoint powered by <code>github.com/prometheus/client_golang</code>. This allows the Kubernetes Metrics Server or Prometheus Adapter to constantly poll your API and scale up your Pod Replicas horizontally when traffic increases.</p>
|
|
39
|
+
</section>
|
|
40
|
+
|
|
41
|
+
<section class="mb-10">
|
|
42
|
+
<h2 class="text-2xl font-bold text-gray-800 mb-4 border-b pb-2">5. Real-Time System Streams (SSE)</h2>
|
|
43
|
+
<p class="mb-4">Need to see exactly how much your server is "holding up" in real time without refreshing a dashboard? GO-DUCK injects a Server-Sent Events (SSE) streaming endpoint at <code>GET /api/system/stream</code>.</p>
|
|
44
|
+
<p class="mb-4">Powered by <code>github.com/shirou/gopsutil</code>, this endpoint streams live JSON payloads directly to your browser containing CPU utilization, Memory consumption, and an aggregated Load Percentage metric at a configurable interval (defaults to 1 second).</p>
|
|
45
|
+
|
|
46
|
+
<pre><code class="language-json">{
|
|
47
|
+
"timestamp": "2026-05-28T19:30:01Z",
|
|
48
|
+
"cpu_percent": 45.2,
|
|
49
|
+
"mem_percent": 68.4,
|
|
50
|
+
"mem_used_mb": 1024,
|
|
51
|
+
"mem_total_mb": 4096,
|
|
52
|
+
"load_percentage": 56.8
|
|
53
|
+
}</code></pre>
|
|
54
|
+
</section>
|
|
55
|
+
|
|
56
|
+
<section class="mb-10">
|
|
57
|
+
<h2 class="text-2xl font-bold text-gray-800 mb-4 border-b pb-2">6. Full JHipster-Style System Metrics JSON</h2>
|
|
58
|
+
<p class="mb-4">For developers who prefer a deep dive into the JVM-style metrics (Go equivalents), a massive, rich telemetry JSON payload is natively exposed at <code>GET /api/system/metrics</code>.</p>
|
|
59
|
+
<p class="mb-4">This endpoint acts identically to the classic JHipster <code>/management/jhimetrics</code> endpoint, and will output:</p>
|
|
60
|
+
<ul class="list-disc pl-6 mb-4 text-gray-700">
|
|
61
|
+
<li><strong>System/Go Stats:</strong> Process Uptime, GC Pauses, Goroutine counts, Heap allocations, and Open Files.</li>
|
|
62
|
+
<li><strong>HTTP Tracking Middleware:</strong> Live request counts, mean execution times, and max execution times grouped by both HTTP Status Codes and specific API Endpoints.</li>
|
|
63
|
+
</ul>
|
|
64
|
+
|
|
65
|
+
<pre><code class="language-json">{
|
|
66
|
+
"system": {
|
|
67
|
+
"uptime": "10 days 4 hours 7 minutes 35 seconds",
|
|
68
|
+
"process_cpu_usage": 1.76,
|
|
69
|
+
"system_cpu_usage": 1.76,
|
|
70
|
+
"process_files_open": 359,
|
|
71
|
+
"heap_alloc_mb": 104,
|
|
72
|
+
"heap_sys_mb": 629,
|
|
73
|
+
"num_gc": 12,
|
|
74
|
+
"gc_pause_total_ms": 45,
|
|
75
|
+
"goroutines": 52
|
|
76
|
+
},
|
|
77
|
+
"endpoints": {
|
|
78
|
+
"GET /api/account": {
|
|
79
|
+
"count": 1733,
|
|
80
|
+
"mean_time_ms": 338.208,
|
|
81
|
+
"max_time_ms": 1050.2
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
"status_codes": {
|
|
85
|
+
"200": { "count": 546626, "mean_time_ms": 487.64, "max_time_ms": 3.45 }
|
|
86
|
+
},
|
|
87
|
+
"failed_calls": 284
|
|
88
|
+
}</code></pre>
|
|
89
|
+
</section>
|