Skip to content

Commit b49348c

Browse files
committed
Add Instrumentation javadocs
1 parent 9bf3327 commit b49348c

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

java-client/src/main/java/co/elastic/clients/transport/instrumentation/Instrumentation.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,55 @@
2323
import co.elastic.clients.transport.TransportOptions;
2424
import co.elastic.clients.transport.http.TransportHttpClient;
2525

26+
/**
27+
* Instrumentation for an Elasticsearch client. It allows creating a {@link Instrumentation.Context} for each request,
28+
* with callbacks for the various stages of request and response processing.
29+
*/
2630
public interface Instrumentation {
2731

32+
/**
33+
* Create a context for a given request and the corresponding endpoint.
34+
*/
2835
<TRequest> Context newContext(TRequest request, Endpoint<TRequest, ?, ?> endpoint);
2936

37+
/**
38+
* A context with lifecycle callbacks for the various stages of request and response processing. Must be {@link #close()}d.
39+
*/
3040
interface Context extends AutoCloseable {
41+
42+
/**
43+
* Sets this context (or the underlying abstraction) as the current thread's scope, so that neste call can
44+
* nest child contexts.
45+
*/
3146
ThreadScope makeCurrent();
3247

48+
/**
49+
* Called once the initial API request has been serialized and the http request has been prepared.
50+
*/
3351
void beforeSendingHttpRequest(TransportHttpClient.Request httpRequest, TransportOptions options);
52+
53+
/**
54+
* Called after the http response has been received, and before analyzing it.
55+
*/
3456
void afterReceivingHttpResponse(TransportHttpClient.Response httpResponse);
57+
58+
/**
59+
* Called after the http response has been deserialized
60+
*/
3561
<TResponse> void afterDecodingApiResponse(TResponse apiResponse);
62+
63+
/**
64+
* Called when any stage of request processing caused a failure.
65+
*/
3666
void recordException(Throwable thr);
3767

3868
@Override
3969
void close();
4070
}
4171

72+
/**
73+
* A thread scope. Closing it will detach the scope from the current thread.
74+
*/
4275
interface ThreadScope extends AutoCloseable {
4376
@Override
4477
void close();

0 commit comments

Comments
 (0)