DataDog / ansible-datadog

Ansible role for Datadog Agent
Apache License 2.0
297 stars 222 forks source link

creating install.json file related to apm single step instrumation #572

Closed schneideradam closed 2 months ago

schneideradam commented 2 months ago

What does this PR do?

This PR makes the agent install ansible collection write an install.json file to the same directory as the Agent config file, datadog.yaml. The install.json file contains a random UUID, an installation timestamp, and the mechanism that was used to install the agent (the hardcoded string ansible_manual or ansible_single_step). The agent will send this information to the Datadog backend, so that we can gather telemetric data on how long users take to onboard after the initial installation of the agent.

Motivation

Jira: https://datadoghq.atlassian.net/browse/APMON-1070 . This is part of our broader work on improving the APM onboarding experience.

Additional Notes

Possible Drawbacks / Trade-offs

I am not copying these changes to the agent-dmg, iot-agent-deb or iot-agent-rpm directories, because we are initially focusing on improving the onboarding experience on Linux.

Describe how to test/QA your changes

Quick test

There isn't a quick test because of the nature of the ansible installer. Please follow the non-quick test below.

End to end test

To test, I first spun up a gcp RHEL instance and pulled the latest branch code. I installed ansible-core v2.11.12. I confirmed that the datadog_apm_instrumentation_enabled was set to "host". From there I ran the playbook with the manual test listed in the command below:

ansible-playbook -i localhost, manual_tests/test_7_full.yml --connection=local

I checked in /etc/datadog-agent to ensure install.json existed and had the following values: {"install_id": "88d5cfef-2f72-4b59-af8d-1e07b71b684b", "install_type": "ansible_single_step", "install_time": 1718116519}

I then changed the value for datadog_apm_instrumentation_enabled to an empty string "" and re-ran the command. I observed that the following install.json updated with the following:

{"install_id": "88d5cfef-2f72-4b59-af8d-1e07b71b684b", "install_type": "ansible_manual", "install_time": 1718116519}

I repeated all above steps in debian.

schneideradam commented 2 months ago

I have verified this on both rhel and debian. I checked with both datadog_apm_instrumentation_enabled enabled, and disabled, and verified the correct behavior. Let me know if that is adequate. I can share screenshots if you'd like.

schneideradam commented 2 months ago

@yshapiro-57 Do you mean you'd like to see some sort of CI unit test? Or instructions on how to test this PR? I'm happy to do whatever, I just usually don't worry about testing something like this when it should just fail silently so as not to get in the way of instrumenting their applications.

yshapiro-57 commented 2 months ago

@schneideradam I was thinking something like this wiki or the end to end test plan on this PR; something that explains to a fresh person how to cause this code to be executed in a local environment.

Again, if you don't already have a writeup handy, and putting one together is time-consuming, then don't worry about it. I think it will be fine to document the testing steps on RHEL and Debian another time.

schneideradam commented 2 months ago

@spencergilbert Can we get this merged? Also, what is the process for deploying to ansible-galaxy?

spencergilbert commented 2 months ago

Followed up internally regarding release, expected publishing next week.

Kyle-Verhoog commented 1 month ago

@spencergilbert did the release go out?

cc @alexbryukhanova