Skip to content

Commit

Permalink
Prepare Release v1.8.0. (#81)
Browse files Browse the repository at this point in the history
* Update Travis CI Ubuntu and Python Versions.

* Bump Package Version to 1.8.0.

* Clean Code to Make Linters Pass.

* Bring Back #noqa for Queue Import.

* Update Docstrings in client.py

* Bring Back Accidentally Deleted Line.
  • Loading branch information
ustinov authored Mar 31, 2021
1 parent 02dce1c commit 1ade929
Show file tree
Hide file tree
Showing 31 changed files with 66 additions and 93 deletions.
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
dist: bionic
dist: focal
language: python
python:
- "3.5"
- "3.6"
- "3.7"
- "3.8"
- "3.9"
install:
- pip install requests
- pip install tdigest
Expand All @@ -29,12 +29,12 @@ deploy:
password:
secure: "w4j8TyINfzCRlcXiZcYj7eIcEYmYIisSHxUsXqC+7pUCFfAwOSJEQJhkYepFWxcmxOIhY5IdWOGsU1JNBkFyzS3NNlU76xvZ7Ykl5zicVd3ng6i/Pj6Eswhf2B5BgCpQwWIXAEHPQL+Q6xmY9tL4YnaLTpXsOOliltt1qdc+W31DilnCEmoFpDUK/KEQckRMvFj60mk3dsep87jxQdtuF+we0piN0JdG5KawjYbwbsLo940ZkXittRw5WKfcIwYbZo1SU8fxflvLKX48qbz6vK9+ACYL/3gav2x2zdopNx8mmK17Q5zgNKuvSm686gXZgzJGrNaSNFm3oNmRMP0dBS4ebYR+jS7ABOiT0SekwBqWkVKLEMnaJC/1k/8JuKabeXcA9mmZP/ZhmRsVMtyP449RBEQKoditMLr10PZbiz5iDu0UjqrF7yOqxwEsIUI7lBXY4r1FBxIrAD/xU8SMFurmb/qTmwB8sbmHxX/L6HBY0giiN039KqhAvcwPbSuDYchzyHouXRkhMgpI2jtpOVottEzMyJtRqaK+qV5zdm1ST6E7WqaIvEkkNM7OGw6jxexTadhQ7w4xdjHYIcgDHHFZJ3C8ZgivaiGaLNxrTT+OJ3fwc+zGcT6ndvYYGzXusre56Zal/PbdElv+sqX0sS/U5UVv9cJU5qQYIv3lpsI="
on:
python: 3.7
python: 3.9
- provider: pypi
user: wavefront-cs
password:
secure: "w4j8TyINfzCRlcXiZcYj7eIcEYmYIisSHxUsXqC+7pUCFfAwOSJEQJhkYepFWxcmxOIhY5IdWOGsU1JNBkFyzS3NNlU76xvZ7Ykl5zicVd3ng6i/Pj6Eswhf2B5BgCpQwWIXAEHPQL+Q6xmY9tL4YnaLTpXsOOliltt1qdc+W31DilnCEmoFpDUK/KEQckRMvFj60mk3dsep87jxQdtuF+we0piN0JdG5KawjYbwbsLo940ZkXittRw5WKfcIwYbZo1SU8fxflvLKX48qbz6vK9+ACYL/3gav2x2zdopNx8mmK17Q5zgNKuvSm686gXZgzJGrNaSNFm3oNmRMP0dBS4ebYR+jS7ABOiT0SekwBqWkVKLEMnaJC/1k/8JuKabeXcA9mmZP/ZhmRsVMtyP449RBEQKoditMLr10PZbiz5iDu0UjqrF7yOqxwEsIUI7lBXY4r1FBxIrAD/xU8SMFurmb/qTmwB8sbmHxX/L6HBY0giiN039KqhAvcwPbSuDYchzyHouXRkhMgpI2jtpOVottEzMyJtRqaK+qV5zdm1ST6E7WqaIvEkkNM7OGw6jxexTadhQ7w4xdjHYIcgDHHFZJ3C8ZgivaiGaLNxrTT+OJ3fwc+zGcT6ndvYYGzXusre56Zal/PbdElv+sqX0sS/U5UVv9cJU5qQYIv3lpsI="
on:
python: 3.7
python: 3.9
tags: true

1 change: 0 additions & 1 deletion example.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""Wavefront SDK Usage Example."""

import sys
Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# coding: utf-8
"""Wavefront Python SDK.
<p>This is a Wavefront Python SDK</p>
Expand All @@ -15,7 +14,7 @@

setuptools.setup(
name='wavefront-sdk-python',
version='1.7.9',
version='1.8.0',
author='Wavefront by VMware',
author_email='[email protected]',
url='https://github.com/wavefrontHQ/wavefront-sdk-python',
Expand Down
1 change: 0 additions & 1 deletion wavefront_sdk/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""Wavefront Python SDK.
This library provides support for sending metrics, histograms and opentracing
Expand Down
116 changes: 58 additions & 58 deletions wavefront_sdk/client.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# pylint: disable=duplicate-code
# -*- coding: utf-8 -*-
"""Wavefront Client for Proxy and Direct Ingestion.
@author Yogesh Prasad Kurmi ([email protected])
Expand All @@ -15,25 +13,26 @@

try:
import queue
except ImportError:
except ImportError: # Python 2.x
import Queue as queue # noqa

from . import entities
from .common import connection_handler, constants, utils
from .common.metrics import registry


# pylint: disable=too-many-instance-attributes
class WavefrontClient(connection_handler.ConnectionHandler,
entities.WavefrontMetricSender,
entities.WavefrontHistogramSender,
entities.WavefrontTracingSpanSender,
entities.WavefrontEventSender):
"""Wavefront data ingestion client.
Sends data directly/via proxy to Wavefront cluster..
Send data directly/via proxy to Wavefront cluster.
"""

# pylint: disable=too-many-instance-attributes

WAVEFRONT_METRIC_FORMAT = 'wavefront'
WAVEFRONT_HISTOGRAM_FORMAT = 'histogram'
WAVEFRONT_TRACING_SPAN_FORMAT = 'trace'
Expand All @@ -43,16 +42,9 @@ class WavefrontClient(connection_handler.ConnectionHandler,
REPORT_END_POINT = '/report'
EVENT_END_POINT = '/api/v2/event'

# pylint: disable=too-many-arguments
# pylint: disable=too-many-statements

def __init__(self,
server,
token,
max_queue_size=50000,
batch_size=10000,
flush_interval_seconds=5,
enable_internal_metrics=True):
def __init__(self, server, token, max_queue_size=50000, batch_size=10000,
flush_interval_seconds=5, enable_internal_metrics=True):
# pylint: disable=too-many-arguments,too-many-statements
"""Construct Direct Client.
@param server: Server address,
Expand Down Expand Up @@ -105,7 +97,6 @@ def __init__(self,
else:
self._sdk_metrics_registry = registry.WavefrontSdkMetricsRegistry(
wf_metric_sender=None)

self._sdk_metrics_registry.new_gauge(
'points.queue.size', self._metrics_buffer.qsize)
self._sdk_metrics_registry.new_gauge(
Expand All @@ -117,25 +108,27 @@ def __init__(self,
'points.invalid')
self._points_dropped = self._sdk_metrics_registry.new_delta_counter(
'points.dropped')
self._points_report_errors = self._sdk_metrics_registry.new_delta_counter(
'points.report.errors')

self._points_report_errors = (
self._sdk_metrics_registry.new_delta_counter(
'points.report.errors'))
self._sdk_metrics_registry.new_gauge(
'histograms.queue.size', self._histograms_buffer.qsize)
'histograms.queue.size',
self._histograms_buffer.qsize)
self._sdk_metrics_registry.new_gauge(
'histograms.queue.remaining_capacity',
remaining_capacity_getter(self._histograms_buffer))
self._histograms_valid = self._sdk_metrics_registry.new_delta_counter(
'histograms.valid')
self._histograms_invalid = self._sdk_metrics_registry.new_delta_counter(
'histograms.invalid')
self._histograms_dropped = self._sdk_metrics_registry.new_delta_counter(
'histograms.dropped')
self._histograms_invalid = (
self._sdk_metrics_registry.new_delta_counter('histograms.invalid'))
self._histograms_dropped = (
self._sdk_metrics_registry.new_delta_counter('histograms.dropped'))
self._histograms_report_errors = (
self._sdk_metrics_registry.new_delta_counter('histograms.report.errors'))

self._sdk_metrics_registry.new_delta_counter(
'histograms.report.errors'))
self._sdk_metrics_registry.new_gauge(
'spans.queue.size', self._tracing_spans_buffer.qsize)
'spans.queue.size',
self._tracing_spans_buffer.qsize)
self._sdk_metrics_registry.new_gauge(
'spans.queue.remaining_capacity',
remaining_capacity_getter(self._tracing_spans_buffer))
Expand All @@ -145,11 +138,12 @@ def __init__(self,
'spans.invalid')
self._spans_dropped = self._sdk_metrics_registry.new_delta_counter(
'spans.dropped')
self._spans_report_errors = self._sdk_metrics_registry.new_delta_counter(
'spans.report.errors')

self._spans_report_errors = (
self._sdk_metrics_registry.new_delta_counter(
'spans.report.errors'))
self._sdk_metrics_registry.new_gauge(
'span_logs.queue.size', self._spans_log_buffer.qsize)
'span_logs.queue.size',
self._spans_log_buffer.qsize)
self._sdk_metrics_registry.new_gauge(
'span_logs.queue.remaining_capacity',
remaining_capacity_getter(self._spans_log_buffer))
Expand All @@ -159,11 +153,12 @@ def __init__(self,
'span_logs.invalid')
self._span_logs_dropped = self._sdk_metrics_registry.new_delta_counter(
'span_logs.dropped')
self._span_logs_report_errors = self._sdk_metrics_registry.new_delta_counter(
'span_logs.report.errors')

