Collector Contrib v0.166.0 (24 November 2026) retries timeouts and most bulk errors by default. When that duplicates documents and how deterministic IDs help.
The change in v0.166.0
OpenTelemetry Collector Contrib v0.166.0 was released on 24 November 2026. One of its breaking changes is a single line in the release notes: the Elasticsearch exporter now defaults to at-least-once retries on transport errors, client timeouts, bulk HTTP statuses 400, 401, 403, 404, 409, 429, 500, 502, 503 and 504, and document statuses 429, 500, 502, 503 and 504. The notes add that HTTP client timeouts are always retried, that this cannot be configured or reverted, and that retry::retry_on_document_status no longer follows retry::retry_on_status.
In v0.165.0 the README described both lists as defaulting to [429], with the reason stated in the text: "To avoid duplicates". The v0.166.0 README states the new trade plainly: retrying an HTTP client timeout or a status 500, 502, 503 or 504 can index the same documents twice when the first _bulk request was applied and its response was lost.
So the upgrade changes what your log and trace indexes contain during incidents. This guide explains exactly when duplicates appear, how deterministic document IDs change the failure from duplicates into conflict reports, and how to restore the old behaviour where you need it.
What the exporter actually retries
Two layers matter.
The transport layer decides whether a failed HTTP exchange is retried at all. Comparing esclient.go between the two tags shows the change directly. In v0.165.0, retryOnError refused to retry a context.DeadlineExceeded unless it happened before the connection was established; a comment explains that such timeouts "are safe to retry without risking duplicates because no request body has been sent". In v0.166.0 the function is one line: retry everything except cancellation.
// v0.165.0
func retryOnError(_ *http.Request, err error) bool {
if errors.Is(err, context.Canceled) {
return false
}
if _, ok := errors.AsType[*connSetupTimeoutError](err); ok {
return true
}
return !errors.Is(err, context.DeadlineExceeded)
}
// v0.166.0
func retryOnError(_ *http.Request, err error) bool {
return !errors.Is(err, context.Canceled)
}The bulk layer then decides what to do with a response. retry_on_status lists statuses that retry the whole _bulk request. retry_on_document_status lists per-item statuses inside a successful bulk response that retry only those documents. max_retries defaults to 2 in both versions.
A timeout after the body was sent is the dangerous case. Elasticsearch may have applied every item before the response was lost. The exporter cannot tell, so in v0.166.0 it sends the whole bulk again.
What a retry stores
The exporter uses the create bulk action for log records, spans, span events and metrics; exporter.go at v0.166.0 passes docappender.ActionCreate on those paths (one profiling path uses update, which this guide does not cover). What a repeated create does depends on the document ID.
Without an ID, which is the default, Elasticsearch generates a new one for each item. A repeated request therefore stores every document a second time. With an explicit ID, a second create of an ID that exists is rejected for that item with a 409 version conflict, and the stored document is unchanged.
The companion example es_bulk_retry_model models both versions against a dictionary store that behaves like the create action. It is a model, not Elasticsearch. For a batch of five log records from a help-desk case stream, the recorded results are:
| Scenario | v0.165.0 defaults | v0.166.0 defaults |
|---|---|---|
| Response lost after apply, no IDs | 5 stored, all 5 reported failed (timeout) | 10 stored, 5 duplicates |
| Response lost after apply, deterministic IDs | 5 stored, all 5 reported failed (timeout) | 5 stored, five 409 reports |
| 503 before apply | 0 stored, 5 lost | 5 stored after one retry |
| Two items rejected with 429 | 5 stored after one document retry | the same |
| Malformed request (400) | fails after 1 attempt | fails after 3 attempts |
The first row is the headline: the old defaults reported data as failed even though it had landed, and the new defaults never lose it but may store it twice. The third row is what the new defaults buy: a node restart that returns 503 no longer drops the batch. The last row is a cost worth knowing: a 400 means the request is malformed, and retrying it twice only spends time; the same applies to 401 and 403 when credentials are wrong, although the README notes that the version check excludes those two.
Deterministic IDs make retries idempotent
If duplicates matter for an index, give each document an ID derived from the record itself. The exporter supports this through logs_dynamic_id and traces_dynamic_id: when enabled, a non-empty elasticsearch.document_id attribute on the log record or span becomes the document ID, and in the otel mapping mode the attribute is removed from the stored document. The README shows the pattern with the transform processor:
# Author: Sandeep Belgavi. Deterministic IDs for help-desk audit logs.
exporters:
elasticsearch:
endpoint: https://es.bookstore.test:9200
logs_dynamic_id:
enabled: true
processors:
transform/es-doc-id:
error_mode: ignore
log_statements:
- context: log
condition: attributes["case.id"] != nil && attributes["event.sequence"] != nil
statements:
- set(attributes["elasticsearch.document_id"], Concat([attributes["case.id"], attributes["event.sequence"]], "-"))The statement layout follows the example in the exporter README; records without both attributes keep a generated ID.
For spans, the README uses the trace ID and span ID joined together, which is unique by construction.
The ID must identify the record, not the delivery. A timestamp alone collides for two events in the same millisecond; a UUID generated by the collector on each attempt defeats the purpose, because the retry gets a new UUID. Good candidates are fields the producer already sets once: a case number with a per-case sequence, an event ID from the source system, or trace and span IDs.
With deterministic IDs, a retried bulk turns duplicates into 409 items. 409 is not in the default retry_on_document_status, so those items are not retried, which is correct. They are still treated as failed documents: bulkindexer.go at v0.166.0 counts each one in the processed-documents telemetry with a client-failure outcome and the error type version_conflict_engine_exception, and logs it as "failed to index document" unless suppress_conflict_errors is set to true in the exporter configuration. Expect a burst of these after timeouts and do not page on them blindly; a 409 for an ID you just sent means the first attempt already worked. Alert on the other error types instead.
Restoring the old behaviour
The release notes give the exact settings. To keep the previous default codes, set both lists to [429]:
exporters:
elasticsearch:
retry:
retry_on_status: [429]
retry_on_document_status: [429]If you had set retry_on_status and not retry_on_document_status, the document list no longer follows the request list, so set it to the same values explicitly. Note what this does not restore: client timeouts are retried regardless, so even with both lists set to [429] a timeout after the body was sent can still produce a duplicate on v0.166.0. Only deterministic IDs prevent that.
Choosing per pipeline
Different signals deserve different answers.
- Debug and application logs where a rare duplicate is harmless: accept the new defaults. They lose less data during node restarts and overload.
- Audit logs and anything counted, such as approval decisions in a help-desk agent's trail or refunds issued: use deterministic IDs. Counting duplicates is worse than counting 409s, and a reviewer reading an audit trail should not see the same approval twice.
- Traces: span IDs are unique, so
traces_dynamic_idwith trace and span IDs is cheap and removes duplicate spans from retried batches. - Metrics: a duplicated data point distorts sums and counts. I did not test the metrics path for this guide, so run the fault test below on a metrics pipeline before relying on the log advice.
Verifying after the upgrade
Measure instead of assuming. Count documents per source record before and after a fault: for a test index, send a known set of records, kill the Elasticsearch node or inject a delay longer than the client timeout during a bulk, and compare stored counts with sent counts. Watch the exporter's retried-document and failed-document telemetry during the test; a retry followed by 409s is the signature of the idempotent path working. Finally, check the collector's own logs for 400s that are now retried, since they point to a mapping or pipeline problem that retries will not fix.
Limits of this guide
The defaults, settings and code excerpts come from the v0.166.0 release notes, the exporter README at v0.165.0 and v0.166.0, and esclient.go, bulkindexer.go and exporter.go at those tags. The table comes from the companion model, not from an Elasticsearch cluster. Data streams, routing, ingest pipelines and the failure store can change what a given request stores; run the fault test against your own mapping before relying on the numbers.