-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prototype sending allocation stacks as pprof #684
Conversation
profiler/src/main/java/com/splunk/opentelemetry/profiler/JfrActivator.java
Show resolved
Hide resolved
...main/java/com/splunk/opentelemetry/profiler/allocation/exporter/AllocationEventExporter.java
Show resolved
Hide resolved
.../com/splunk/opentelemetry/profiler/allocation/exporter/PlainTextAllocationEventExporter.java
Outdated
Show resolved
Hide resolved
...java/com/splunk/opentelemetry/profiler/allocation/exporter/PprofAllocationEventExporter.java
Outdated
Show resolved
Hide resolved
...java/com/splunk/opentelemetry/profiler/allocation/exporter/PprofAllocationEventExporter.java
Show resolved
Hide resolved
...java/com/splunk/opentelemetry/profiler/allocation/exporter/PprofAllocationEventExporter.java
Outdated
Show resolved
Hide resolved
...java/com/splunk/opentelemetry/profiler/allocation/exporter/PprofAllocationEventExporter.java
Show resolved
Hide resolved
...java/com/splunk/opentelemetry/profiler/allocation/exporter/PprofAllocationEventExporter.java
Outdated
Show resolved
Hide resolved
...java/com/splunk/opentelemetry/profiler/allocation/exporter/PprofAllocationEventExporter.java
Outdated
Show resolved
Hide resolved
...java/com/splunk/opentelemetry/profiler/allocation/exporter/PprofAllocationEventExporter.java
Outdated
Show resolved
Hide resolved
...java/com/splunk/opentelemetry/profiler/allocation/exporter/PprofAllocationEventExporter.java
Outdated
Show resolved
Hide resolved
...java/com/splunk/opentelemetry/profiler/allocation/exporter/PprofAllocationEventExporter.java
Outdated
Show resolved
Hide resolved
profiler/src/main/java/com/splunk/opentelemetry/profiler/Configuration.java
Outdated
Show resolved
Hide resolved
profiler/src/main/java/com/splunk/opentelemetry/profiler/JfrActivator.java
Show resolved
Hide resolved
...java/com/splunk/opentelemetry/profiler/allocation/exporter/PprofAllocationEventExporter.java
Show resolved
Hide resolved
...java/com/splunk/opentelemetry/profiler/allocation/exporter/PprofAllocationEventExporter.java
Show resolved
Hide resolved
...java/com/splunk/opentelemetry/profiler/allocation/exporter/PprofAllocationEventExporter.java
Outdated
Show resolved
Hide resolved
...java/com/splunk/opentelemetry/profiler/allocation/exporter/PprofAllocationEventExporter.java
Outdated
Show resolved
Hide resolved
...er/src/main/java/com/splunk/opentelemetry/profiler/exporter/PprofProfilingEventExporter.java
Outdated
Show resolved
Hide resolved
pprof.getProfileBuilder().addSample(sample); | ||
} | ||
|
||
private static StackTrace handleStackTrace(String stackTrace) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @vovencij please 👀
...er/src/main/java/com/splunk/opentelemetry/profiler/exporter/PprofProfilingEventExporter.java
Outdated
Show resolved
Hide resolved
...er/src/main/java/com/splunk/opentelemetry/profiler/exporter/PprofProfilingEventExporter.java
Outdated
Show resolved
Hide resolved
...java/com/splunk/opentelemetry/profiler/allocation/exporter/PprofAllocationEventExporter.java
Outdated
Show resolved
Hide resolved
profiler/src/main/java/com/splunk/opentelemetry/profiler/ProfilingDataType.java
Outdated
Show resolved
Hide resolved
profiler/src/main/java/com/splunk/opentelemetry/profiler/Configuration.java
Outdated
Show resolved
Hide resolved
...java/com/splunk/opentelemetry/profiler/allocation/exporter/PprofAllocationEventExporter.java
Outdated
Show resolved
Hide resolved
profiler/src/main/java/com/splunk/opentelemetry/profiler/Configuration.java
Show resolved
Hide resolved
private static LogProcessor INSTANCE; | ||
|
||
static LogProcessor get(LogExporter logsExporter) { | ||
if (INSTANCE == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: you can make it final
and initialize it in a static block, there's no need for the null-check here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea behind this is to initialize BatchingLogsProcessor
only if it is needed. And if it is needed only create one copy of it. BatchingLogsProcessor
is not used by the pprof exporters. I'll add a comment.
this.eventPeriods = builder.eventPeriods; | ||
this.pprofLogDataExporter = | ||
new PprofLogDataExporter( | ||
builder.logProcessor, builder.resource, ProfilingDataType.CPU, builder.dataFormat); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only possible value for dataFormat
is PPROF_GZIP_BASE64
- does it make sense to pass it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is because initially we had more formats. I'd keep it in case we need to experiment with different format, it would be nice if we could get rid of the base64.
profiler/src/main/java/com/splunk/opentelemetry/profiler/exporter/PprofLogDataExporter.java
Outdated
Show resolved
Hide resolved
|
||
public static StackTrace parse(String stackTrace) { | ||
// \\R - Any Unicode linebreak sequence | ||
String[] lines = stackTrace.split("\\R"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's an idea for improvement (not this PR though): we could parse the stack trace without this split, just using the start/end indexes, and save some memory
profiler/src/main/java/com/splunk/opentelemetry/profiler/exporter/StackTraceParser.java
Outdated
Show resolved
Hide resolved
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class StackTraceParserTest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this class would benefit from more extensive unit test - since it contains a ton of parsing logic. Currently there are no assertions for stack trace lines, and most of the other properties just get the "not null" treatment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added assertions for stack trace lines. Test data contains multiple stack traces, test verifies actual values for only one stack trace, for the rest it just tests for not null.
String result = "\"" + name + "\"" + " #" + id; | ||
if (thread != null) { | ||
result += " nid=0x" + Long.toHexString(thread.getOSThreadId()); | ||
} | ||
result += "\n"; | ||
result += " java.lang.Thread.State: UNKNOWN\n" + stack; | ||
return result; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about using a StringBuilder
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would leave it as it is because StringBuilder
reduces the readability. Also the plan is to use pprof
exporter by default so this class really won't be used by anything else besides our tests if all goes as planned. Perhaps we can even delete it at some point.
c842cd9
to
3fc1470
Compare
@gsmirnov-splk @vovencij please review