Repository navigation
Description
What version of Effect is running?
4.1.3 (same code on main at f12fefb, 4.1.4)
What steps can reproduce the bug?
When an export fails, OtlpExporter drops the batch, clears the buffer, disables itself for 60 s and logs one Debug line (OtlpExporter.ts#L241-L246). While disabled, push discards every record. At the default log level nothing is printed, so the loss is invisible.
npm i [email protected], save as repro.mjs, run node repro.mjs:
import { Effect, Layer } from "effect"
import { HttpClient, HttpClientResponse } from "effect/http"
import { OtlpLogger, OtlpSerialization } from "effect/observability"
let requests = 0
// A collector that rejects the first batch and would accept every later one.
const client = HttpClient.make((request) =>
Effect.sync(() => HttpClientResponse.fromWeb(request, new Response(null, { status: requests++ === 0 ? 400 : 200 })))
)
const exporter = OtlpLogger.layer({
url: "http://localhost:4318/v1/logs",
resource: { serviceName: "repro" },
exportInterval: "100 millis"
}).pipe(
Layer.provide(OtlpSerialization.layerJson),
Layer.provide(Layer.succeed(HttpClient.HttpClient, client))
)
const program = Effect.gen(function*() {
yield* Effect.logInfo("first") // exported, answered 400
yield* Effect.sleep("1 second")
for (let i = 0; i < 5; i++) {
yield* Effect.logInfo(`later ${i}`) // never exported
yield* Effect.sleep("300 millis")
}
console.log("export requests:", requests)
})
Effect.runPromise(program.pipe(Effect.provide(exporter)))What is the expected behavior?
A program running at the default log level is told that telemetry is being discarded, for example a Warning when the exporter disables itself. It already logs once per 60 s window, so this would not be noisy.
What do you see instead?
[11:25:05.576] INFO (#1): first
[11:25:06.579] INFO (#1): later 0
[11:25:06.881] INFO (#1): later 1
[11:25:07.181] INFO (#1): later 2
[11:25:07.482] INFO (#1): later 3
[11:25:07.783] INFO (#1): later 4
export requests: 1
One request, five records never sent, and no sign of either.
Additional information
- Applies to
OtlpLogger,OtlpTracerandOtlpMetrics, which share this exporter. Transport errors and 408/429/500/502/503/504 get there after 3 retries; any other non-2xx, or abodythat throws, at once. - For
OtlpLoggerthe Debug line can never reach the logs backend, because the exporter that would carry it is the one that is disabled. That also means a Warning cannot loop. - Raising the level does not always help. With
Layer.merge(exporter, Layer.succeed(References.MinimumLogLevel, "Debug"))the line is still not printed; it only appears when the level is in the context the exporter layer is built in. - How we hit it: on self-hosted servers exporting over OTLP, a counter kept rising in our tracing backend while the log lines written by the same code path were missing for minutes at a time, with no error on either side. The gaps fit this path, but we could not confirm it, because nothing records a dropped export.
I can send a PR for the log level. Investigated with an AI coding agent (Claude Code); the repro above was run on 4.1.3.
Activity