Repository navigation
Commit c0dd224
committed
[BUG] Stop the Elasticsearch async ForceFlush reporting success without waiting
ForceFlush() returned true straight away when async export was enabled, so a
caller had no way to know whether anything had been delivered.
It now waits on the sessions that were in flight when it was called. Sessions
are identified rather than counted: each export takes the next id and joins a
set, and the wait ends when no id below the entry watermark is left, so a
completion cannot satisfy a flush that started after it. Counting alone lets a
later export stand in for an earlier one. The wait uses one deadline for the
call, so a wakeup that is not a completion resumes against what is left instead
of restarting the wait, and the result is the predicate rather than the leftover
duration.
The ids are uint64_t rather than size_t. The wait compares them by order, which
only holds while they keep increasing, and a 32 bit counter reaches its end in
days at a rate this exporter is meant to sustain; past that the next watermark
is small enough for a still running session to satisfy it.
AsyncResponseHandler reports at most once, through a compare and exchange. The
HTTP client can deliver both a response and a terminal session event for one
request, and the exporter counts one finished session per export.
An export registers its session before anything that can return, so a flush
asked from the moment the records arrive waits for them, and a guard reports
through the same completion on every early exit. Without it a return added later
would strand a waiter on a session that can never finish.
What a true return means is documented on the declaration, and it is weaker than
"the session ended". Both completion paths publish the outcome before the
session is torn down: OnResponse calls CompleteOnce() ahead of its logging, and
the handler destructor calls it ahead of FinishSession(). So a true return means
every snapshotted export has reported an outcome, and transport cleanup may
still be running.
Reported in #4336
Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>1 parent 5af96de commit c0dd224
5 files changed
Lines changed: 1083 additions & 94 deletions
File tree
- exporters/elasticsearch
- include/opentelemetry/exporters/elasticsearch
- src
- test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
59 | 62 | | |
60 | 63 | | |
61 | 64 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
58 | 64 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
122 | 123 | | |
123 | 124 | | |
124 | 125 | | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
125 | 130 | | |
126 | | - | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
127 | 136 | | |
128 | 137 | | |
129 | 138 | | |
| |||
149 | 158 | | |
150 | 159 | | |
151 | 160 | | |
152 | | - | |
153 | | - | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
154 | 170 | | |
155 | 171 | | |
156 | | - | |
157 | 172 | | |
158 | 173 | | |
159 | 174 | | |
| |||
0 commit comments