Skip to content

Commit

Permalink
More tracing
Browse files Browse the repository at this point in the history
  • Loading branch information
danielmitterdorfer committed Feb 1, 2024
1 parent 0826060 commit 3bede77
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ public Iterator<? extends ToXContent> toXContentChunked(ToXContent.Params params
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject();
traceStart("Edges");
builder.startArray("Edges");
for (Map<String, Integer> edge : edges) {
builder.startArray();
Expand All @@ -250,26 +251,67 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
builder.endArray();
}
builder.endArray();
traceStop("Edges");
traceStart("FileID");
builder.field("FileID", fileIds);
traceStop("FileID");
traceStart("FrameType");
builder.field("FrameType", frameTypes);
traceStop("FrameType");
traceStart("Inline");
builder.field("Inline", inlineFrames);
traceStop("Inline");
traceStart("ExeFilename");
builder.field("ExeFilename", fileNames);
traceStop("ExeFilename");
traceStart("AddressOrLine");
builder.field("AddressOrLine", addressOrLines);
traceStop("AddressOrLine");
traceStart("FunctionName");
builder.field("FunctionName", functionNames);
traceStop("FunctionName");
traceStart("FunctionOffset");
builder.field("FunctionOffset", functionOffsets);
traceStop("FunctionOffset");
traceStart("SourceFilename");
builder.field("SourceFilename", sourceFileNames);
traceStop("SourceFilename");
traceStart("SourceLine");
builder.field("SourceLine", sourceLines);
traceStop("SourceLine");
traceStart("CountInclusive");
builder.field("CountInclusive", countInclusive);
traceStop("CountInclusive");
traceStart("CountExclusive");
builder.field("CountExclusive", countExclusive);
traceStop("CountExclusive");
traceStart("AnnualCO2TonsInclusive");
builder.field("AnnualCO2TonsInclusive", annualCO2TonsInclusive);
traceStop("AnnualCO2TonsInclusive");
traceStart("AnnualCO2TonsExclusive");
builder.field("AnnualCO2TonsExclusive", annualCO2TonsExclusive);
traceStop("AnnualCO2TonsExclusive");
traceStart("AnnualCostsUSDInclusive");
builder.field("AnnualCostsUSDInclusive", annualCostsUSDInclusive);
traceStop("AnnualCostsUSDInclusive");
traceStart("AnnualCostsUSDExclusive");
builder.field("AnnualCostsUSDExclusive", annualCostsUSDExclusive);
traceStop("AnnualCostsUSDExclusive");
traceStart("Size");
builder.field("Size", size);
traceStop("Size");
traceStart("SamplingRate");
builder.field("SamplingRate", samplingRate);
traceStop("SamplingRate");
traceStart("SelfCPU");
builder.field("SelfCPU", selfCPU);
traceStop("SelfCPU");
traceStart("TotalCPU");
builder.field("TotalCPU", totalCPU);
traceStop("TotalCPU");
traceStart("TotalSamples");
builder.field("TotalSamples", totalSamples);
traceStop("TotalSamples");

builder.endObject();
return builder;
Expand Down Expand Up @@ -345,4 +387,12 @@ public ToXContent next() {
}
};
}

private static void traceStart(String name) {
TraceLogger.start(null, "toXContent[" + name + "]");
}

private static void traceStop(String name) {
TraceLogger.stop(null, "toXContent[" + name + "]");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.elasticsearch.client.internal.node.NodeClient;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.tasks.Task;
import org.elasticsearch.telemetry.tracing.TraceLogger;
import org.elasticsearch.transport.TransportService;

import java.util.ArrayList;
Expand Down Expand Up @@ -65,6 +66,7 @@ public void onFailure(Exception e) {
}

static GetFlamegraphResponse buildFlamegraph(GetStackTracesResponse response) {
TraceLogger.start(null, "buildFlamegraph");
FlamegraphBuilder builder = new FlamegraphBuilder(
response.getTotalSamples(),
response.getTotalFrames(),
Expand Down Expand Up @@ -137,6 +139,7 @@ static GetFlamegraphResponse buildFlamegraph(GetStackTracesResponse response) {
});
}
}
TraceLogger.stop(null, "buildFlamegraph");
return builder.build();
}

Expand Down

0 comments on commit 3bede77

Please sign in to comment.