blob: 15f6c3a5cd978c4f5af258a3308f5846f33e6189 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.docproc.jdisc.observability;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.yahoo.component.provider.ComponentRegistry;
import com.yahoo.container.handler.observability.ApplicationStatusHandler;
import com.yahoo.docproc.Call;
import com.yahoo.docproc.impl.DocprocService;
import com.yahoo.docproc.jdisc.DocumentProcessingHandler;
import com.yahoo.jdisc.handler.RequestHandler;
import java.util.Iterator;
import java.util.Map;
/**
* @author bjorncs
*/
public class DocprocsStatusExtension implements ApplicationStatusHandler.Extension {
@Override
public Map<String, ? extends JsonNode> produceExtraFields(ApplicationStatusHandler statusHandler) {
return Map.of("docprocChains", renderDocprocChains(statusHandler));
}
private static JsonNode renderDocprocChains(ApplicationStatusHandler statusHandler) {
ObjectNode ret = statusHandler.jsonMapper().createObjectNode();
for (RequestHandler h : statusHandler.requestHandlers()) {
if (h instanceof DocumentProcessingHandler) {
ComponentRegistry<DocprocService> registry = ((DocumentProcessingHandler) h).getDocprocServiceRegistry();
for (DocprocService service : registry.allComponents()) {
ret.set(service.getId().stringValue(), renderCalls(statusHandler, service.getCallStack().iterator()));
}
}
}
return ret;
}
private static JsonNode renderCalls(ApplicationStatusHandler statusHandler, Iterator<Call> components) {
ArrayNode ret = statusHandler.jsonMapper().createArrayNode();
while (components.hasNext()) {
Call c = components.next();
JsonNode jc = ApplicationStatusHandler.renderComponent(c.getDocumentProcessor(), c.getDocumentProcessor().getId());
ret.add(jc);
}
return ret;
}
}
|