You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- guides/metrics.md: fix nonexistent opensearchtransport.WithObserver()
reference; describe Observer field on opensearch.Config instead
- guides/metrics.md: hoist safeFloat helper out of for-loop body so the
polling example is parseable Go
- guides/metrics.md: align aggregate tables to Field (Go name) + JSON
(tag) layout matching ConnectionMetric/PolicySnapshot/RouterSnapshot
- guides/error_handling.md, v5preview/opensearchapi/README.md: drop
*PartialBulkError and *ShardFailureError from MSearch switch examples
(MSearch never returns them); fix the duplicate pre-existing example
in v5preview README
- guides/error_handling.md: qualify "folded into err" claim with the
v4-vs-v5preview default-mask caveat
- CHANGELOG.md: rewrite "prefer for/switch pattern over Errors(err)"
bullet to recommend the pattern over per-Resp helpers, not over
Errors(err)
Signed-off-by: Sean Chittenden <sean.chittenden@crowdstrike.com>
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -102,7 +102,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
102
102
-`opensearchapi.Errors(err) []error` package-level helper that flattens single- and multi-wrapper errors into a uniform slice; recommended call-site pattern is a `for`/`switch` over the result (not `errors.As` against a specific type)
103
103
- Helper functions: `IsPartialFailure`, `ToleratePartialFailures`, `RequireSuccessRate` for threshold-based error tolerance
- Per-Resp helper methods (`BulkItemFailures`, `SearchShardFailures`, `WriteShardFailures`, `MultiSearchItemFailures`, `PartialFailures(mask)`) exist on the response types as engine machinery for the dispatch; new code should prefer the`for`/`switch`pattern over `opensearchapi.Errors(err)` for forward compatibility
105
+
- Per-Resp helper methods (`BulkItemFailures`, `SearchShardFailures`, `WriteShardFailures`, `MultiSearchItemFailures`, `PartialFailures(mask)`) exist on the response types as engine machinery for the dispatch; new code should prefer a`for`/`switch` over `opensearchapi.Errors(err)` rather than the per-Resp helpers, for forward compatibility
106
106
-`Config.Errors *errmask.ErrorMask` replaces a single boolean: each bit suppresses one wrapper category. v4 defaults to `errmask.All` (mask everything, preserves pre-bitfield behavior); v5+ defaults to `errmask.Empty` (report everything)
107
107
-`OPENSEARCH_GO_ERROR_MASK` environment variable overrides `Config.Errors` at runtime via comma-separated `+`/`-` tokens (lowercase snake_case wrapper names; unknown tokens silently dropped, debug-logged)
108
108
- Both `(resp, error)` are non-nil on partial failure -- response is fully populated
// resp is fully populated; partial failures (if any) are folded into err.
222
+
// resp is fully populated; partial failures (if any) are folded into err
223
+
// when the wrapper bits are unmasked (the v5preview default, or v4 with
224
+
// Config.Errors: errmask.New()).
223
225
```
224
226
225
227
**Inspect categories with a `for`/`switch`** -- when partial error handling is appropriate. Partial error handling lets the client and its application recover from known failure modes they can tolerate (e.g. continue serving a search with a few failed shards, or retry only the bulk items the server rejected) instead of failing the whole operation. The `default` arm catches transport / HTTP / decode errors and any partial-failure category added in a future release:
|`HealthChecks`|`health_checks`|`int`| Baseline `GET /` health checks performed |
67
+
|`ClusterHealthChecks`|`cluster_health_checks`|`int`|`GET /_cluster/health?local=true` checks performed |
68
+
|`HealthChecksSuccess`|`health_checks_success`|`int`| Successful health check outcomes |
69
+
|`HealthChecksFailed`|`health_checks_failed`|`int`| Failed health check outcomes |
70
70
71
71
---
72
72
@@ -169,6 +169,13 @@ Each index with an active routing slot produces an entry in `Router.Indexes`.
169
169
Poll metrics on a timer for logging or export to an external monitoring system.
170
170
171
171
```go
172
+
funcsafeFloat(f *float64) float64 {
173
+
if f == nil {
174
+
return0
175
+
}
176
+
return *f
177
+
}
178
+
172
179
ticker:= time.NewTicker(30 * time.Second)
173
180
defer ticker.Stop()
174
181
@@ -207,13 +214,6 @@ for range ticker.C {
207
214
}
208
215
}
209
216
}
210
-
211
-
funcsafeFloat(f *float64) float64 {
212
-
if f == nil {
213
-
return0
214
-
}
215
-
return *f
216
-
}
217
217
```
218
218
219
219
## JSON Export
@@ -249,6 +249,6 @@ The metrics API is pull-based: call `client.Metrics()` inside your collector's `
249
249
250
250
## Observer API
251
251
252
-
For event-driven observability (as opposed to polling), implement the `ConnectionObserver` interface and pass it via `opensearchtransport.WithObserver()`. The observer receives callbacks for connection lifecycle events (promote, demote, overload), routing decisions, health checks, and shard map invalidations. See the [routing guide](routing.md) for details on observer events.
252
+
For event-driven observability (as opposed to polling), implement the `opensearchtransport.ConnectionObserver` interface and set it on the `Observer` field of `opensearch.Config`. The observer receives callbacks for connection lifecycle events (promote, demote, overload), routing decisions, health checks, and shard map invalidations. See the [routing guide](routing.md) for details on observer events.
253
253
254
254
The metrics API and observer API are complementary: metrics give you aggregate snapshots for dashboards, while the observer gives you per-event detail for tracing and debugging.
0 commit comments