Skip to content
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

Log metadata payload as debug to be added to flares #3625

Merged
merged 1 commit into from Jan 8, 2018

Conversation

hush-hush
Copy link
Member

What does this PR do?

When debugging some support case, having the metadata payload in the logs
can be very useful.

@hush-hush hush-hush added this to the 5.21.0 milestone Jan 2, 2018
# to the backend.
data = payload.payload # deep copy and merge of meta and metric data
data['apiKey'] = '*************************' + data.get('apiKey', '')[-5:]
log.debug("Metadata payload: %s", json.dumps(data))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as @gmmeyer pointed out it's probably enough to log this only:

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@olivielpeau:
The second one won't work since we will miss external_host_tags. And we could move the log line to _should_send_additional_data but it will result in exactly the same thing except we will be missing the metrics part.

I think we should keep it here to have a payload as close to the one receive by the backend (since the goal is to debug agent/backend interaction).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation @hush-hush!

So if I understand the code correctly this would log the whole agent payload (metadata + metrics + service checks + events) at the end of every run of the collector. Even though it's logged at the debug level I'm still concerned about the size of the log entries this would generate (would be at least a few KBs in general, and up to a few MBs on some agents sending thousands of metrics/events).

I think we should try to select what we think is relevant in the whole payload to debug metadata-related behavior, or at least remove the fields that can be big and are definitely not relevant. Maybe the fields that are defined here: https://github.com/DataDog/dd-agent/blob/5.20.2/checks/collector.py#L63-L66 , and that we could get with payload.meta_payload would be enough? If not could we remove the metrics and service_checks fields (which are not sent in the same payload anyway, cf the splitting done by the emitter), and the events field too (which shouldn't have any impact on the metadata resolution)?

Finally, I think logging this on the first run of the collector should be enough, unless I'm missing something.

Let me know what you think :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@olivielpeau: indeed we were going to log it at every collector run... Good catch.
After speaking with the intake team, I think it's important to log the metadata payload as close as possible to what they will receive.

I added a condition to log the payload only on the first run.

@hush-hush hush-hush force-pushed the maxime/log-metadata branch 2 times, most recently from c9d264d to 976f714 Compare January 8, 2018 16:56
When debugging some support case, having the metadata payload in the logs
can be very useful.
@hush-hush hush-hush merged commit 54922f5 into master Jan 8, 2018
@hush-hush hush-hush deleted the maxime/log-metadata branch January 8, 2018 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants