Skip to content

Commit fd69807

Browse files
committed
update README
1 parent 73b1459 commit fd69807

2 files changed

Lines changed: 40 additions & 1 deletion

File tree

README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,45 @@ public class DisableTLSExample {
153153
}
154154
```
155155

156+
#### Capturing response metadata for observability
157+
158+
The SDK supports capturing response metadata for all data plane operations (upsert, query, fetch, update, delete). This enables you to track latency metrics and integrate with observability tools like OpenTelemetry, Prometheus, or Datadog.
159+
160+
```java
161+
import io.pinecone.clients.Pinecone;
162+
import io.pinecone.clients.Index;
163+
164+
Pinecone pinecone = new Pinecone.Builder("PINECONE_API_KEY")
165+
.withResponseMetadataListener(metadata -> {
166+
System.out.printf("Operation: %s | Client: %dms | Server: %dms | Network: %dms%n",
167+
metadata.getOperationName(),
168+
metadata.getClientDurationMs(),
169+
metadata.getServerDurationMs(),
170+
metadata.getNetworkOverheadMs());
171+
})
172+
.build();
173+
174+
Index index = pinecone.getIndexConnection("example-index");
175+
index.query(5, Arrays.asList(1.0f, 2.0f, 3.0f));
176+
// Output: Operation: query | Client: 45ms | Server: 32ms | Network: 13ms
177+
```
178+
179+
The `ResponseMetadata` object provides:
180+
181+
| Method | Description |
182+
|--------|-------------|
183+
| `getOperationName()` | Operation type: upsert, query, fetch, update, delete |
184+
| `getClientDurationMs()` | Total round-trip time measured by the client |
185+
| `getServerDurationMs()` | Server processing time from `x-pinecone-response-duration-ms` header |
186+
| `getNetworkOverheadMs()` | Computed: client duration - server duration |
187+
| `getIndexName()` | Name of the index |
188+
| `getNamespace()` | Namespace used |
189+
| `isSuccess()` | Whether the operation succeeded |
190+
| `getGrpcStatusCode()` | gRPC status code |
191+
| `getErrorType()` | Error category when failed |
192+
193+
For a complete OpenTelemetry integration example with Prometheus and Grafana, see the [java-otel-metrics example](examples/java-otel-metrics/).
194+
156195
# Indexes
157196

158197
Operations related to the building and managing of Pinecone indexes are called [control plane](https://docs.pinecone.io/reference/api/introduction#control-plane) operations.

examples/java-otel-metrics/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<dependency>
2525
<groupId>io.pinecone</groupId>
2626
<artifactId>pinecone-client</artifactId>
27-
<version>6.0.0-rc</version>
27+
<version>6.1.0</version>
2828
</dependency>
2929

3030
<!-- OpenTelemetry SDK -->

0 commit comments

Comments
 (0)