blob: e838987133ff0ecb25bf16d7a7492a9e7a95ac3b (
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
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package ai.vespa.metricsproxy.http.yamas;
import ai.vespa.metricsproxy.metric.model.MetricsPacket;
import ai.vespa.metricsproxy.metric.model.json.YamasJsonUtil;
import com.yahoo.container.jdisc.HttpResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
/**
* @author olaa
*/
public class YamasResponse extends HttpResponse {
private final List<MetricsPacket> metrics;
private boolean useJsonl;
public YamasResponse(int code, List<MetricsPacket> metrics, boolean useJsonl) {
super(code);
this.metrics = metrics;
this.useJsonl = useJsonl;
}
@Override
public String getContentType() {
return "application/json";
}
@Override
public void render(OutputStream outputStream) throws IOException {
if (useJsonl)
YamasJsonUtil.toJsonl(metrics, outputStream, false);
else
YamasJsonUtil.toJson(metrics, outputStream, false);
}
}
|