-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
[resourcedetectionprocessor] Add docker detector #2775
[resourcedetectionprocessor] Add docker detector #2775
Conversation
Codecov Report
@@ Coverage Diff @@
## main #2775 +/- ##
==========================================
- Coverage 91.61% 91.56% -0.05%
==========================================
Files 486 488 +2
Lines 23540 23568 +28
==========================================
+ Hits 21565 21581 +16
- Misses 1465 1473 +8
- Partials 510 514 +4
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
This PR was marked stale due to lack of activity. It will be closed in 7 days. |
@kbrockhoff can you take a look? Happy to try to improve test coverage after I have a review on the overall idea |
This PR was marked stale due to lack of activity. It will be closed in 7 days. |
@kbrockhoff Friendly ping! Also @anuraaga @jrcamp I would be happy if you took a look :) |
@jrcamp please review :) |
@@ -17,6 +17,8 @@ details of which are currently pending confirmation in the OpenTelemetry specifi | |||
* host.name | |||
* os.type | |||
|
|||
If running the Collector Docker image, mount `/var/run/docker.sock` and set the `use_docker_sock` flag to `true` to retrieve the attributes from the host machine. Docker detection does not work on macOS. |
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 kinda feel like it should be its own detector (you called it out as a possibility in the original issue). Was there any reason you decided not to go that route?
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.
Was there any reason you decided not to go that route?
The main reasons were that
- it felt like the Docker/bare system detectors should evolve together and provide the same attributes when technically feasible: we get the same attributes today and if e.g. someone wants to add the
host.arch
attribute when running the Collector binary it makes sense that they would also want it when running on Docker. - the system detector should work regardless of how the Collector is ran: from a user's POV it should make no difference if they are running the Collector from a bare binary or a containerized version.
But as I wrote, I can definitely see it being its own detector, specially if we think they might end up diverging in some way (e.g. we want to add a docker.version
attribute or some other attribute that only makes sense on Docker). We have to have a use_docker_sock
flag anyway so it's not going to make the user experience much worse and it is more flexible
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.
@jrcamp I thought about this a bit more, and while I think the arguments above make sense, I think it's likely that these detector end up diverging so I separated it, PTAL
This PR was marked stale due to lack of activity. It will be closed in 7 days. |
|
||
* Docker metadata: Queries the Docker daemon to retrieve the following resource attributes from the host machine: | ||
|
||
* host.name |
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.
Can you describe the difference between retrieving these with normal means? I'm surprised we need to use the docker API to get simple looking attributes.
Maybe it's to retrieve the information about the host, not the docker container. If so, this seems wrong, I believe our semantic conventions intend these to be filled for the current process, which would be using the values from within the docker container, not the host machine. I'd expect us to define new conventions in the spec, something like containerhost.host.name
, containerhost.os.type
for things outside the process.
Sorry if I'm missing something
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.
Also I was expecting this PR to implement container
attributes
Surprised to see host.name
and os.type
in the docker detector :)
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.
Can you describe the difference between retrieving these with normal means? I'm surprised we need to use the docker API to get simple looking attributes.
Here is the output of the hostname
command and the Name
field from the Docker API info endpoint from an Ubuntu Docker image running on an Ubuntu VM:
❯ docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -it ubuntu bash
root@3d639eae3af3:/# apt-get update && apt-get install -y curl jq
# ...
root@3d639eae3af3:/# hostname
3d639eae3af3
root@3d639eae3af3:/# curl --silent --unix-socket /var/run/docker.sock http://localhost/info | jq .Name
"ubuntu-vm"
hostname
gives you the os.Hostname
(which is a random string on Docker). The Docker API gives you the name of the host machine (on Linux and Windows).
Similarly, the os.type
will give you the host OS type (so, e.g., windows
even if your container is Linux-based).
I'd expect us to define new conventions in the spec, something like containerhost.host.name, containerhost.os.type for things outside the process.
I can definitely do that, but I fail to see why someone would care about the Docker hostname: the whole point (at least to me) of running the Collector as a Docker image is to not have other stuff running in the same Docker image so the useful info is the one about the host where the Docker image is running.
Also I was expecting this PR to implement container attributes
👍 will do
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.
Ah, thanks for the explanation, that's the opposite behavior of what I was expecting for os.type
, surprised native calls within the container don't return information about the container :O And populating something other than the random string seems good.
Just curious, do you know how common it is to have the docker API exposed? For example, will kubernetes users generally be able to use the detector?
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.
Just curious, do you know how common it is to have the docker API exposed? For example, will kubernetes users generally be able to use the detector?
I don't know about Kubernetes specifically, I would expect that people have to mount the Unix socket manually. We use this on our Datadog Agent for users running Docker by itself, but we have a different solution for Kubernetes.
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 we can add further container
attributes in a future PR now I understand that this is important for correctly populating those existing ones
|
||
* Docker metadata: Queries the Docker daemon to retrieve the following resource attributes from the host machine: | ||
|
||
* host.name |
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.
Ah, thanks for the explanation, that's the opposite behavior of what I was expecting for os.type
, surprised native calls within the container don't return information about the container :O And populating something other than the random string seems good.
Just curious, do you know how common it is to have the docker API exposed? For example, will kubernetes users generally be able to use the detector?
Please rebase, codecov should not run :) |
@jrcamp if you have any other comment please open an issue. |
Sorry, I was out yesterday and didn't see this, happy to see there was no problem with the merge |
* Add a host wrapper to improve ReportFatalError msg * Adding host wrapper when starting pipeline * Do not allocate in the loop
Description:
Link to tracking Issue: Fixes #2773
Testing: Amended unit tests. Tested on Ubuntu 18.04 (you need to add
-v /var/run/docker.sock:/var/run/docker.sock
).Documentation: Documented on README