feat(server): export log records over OTLP (#12493)
Signed-off-by: Yordis Prieto <[email protected]>
This commit is contained in:
1 parent
82cd1d1aab
commit
3bb06ad910
25 files changed
+503
-26
No files matched your search
@@ -50,6 +50,7 @@ it.layer(NodeServices.layer)("cli config resolution", (it) => {
|
||||
traceMaxFiles: 10,
|
||||
otlpTracesUrl: undefined,
|
||||
otlpMetricsUrl: undefined,
|
||||
otlpLogsUrl: undefined,
|
||||
otlpExportIntervalMs: 10_000,
|
||||
otlpServiceName: "t3-server",
|
||||
otlpHeaders: undefined,
|
||||
@@ -398,6 +399,7 @@ it.layer(NodeServices.layer)("cli config resolution", (it) => {
|
||||
tailscaleServePort: 443,
|
||||
otlpTracesUrl: "http://localhost:4318/v1/traces",
|
||||
otlpMetricsUrl: "http://localhost:4318/v1/metrics",
|
||||
otlpLogsUrl: "http://localhost:4318/v1/logs",
|
||||
}),
|
||||
);
|
||||
const derivedPaths = yield* deriveServerPaths(baseDir, undefined);
|
||||
@@ -438,6 +440,7 @@ it.layer(NodeServices.layer)("cli config resolution", (it) => {
|
||||
...defaultObservabilityConfig,
|
||||
otlpTracesUrl: "http://localhost:4318/v1/traces",
|
||||
otlpMetricsUrl: "http://localhost:4318/v1/metrics",
|
||||
otlpLogsUrl: "http://localhost:4318/v1/logs",
|
||||
mode: "desktop",
|
||||
port: 4888,
|
||||
cwd: process.cwd(),
|
||||
@@ -604,6 +607,7 @@ it.layer(NodeServices.layer)("cli config resolution", (it) => {
|
||||
observability: {
|
||||
otlpTracesUrl: "http://localhost:4318/v1/traces",
|
||||
otlpMetricsUrl: "http://localhost:4318/v1/metrics",
|
||||
otlpLogsUrl: "http://localhost:4318/v1/logs",
|
||||
},
|
||||
})}\n`,
|
||||
);
|
||||
@@ -635,11 +639,13 @@ it.layer(NodeServices.layer)("cli config resolution", (it) => {
|
||||
|
||||
expect(resolved.otlpTracesUrl).toBe("http://localhost:4318/v1/traces");
|
||||
expect(resolved.otlpMetricsUrl).toBe("http://localhost:4318/v1/metrics");
|
||||
expect(resolved.otlpLogsUrl).toBe("http://localhost:4318/v1/logs");
|
||||
expect(resolved).toEqual({
|
||||
logLevel: "Info",
|
||||
...defaultObservabilityConfig,
|
||||
otlpTracesUrl: "http://localhost:4318/v1/traces",
|
||||
otlpMetricsUrl: "http://localhost:4318/v1/metrics",
|
||||
otlpLogsUrl: "http://localhost:4318/v1/logs",
|
||||
mode: "desktop",
|
||||
port: 4888,
|
||||
cwd: process.cwd(),
|
||||
@@ -845,4 +851,42 @@ it.layer(NodeServices.layer)("cli config resolution", (it) => {
|
||||
expect(resolved.otlpProtocol).toBe("http/protobuf");
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("reads the OTLP logs URL from env", () =>
|
||||
Effect.gen(function* () {
|
||||
const { join } = yield* Path.Path;
|
||||
const baseDir = join(NodeOS.tmpdir(), "t3-cli-config-otlp-logs-url-base");
|
||||
|
||||
const resolved = yield* resolveServerConfig(
|
||||
{
|
||||
mode: Option.some("web"),
|
||||
port: Option.some(3773),
|
||||
host: Option.none(),
|
||||
baseDir: Option.some(baseDir),
|
||||
cwd: Option.none(),
|
||||
devUrl: Option.none(),
|
||||
noBrowser: Option.none(),
|
||||
bootstrapFd: Option.none(),
|
||||
autoBootstrapProjectFromCwd: Option.none(),
|
||||
logWebSocketEvents: Option.none(),
|
||||
tailscaleServeEnabled: Option.none(),
|
||||
tailscaleServePort: Option.none(),
|
||||
},
|
||||
Option.none(),
|
||||
).pipe(
|
||||
Effect.provide(
|
||||
Layer.mergeAll(
|
||||
ConfigProvider.layer(
|
||||
ConfigProvider.fromEnv({
|
||||
env: { T3CODE_OTLP_LOGS_URL: "http://collector.internal:4318/v1/logs" },
|
||||
}),
|
||||
),
|
||||
NetService.layer,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(resolved.otlpLogsUrl).toBe("http://collector.internal:4318/v1/logs");
|
||||
}),
|
||||
);
|
||||
});
|
||||
@@ -96,6 +96,10 @@ const EnvServerConfig = Config.all({
|
||||
Config.option,
|
||||
Config.map(Option.getOrUndefined),
|
||||
),
|
||||
otlpLogsUrl: Config.String("T3CODE_OTLP_LOGS_URL").pipe(
|
||||
Config.option,
|
||||
Config.map(Option.getOrUndefined),
|
||||
),
|
||||
otlpExportIntervalMs: Config.Int("T3CODE_OTLP_EXPORT_INTERVAL_MS").pipe(
|
||||
Config.withDefault(10_000),
|
||||
),
|
||||
@@ -227,7 +231,7 @@ const loadPersistedObservabilitySettings = Effect.fn(function* (settingsPath: st
|
||||
const fs = yield* FileSystem.FileSystem;
|
||||
const exists = yield* fs.exists(settingsPath).pipe(Effect.orElseSucceed(() => false));
|
||||
if (!exists) {
|
||||
return { otlpTracesUrl: undefined, otlpMetricsUrl: undefined };
|
||||
return { otlpTracesUrl: undefined, otlpMetricsUrl: undefined, otlpLogsUrl: undefined };
|
||||
}
|
||||
|
||||
const raw = yield* fs.readFileString(settingsPath).pipe(Effect.orElseSucceed(() => ""));
|
||||
@@ -393,6 +397,8 @@ export const resolveServerConfig = (
|
||||
env.otlpMetricsUrl ??
|
||||
bootstrap?.otlpMetricsUrl ??
|
||||
persistedObservabilitySettings.otlpMetricsUrl,
|
||||
otlpLogsUrl:
|
||||
env.otlpLogsUrl ?? bootstrap?.otlpLogsUrl ?? persistedObservabilitySettings.otlpLogsUrl,
|
||||
otlpExportIntervalMs: env.otlpExportIntervalMs,
|
||||
otlpServiceName: env.otlpServiceName,
|
||||
otlpHeaders: env.otlpHeaders,
|
||||
|
||||
@@ -320,6 +320,7 @@ const makePairServerConfig = Effect.fn(function* (input: {
|
||||
traceMaxFiles: 10,
|
||||
otlpTracesUrl: undefined,
|
||||
otlpMetricsUrl: undefined,
|
||||
otlpLogsUrl: undefined,
|
||||
otlpExportIntervalMs: 10_000,
|
||||
otlpServiceName: "t3-server",
|
||||
otlpHeaders: undefined,
|
||||
|
||||
Reference in new issue
Block a user