Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion datadog/dogshell/wrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
'''
# stdlib
from __future__ import print_function

import os
from copy import copy
import optparse
import subprocess
Expand Down Expand Up @@ -260,7 +262,7 @@ def parse_options(raw_args=None):
parser.add_option('-n', '--name', action='store', type='string', help="the name of the event \
as it should appear on your Datadog stream")
parser.add_option('-k', '--api_key', action='store', type='string',
help="your DataDog API Key")
help="your DataDog API Key", default=os.environ.get("DD_API_KEY"))
parser.add_option('-s', '--site', action='store', type='choice', default='datadoghq.com', choices=['datadoghq.com', 'us', 'datadoghq.eu', 'eu'], help="The site \
to send data, US (datadoghq.com) or EU (datadoghq.eu), default: US")
parser.add_option('-m', '--submit_mode', action='store', type='choice',
Expand Down
4 changes: 4 additions & 0 deletions tests/unit/dogwrap/test_dogwrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ def test_parse_options(self):
with self.assertRaises(SystemExit):
parse_options(['--proc_poll_interval', 'invalid'])

with mock.patch.dict(os.environ, values={"DD_API_KEY": "the_key"}, clear=True):
options, _ = parse_options([])
self.assertEqual(options.api_key, "the_key")

def test_poll_proc(self):
mock_proc = mock.Mock()
mock_proc.poll.side_effect = [None, 0]
Expand Down