Allow Linux process command names longer than 15 chars #2062
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently,
ProcessSampledata on Linux hosts has a 15 character limit on thecommandNamevalue.This is a limitation of the kernel - the
commvalue read from/proc/<pid>/statis limited toTASK_COMM_LEN(16, including null byte).This isn't the end of the world when collecting all processes, but causes issues when trying to limit the collected samples via
include_matching_metrics. You can't currently matchsome-long-process-name-1without using a wildcard to cover everything after the 15th character. Ifsome-long-process-name-2is also running, both of these will be sampled.I've updated the
pw.Command()method (snapshot_linux.go) to handle this.If the process name (from
/proc/<pid>/stat) is less than 15 chars, then we return that.If it's 15, it could be truncated, so we use
pw.process.Exe()to read the link at/proc/<pid>/exe, returning the base name.This requires read permissions on the linked executable, so if the agent isn't running as root, the (possibly truncated) value is returned.
Comparison in events in

ProcessSample- Top: patched, bottom: 1.30.0