Refactor key handling.
Merge pull request #991 from edx/e0d/datadog-refactor

Refactor key handling.