-
Notifications
You must be signed in to change notification settings - Fork 227
added parsing of cgroups file #352
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
Conversation
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.
Code looks fine overall. Might be a bit neater using regular expressions?
I think it would be ideal if all agents aligned on the approach used for identifying container IDs. If you disagree with my approach, perhaps let's take it back to elastic/apm#21 to discuss?
e667280
to
99e00fd
Compare
} | ||
assert system_info["container"] == {"id": "123"} | ||
|
||
|
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.
Worth a test to ensure system hostname is used as pod name when kubernetes info is not detected but partially set by environ? Seems like overkill but figured I'd mention it to prove I reviewed this.
@mock.patch.dict(
"os.environ",
{
"KUBERNETES_NAMESPACE": "namespace",
},
)
def test_docker_kubernetes_system_info_except_hostname_from_environ():
# initialize agent only after overriding environment
elasticapm_client = Client()
# mock docker/kubernetes data here to get consistent behavior if test is run in docker
with mock.patch("elasticapm.utils.cgroup.get_cgroup_container_metadata") as mock_metadata, mock.patch(
"socket.gethostname"
) as mock_gethostname:
mock_metadata.return_value = {}
mock_gethostname.return_value = "foo"
system_info = elasticapm_client.get_system_info()
assert "kubernetes" in system_info
assert system_info["kubernetes"] == {
"pod": {"name": "foo"},
"namespace": "namespace",
}
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 would have been the ideal chance to use that new fancy review-as-commit thingy :D set you as author of the commit instead. Not that it makes a huge difference after I squash-merge this :D
due to the somewhat underdefined and volatile format of this file, the "parsing" got pretty spaghetti-code-y :(
environment variables take precedence over data from /proc/self/cgroup
also, account for larger payload in payload size check, due to added metadata
…pm-agent-go#342 (as in, pretty much copied from elastic/apm-agent-go#342)
5b52fe9
to
aa72770
Compare
due to the somewhat underdefined and volatile format of this file,
the "parsing" got pretty spaghetti-code-y :(
This implements #346 and #347