self._span_logs_report_errors = (
self._sdk_metrics_registry.new_delta_counter(
'span_logs.report.errors'))
self._sdk_metrics_registry.new_gauge(
'events.queue.size', self._events_buffer.qsize)
'events.queue.size',
self._events_buffer.qsize)
self._sdk_metrics_registry.new_gauge(
'events.queue.remaining_capacity',
remaining_capacity_getter(self._events_buffer))
Expand All @@ -173,10 +168,12 @@ def __init__(self,
'events.invalid')
self._events_dropped = self._sdk_metrics_registry.new_delta_counter(
'events.dropped')
self._events_report_errors = self._sdk_metrics_registry.new_delta_counter(
'events.report.errors')
self._events_report_errors = (
self._sdk_metrics_registry.new_delta_counter(
'events.report.errors'))

def _report(self, points, data_format, entity_prefix, report_errors):
# Raw string is used for the docstring as there's a backslash.
r"""One api call sending one given string data.
@param points: List of data in string format, concat by '\n'
Expand All @@ -198,13 +195,11 @@ def _report(self, points, data_format, entity_prefix, report_errors):
params = {'f': data_format}
compressed_data = utils.gzip_compress(points.encode('utf-8'))
response = requests.post(self.server + self.REPORT_END_POINT,
params=params,
headers=self._headers,
params=params, headers=self._headers,
data=compressed_data)

self._sdk_metrics_registry.new_delta_counter(
'{}.report.{}'.format(entity_prefix,
response.status_code)).inc()
self._sdk_metrics_registry.new_delta_counter('{}.report.{}'.format(
entity_prefix, response.status_code)).inc()
response.raise_for_status()
except Exception as error:
report_errors.inc()
Expand All @@ -230,7 +225,7 @@ def _batch_report(self, batch_line_data, data_format, entity_prefix,
self._report('\n'.join(batch) + '\n', data_format,
entity_prefix, report_errors)
# pylint: disable=broad-except,fixme
# TODO: Please replace a generic Exception with a specific one.
# TODO: Replace a generic Exception with a specific one.
except Exception as error:
logging.error(
'Failed to report %s data points to wavefront %s',
Expand Down Expand Up @@ -301,6 +296,7 @@ def close(self):
self._sdk_metrics_registry.close(timeout_secs=1)

def send_metric(self, name, value, timestamp, source, tags):
# pylint: disable=too-many-arguments
"""Send Metric Data via proxy/direct ingestion client.
Wavefront Metrics Data format
Expand All @@ -320,8 +316,9 @@ def send_metric(self, name, value, timestamp, source, tags):
@type tags: dict
"""
try:
line_data = utils.metric_to_line_data(
name, value, timestamp, source, tags, self._default_source)
line_data = utils.metric_to_line_data(name, value, timestamp,
source, tags,
self._default_source)
self._points_valid.inc()
except ValueError as error:
self._points_invalid.inc()
Expand All @@ -346,6 +343,7 @@ def send_metric_now(self, metrics):

def send_distribution(self, name, centroids, histogram_granularities,
timestamp, source, tags):
# pylint: disable=too-many-arguments
"""Send Distribution Data via proxy/direct ingestion client.
Wavefront Histogram Data format
Expand All @@ -368,9 +366,10 @@ def send_distribution(self, name, centroids, histogram_granularities,
@type tags: dict
"""
try:
line_data = utils.histogram_to_line_data(
name, centroids, histogram_granularities, timestamp,
source, tags, self._default_source)
line_data = utils.histogram_to_line_data(name, centroids,
histogram_granularities,
timestamp, source, tags,
self._default_source)
self._histograms_valid.inc()
except ValueError as error:
self._histograms_invalid.inc()
Expand All @@ -393,10 +392,9 @@ def send_distribution_now(self, distributions):
self._batch_report(distributions, self.WAVEFRONT_HISTOGRAM_FORMAT,
'histograms', self._histograms_report_errors)

# pylint: disable=too-many-arguments

def send_span(self, name, start_millis, duration_millis, source, trace_id,
span_id, parents, follows_from, tags, span_logs):
# pylint: disable=too-many-arguments
"""Send span data via proxy/direct ingestion client.
Wavefront Tracing Span Data format
Expand Down Expand Up @@ -444,8 +442,8 @@ def send_span(self, name, start_millis, duration_millis, source, trace_id,
raise error
if span_logs:
try:
line_data = utils.span_log_to_line_data(
trace_id, span_id, span_logs)
line_data = utils.span_log_to_line_data(trace_id, span_id,
span_logs)
self._span_logs_valid.inc()
except ValueError as error:
self._span_logs_invalid.inc()
Expand Down Expand Up @@ -484,6 +482,7 @@ def send_span_log_now(self, span_logs):

def send_event(self, name, start_time, end_time, source, tags,
annotations):
# pylint: disable=too-many-arguments
"""Send Event Data via proxy/direct ingestion client.
Wavefront Event Data format
Expand All @@ -510,13 +509,14 @@ def send_event(self, name, start_time, end_time, source, tags,
"""
try:
if self._token:
line_data = utils.event_to_json(
name, start_time, end_time, source, tags, annotations,
self._default_source)
line_data = utils.event_to_json(name, start_time, end_time,
source, tags, annotations,
self._default_source)
else:
line_data = utils.event_to_line_data(
name, start_time, end_time, source, tags, annotations,
self._default_source)
line_data = utils.event_to_line_data(name, start_time,
end_time, source, tags,
annotations,
self._default_source)
self._events_valid.inc()
except ValueError as error:
self._events_invalid.inc()
Expand Down
3 changes: 1 addition & 2 deletions wavefront_sdk/client_factory.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""Wavefront MultiClient to support Data Ingestion for Multiple Clients.
@author Yogesh Prasad Kurmi ([email protected])
Expand All @@ -10,7 +9,7 @@
from wavefront_sdk.multi_clients import WavefrontMultiClient


# pylint: disable=W0232
# pylint: disable=W0232 # Class has no __init__ method
class WavefrontClientFactory:
"""Wavefront client factory.
Expand Down
1 change: 0 additions & 1 deletion wavefront_sdk/common/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""Provide utils functions.
@author Hao Song ([email protected])
Expand Down
3 changes: 2 additions & 1 deletion wavefront_sdk/common/application_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ def get_as_list(self):
return tags

def add_custom_tags_from_env(self, pattern):
"""Set custom tags from environment variables that match the regex pattern.
"""Set custom tags from environment variables.
(that match the regex pattern)
@param pattern: Regex pattern
"""
for key in os.environ:
Expand Down
1 change: 0 additions & 1 deletion wavefront_sdk/common/connection_handler.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""A connection handler for both proxy and direct client.
@author: Hao Song ([email protected])
Expand Down
1 change: 0 additions & 1 deletion wavefront_sdk/common/metrics/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""Wavefront SDK Metrics.
@author Hao Song ([email protected])
Expand Down
1 change: 0 additions & 1 deletion wavefront_sdk/common/metrics/counter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""Wavefront SDK Counter.
@author Hao Song ([email protected])
Expand Down
1 change: 0 additions & 1 deletion wavefront_sdk/common/metrics/deltacounter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""Wavefront SDK Delta Counter.
@author Joanna Ko ([email protected])
Expand Down
1 change: 0 additions & 1 deletion wavefront_sdk/common/metrics/gauge.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""Wavefront SDK Gauge.
@author Hao Song ([email protected])
Expand Down
1 change: 0 additions & 1 deletion wavefront_sdk/common/metrics/metrics.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""Wavefront SDK Metric.
@author Hao Song ([email protected])
Expand Down
1 change: 0 additions & 1 deletion wavefront_sdk/common/metrics/registry.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""Wavefront SDK Metrics Registry.
@author Hao Song ([email protected])
Expand Down
1 change: 0 additions & 1 deletion wavefront_sdk/common/proxy_connection_handler.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""Connection Handler class for sending data to a Wavefront proxy.
@author: Hao Song ([email protected])
Expand Down
1 change: 0 additions & 1 deletion wavefront_sdk/common/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
Utils module contains useful function for preparing and processing data.
Expand Down
Loading

0 comments on commit 1ade929

Please sign in to comment.