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

'metric_type' should be 'type' #64

Merged
merged 1 commit into from
Jun 30, 2015
Merged
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
18 changes: 16 additions & 2 deletions datadog/api/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,35 @@ def send(cls, metrics=None, **single_metric):
:param tags: list of tags associated with the metric.
:type tags: string list

:param metric_type: type of the metric
:type metric_type: 'gauge' or 'counter' string
:param type: type of the metric
:type type: 'gauge' or 'counter' string

:returns: JSON response from HTTP request
"""
def rename_metric_type(metric):
"""
FIXME DROPME in 1.0:

API documentation was illegitimately promoting usage of `metric_type` parameter
instead of `type`.
To be consistent and avoid 'backward incompatibilities', properly rename this parameter.
"""
if 'metric_type' in metric:
metric['type'] = metric.pop('metric_type')

# Set the right endpoint
cls._class_url = cls._METRIC_SUBMIT_ENDPOINT

# Format the payload
try:
if metrics:
for metric in metrics:
if isinstance(metric, dict):
rename_metric_type(metric)
metric['points'] = cls._process_points(metric['points'])
metrics_dict = {"series": metrics}
else:
rename_metric_type(single_metric)
single_metric['points'] = cls._process_points(single_metric['points'])
metrics = [single_metric]
metrics_dict = {"series": metrics}
Expand Down