kavoru 0.6.0 → 0.7.1
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/package.json +1 -1
- package/src/features.ts +24 -12
package/package.json
CHANGED
package/src/features.ts
CHANGED
|
@@ -108,7 +108,7 @@ const FEATURE_PATHS: Record<FeatureId, string[]> = {
|
|
|
108
108
|
],
|
|
109
109
|
resend: ["src/infra/resend"],
|
|
110
110
|
cron: ["src/schedules"],
|
|
111
|
-
docker: ["Dockerfile", "docker-compose.yaml"],
|
|
111
|
+
docker: ["Dockerfile", "docker-compose.yaml", "docker/otel.Dockerfile"],
|
|
112
112
|
};
|
|
113
113
|
|
|
114
114
|
const FEATURE_DEPENDENCIES: Partial<
|
|
@@ -276,11 +276,14 @@ async function patchModulesIndex(
|
|
|
276
276
|
await writeText(projectDir, relativePath, content);
|
|
277
277
|
}
|
|
278
278
|
|
|
279
|
-
|
|
279
|
+
export function buildEntryIndex(selection: FeatureSelection): string {
|
|
280
280
|
const imports = [
|
|
281
281
|
selection.sentry
|
|
282
282
|
? 'import { initSentry, flushSentry } from "./infra/sentry";'
|
|
283
283
|
: null,
|
|
284
|
+
selection.otel
|
|
285
|
+
? 'import {\n bootstrapOpenTelemetry,\n shutdownOpenTelemetry,\n} from "./infra/telemetry";'
|
|
286
|
+
: null,
|
|
284
287
|
selection.kafka
|
|
285
288
|
? 'import { startKafka, stopKafka } from "./infra/kafka";'
|
|
286
289
|
: null,
|
|
@@ -291,8 +294,11 @@ async function patchEntryIndex(projectDir: string, selection: FeatureSelection)
|
|
|
291
294
|
|
|
292
295
|
const body: string[] = [];
|
|
293
296
|
|
|
297
|
+
if (selection.otel) {
|
|
298
|
+
body.push("", "bootstrapOpenTelemetry();");
|
|
299
|
+
}
|
|
294
300
|
if (selection.sentry) {
|
|
295
|
-
body.push("
|
|
301
|
+
body.push("initSentry();");
|
|
296
302
|
}
|
|
297
303
|
|
|
298
304
|
body.push("", "const server = new HttpServer();", "");
|
|
@@ -326,6 +332,9 @@ async function patchEntryIndex(projectDir: string, selection: FeatureSelection)
|
|
|
326
332
|
if (selection.sentry) {
|
|
327
333
|
body.push(" await flushSentry();");
|
|
328
334
|
}
|
|
335
|
+
if (selection.otel) {
|
|
336
|
+
body.push(" await shutdownOpenTelemetry();");
|
|
337
|
+
}
|
|
329
338
|
|
|
330
339
|
body.push(
|
|
331
340
|
" process.exit(0);",
|
|
@@ -337,7 +346,11 @@ async function patchEntryIndex(projectDir: string, selection: FeatureSelection)
|
|
|
337
346
|
"",
|
|
338
347
|
);
|
|
339
348
|
|
|
340
|
-
|
|
349
|
+
return [...imports, ...body].join("\n");
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
async function patchEntryIndex(projectDir: string, selection: FeatureSelection) {
|
|
353
|
+
await writeText(projectDir, "src/index.ts", buildEntryIndex(selection));
|
|
341
354
|
}
|
|
342
355
|
|
|
343
356
|
async function patchServerIndex(projectDir: string, selection: FeatureSelection) {
|
|
@@ -523,7 +536,7 @@ function buildAppEnvironment(selection: FeatureSelection): string {
|
|
|
523
536
|
lines.push(" KAFKA_BROKERS: kafka:9092");
|
|
524
537
|
}
|
|
525
538
|
if (selection.otel) {
|
|
526
|
-
lines.push(" OTEL_EXPORTER_OTLP_ENDPOINT: http://
|
|
539
|
+
lines.push(" OTEL_EXPORTER_OTLP_ENDPOINT: http://otel:4318/v1/traces");
|
|
527
540
|
lines.push(" OTEL_SERVICE_NAME: ${OTEL_SERVICE_NAME:-kavoru}");
|
|
528
541
|
}
|
|
529
542
|
if (selection.sentry) {
|
|
@@ -568,15 +581,14 @@ function generateDockerCompose(selection: FeatureSelection): string {
|
|
|
568
581
|
`
|
|
569
582
|
: "";
|
|
570
583
|
|
|
571
|
-
const
|
|
584
|
+
const otelService = selection.otel
|
|
572
585
|
? `
|
|
573
|
-
|
|
574
|
-
|
|
586
|
+
otel:
|
|
587
|
+
build:
|
|
588
|
+
context: .
|
|
589
|
+
dockerfile: docker/otel.Dockerfile
|
|
575
590
|
ports:
|
|
576
|
-
- "16686:16686"
|
|
577
591
|
- "4318:4318"
|
|
578
|
-
environment:
|
|
579
|
-
COLLECTOR_OTLP_ENABLED: "true"
|
|
580
592
|
networks:
|
|
581
593
|
- app_network
|
|
582
594
|
restart: unless-stopped
|
|
@@ -622,7 +634,7 @@ ${appDependsOn}${appEnvironment} healthcheck:
|
|
|
622
634
|
timeout: 300s
|
|
623
635
|
retries: 1
|
|
624
636
|
start_period: 40s
|
|
625
|
-
${kafkaService}${
|
|
637
|
+
${kafkaService}${otelService}${spotlightService}
|
|
626
638
|
networks:
|
|
627
639
|
app_network:
|
|
628
640
|
driver: bridge
|