Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
159 commits
Select commit Hold shift + click to select a range
2be84bf
add murmur128
mredolatti Sep 30, 2020
af0952d
change cpphash branch
mredolatti Sep 30, 2020
1553fad
use install_requires
mredolatti Sep 30, 2020
274606b
remove ssh
mredolatti Sep 30, 2020
f2beb3c
Merge pull request #180 from splitio/feature/hash128
mredolatti Sep 30, 2020
cb35492
add impression observer
mredolatti Oct 1, 2020
dabd6bf
some polishing
mredolatti Oct 1, 2020
7ea6cbb
Make block_until_ready() guarantee factory readiness
sethbrite Oct 2, 2020
e994cb7
Merge pull request #181 from splitio/impression_observer
mredolatti Oct 5, 2020
caa8b50
add counter and manager
mredolatti Oct 6, 2020
3d67428
commit ALL the files
mredolatti Oct 6, 2020
4589b38
pr feedback
mredolatti Oct 6, 2020
3518309
Merge pull request #183 from splitio/impression_counter
mredolatti Oct 7, 2020
b93d090
initial integration
mredolatti Oct 7, 2020
a0a443d
update configs
mredolatti Oct 7, 2020
19fc89c
fix remaining tests
mredolatti Oct 8, 2020
d3cf340
added auth client
Oct 8, 2020
20319ee
doc
Oct 8, 2020
5e5bf6f
support lowercase impressions mode
mredolatti Oct 8, 2020
541d3c7
Merge pull request #184 from splitio/imp_dedupe/manager_integration
mredolatti Oct 8, 2020
3649220
fix log message
mredolatti Oct 8, 2020
0477c08
Merge pull request #187 from splitio/imp_dedupe/manager_integration
mredolatti Oct 8, 2020
e18789e
forcefully test python murmur128
mredolatti Oct 13, 2020
5680cbb
Merge branch 'feature/imp_dedupe' of github.com:splitio/python-client…
mredolatti Oct 13, 2020
5e15293
fix test
mredolatti Oct 13, 2020
3047f61
Merge pull request #186 from splitio/feature/imp_dedupe
mredolatti Oct 13, 2020
4208b4d
Merge pull request #182 from sethbrite/ensure_factory_readiness
mredolatti Oct 13, 2020
1540e91
added parser
Oct 13, 2020
d7094d7
removed print
Oct 13, 2020
6cf2f39
use an intermediate flag
mredolatti Oct 13, 2020
1a8fde8
Merge pull request #189 from splitio/fix/ready_flag
mredolatti Oct 13, 2020
bfbceb0
added notification dto
Oct 14, 2020
c8a9c72
added more validations
Oct 14, 2020
41b6e84
Merge branch 'feature/push_parser' of github.com:splitio/python-clien…
Oct 14, 2020
300feb0
validations
Oct 14, 2020
48e3119
updated
Oct 14, 2020
f830607
removed commented line
Oct 14, 2020
dede4e5
updated incoming payload
Oct 14, 2020
87d5e6a
improvements in parser
Oct 14, 2020
09ebee8
Merge pull request #185 from splitio/feature/auth
mmelograno Oct 15, 2020
832f193
Merge branch 'feature/push_parser' of github.com:splitio/python-clien…
Oct 16, 2020
28b2cd4
Merge branch 'feature/notification' of github.com:splitio/python-clie…
Oct 16, 2020
5995319
added workers for segments and splits
Oct 16, 2020
b491cbd
fixed 2.7 issue
Oct 16, 2020
51fdc52
add unit tests
mredolatti Oct 19, 2020
3c010ad
make it work in py2
mredolatti Oct 20, 2020
293bd27
address sonarqube comments
mredolatti Oct 20, 2020
68b9dee
Merge pull request #193 from splitio/feature/sseclient
mredolatti Oct 20, 2020
963f172
added sync
Oct 20, 2020
2acf8ff
added custom exception
Oct 20, 2020
0dc8e00
Merge pull request #188 from splitio/feature/push_parser
mmelograno Oct 20, 2020
f7f036b
Merge branch 'feature/streaming' of github.com:splitio/python-client …
Oct 20, 2020
6bcb87b
Merge pull request #191 from splitio/feature/notification
mmelograno Oct 20, 2020
a3bf240
Merge branch 'feature/streaming' of github.com:splitio/python-client …
Oct 20, 2020
dcdaf6c
general logger
Oct 20, 2020
83cf4bf
Merge pull request #192 from splitio/feature/eventReactor
mmelograno Oct 20, 2020
2b6724f
Merge branch 'feature/streaming' of github.com:splitio/python-client …
Oct 20, 2020
30cac7a
updated workers
Oct 20, 2020
fa7ac6c
moved to synchronizers
Oct 21, 2020
d1fd16c
merged with latest in dev
Oct 21, 2020
844227f
Merge branch 'development' of github.com:splitio/python-client into f…
Oct 21, 2020
271b34a
Merge branch 'feature/streaming' of github.com:splitio/python-client …
Oct 21, 2020
664be45
added tests
Oct 21, 2020
73eb059
push notification manager, processor, status keeper
mredolatti Oct 22, 2020
3652ab7
manager
Oct 22, 2020
8c8f2b7
added locally kill
Oct 22, 2020
adb03e0
last updated
Oct 22, 2020
8dac387
added timer to be ready
Oct 22, 2020
2ef3383
added timer for stop
Oct 22, 2020
b8b4471
Merge pull request #194 from splitio/synchronizer
mmelograno Oct 22, 2020
58d2453
Merge branch 'feature/streaming' of github.com:splitio/python-client …
Oct 22, 2020
b00ba90
updated test, added localhost sync and updated factory
Oct 23, 2020
4ddc33d
fixed assignment to manager instead of synchronizer for localhost mod…
Oct 23, 2020
b3dd9a4
updated configs
Oct 23, 2020
f216c92
pylint
Oct 23, 2020
f231fc5
add tests
mredolatti Oct 23, 2020
9e71584
Merge branch 'feature/streaming' of github.com:splitio/python-client …
mredolatti Oct 23, 2020
81a3303
refactored logger in apis
Oct 23, 2020
6408b6b
add processor tests
mredolatti Oct 23, 2020
9c95d5e
Merge pull request #195 from splitio/feature/not_parser_processor_int…
mredolatti Oct 23, 2020
857ab5a
renaming sync
Oct 23, 2020
a8ae5bb
Merge branch 'feature/streaming' of github.com:splitio/python-client …
Oct 23, 2020
d0c8365
Merge pull request #196 from splitio/feature/syncmanager
mmelograno Oct 23, 2020
7300038
Merge branch 'feature/streaming' of github.com:splitio/python-client …
Oct 26, 2020
30a93d9
logger changes
Oct 26, 2020
d62b97e
feedback
Oct 26, 2020
56d01f0
Merge pull request #197 from splitio/fix/logger
mmelograno Oct 26, 2020
3e35c98
initial integration commit
mredolatti Oct 26, 2020
fb91cc6
Merge branch 'feature/streaming' of github.com:splitio/python-client …
mredolatti Oct 26, 2020
b1e626e
fix streaming enabled
mredolatti Oct 26, 2020
70a6900
stop should leave running in false
mredolatti Oct 26, 2020
6dbdb95
refactor returning sync segments status
Oct 26, 2020
224b162
simplify initialization
mredolatti Oct 26, 2020
1e13e39
Merge branch 'feature/streaming_integration' of github.com:splitio/py…
mredolatti Oct 26, 2020
954a626
fixed tests regarding missing args
Oct 26, 2020
7f9e723
fixing test regarding streaming argument
Oct 26, 2020
0c700fb
fix pending tests
mredolatti Oct 27, 2020
368951d
fix token re-auth
mredolatti Oct 27, 2020
be0989a
name all threads. forward sse url.
mredolatti Oct 27, 2020
7ecbb13
Merge pull request #198 from splitio/feature/streaming_integration
mredolatti Oct 27, 2020
7097150
add backoff
mredolatti Oct 27, 2020
6dde2b3
improved error logging when an exception is raised from HttpClient
Oct 27, 2020
4ef1ef4
Merge pull request #200 from splitio/feature/streaming_backoff
mredolatti Oct 27, 2020
202b4f3
renamed and moved modules
Oct 27, 2020
6ca558f
enable keepalive timeouts
mredolatti Oct 27, 2020
de2b07d
fix possible race condition
mredolatti Oct 27, 2020
03efe8b
Merge pull request #201 from splitio/task/streamingRefactor
mmelograno Oct 27, 2020
ea80fb9
Merge branch 'feature/streaming' of github.com:splitio/python-client …
mredolatti Oct 27, 2020
c4f9642
Merge pull request #202 from splitio/feature/sse_connection_timeout
mredolatti Oct 27, 2020
f68eccc
shutdown push staus event listener
mredolatti Oct 28, 2020
3c76208
Merge pull request #203 from splitio/splitio/sync/shutdown_listener_t…
mredolatti Oct 28, 2020
368de9f
blocking on destroy
Oct 28, 2020
c4ffabd
Merge branch 'feature/streaming' of github.com:splitio/python-client …
Oct 28, 2020
4760701
fixed test
Oct 28, 2020
2d86cf3
fixes
Oct 28, 2020
f54fe60
Merge pull request #204 from splitio/task/destroyBlocking
mmelograno Oct 28, 2020
07b80b6
add mockservers for REST endpoints
mredolatti Oct 28, 2020
f9da3c3
some cleanup
mredolatti Oct 30, 2020
45f9ff9
bump rc
mredolatti Oct 30, 2020
418b48e
async initialization
mredolatti Oct 30, 2020
c5ad559
removed on-init handler, fixed synchronize condition for splits and s…
Oct 30, 2020
3c70714
moved workerpool pause and removed duplicated tests
Oct 30, 2020
d4860bc
removed unnevesary check
Oct 30, 2020
47dd25a
Merge branch 'feature/streaming' of github.com:splitio/python-client …
mredolatti Oct 30, 2020
79f65ad
Merge pull request #206 from splitio/task/fixes
mmelograno Oct 30, 2020
300ae6a
added shutdown method
Oct 30, 2020
2664e7d
fix
Oct 30, 2020
e8d250e
added event for redis
Oct 30, 2020
2b9434e
added coverage for destroy in redis mode
Oct 30, 2020
f4bea7b
Merge pull request #207 from splitio/task/fixes
mmelograno Oct 30, 2020
9ff202b
reoriganization
mredolatti Oct 30, 2020
8bcf95d
reordering
mredolatti Oct 30, 2020
b89e5a3
Merge branch 'feature/streaming' of github.com:splitio/python-client …
mredolatti Oct 30, 2020
ecd65cb
.
mredolatti Oct 30, 2020
2cd3193
Merge pull request #205 from splitio/tests/sdkmockserver
mredolatti Oct 30, 2020
0f3849d
partial commit -integration tests
mredolatti Oct 30, 2020
dd46cde
warn if stopping an already stopped sse client
mredolatti Oct 31, 2020
1cb05c0
fix error propagation
mredolatti Oct 31, 2020
36bf9b8
set name afterwards
mredolatti Oct 31, 2020
5d86eee
Merge branch 'feature/streaming' of github.com:splitio/python-client …
mredolatti Oct 31, 2020
7e31510
added exception
Nov 2, 2020
1a59dc4
typo
Nov 2, 2020
af6fcf3
add happy path integration test and couple of fixes
mredolatti Nov 2, 2020
5c4c402
fix localhost abstract class methods
mredolatti Nov 2, 2020
0eccc7a
Merge branch 'feature/streaming' of github.com:splitio/python-client …
mredolatti Nov 2, 2020
209640a
assert that the worker is still alive until stopped
mredolatti Nov 2, 2020
d32dcb5
Merge pull request #209 from splitio/task/fixes
mredolatti Nov 2, 2020
6c97010
Merge branch 'feature/streaming' of github.com:splitio/python-client …
mredolatti Nov 2, 2020
74b450d
fix non-isolated test
mredolatti Nov 2, 2020
903f9e3
more integration tests and UT fixing
mredolatti Nov 3, 2020
dac5ecc
re-enable skipped tests
mredolatti Nov 3, 2020
bd9aebd
more tests
mredolatti Nov 3, 2020
1069ad3
more tests
mredolatti Nov 4, 2020
c063e34
more tests and some polishing
mredolatti Nov 4, 2020
76d531a
last integration tests
mredolatti Nov 4, 2020
bca16ac
Merge pull request #210 from splitio/tests/push_integration
mredolatti Nov 4, 2020
4d66ad9
Merge pull request #199 from splitio/feature/streaming
mredolatti Nov 4, 2020
ea13467
update changes and setup.py
mredolatti Nov 4, 2020
bbeebc0
Merge pull request #212 from splitio/update/setup_changes
mredolatti Nov 4, 2020
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
10 changes: 8 additions & 2 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
8.3.0 (Nov 4, 2020)
- Added local impressions deduping. Defaulting to optimized
- Added support for the new Split streaming architecture. When enabled (default), the SDK will not poll for updates but instead receive notifications every time there's a change in your environments, allowing to process those much quicker. If disabled or in the event of an issue, the SDK will fallback to the known polling mechanism to provide a seamless experience.
- Updated logging structure so that it's built in terms of a hierarchy with the root at 'splitio'
- Fixed timing issue which caused factory.ready to return False if called immediately after .block_until_ready()

8.2.1 (Aug 25, 2020)
- Use mmh3cffi=0.1.5 which fixes xcode12 issue
- Updated mmh3cffi to version 0.1.5 which fixes xcode12 issue

8.2.0 (Mar 27, 2020)
- Support enabling in-memory cache via config options
- Added support for enabling in-memory cache via config options

8.1.7 (Jan 23, 2020)
- Removed enum34 dependency for python versions > 3.4
Expand Down
5 changes: 2 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
'futures>=3.0.5;python_version<"3"'
]

with open(path.join(path.abspath(path.dirname(__file__)),
'splitio', 'version.py')) as f:
with open(path.join(path.abspath(path.dirname(__file__)), 'splitio', 'version.py')) as f:
exec(f.read()) # pylint: disable=exec-used

setup(
Expand All @@ -42,7 +41,7 @@
'test': TESTS_REQUIRES,
'redis': ['redis>=2.10.5'],
'uwsgi': ['uwsgi>=2.0.0'],
'cpphash': ['mmh3cffi>=0.1.5']
'cpphash': ['mmh3cffi==0.2.0'],
},
setup_requires=['pytest-runner'],
classifiers=[
Expand Down
56 changes: 56 additions & 0 deletions splitio/api/auth.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
"""Auth API module."""

import logging
import json

from future.utils import raise_from

from splitio.api import APIException, headers_from_metadata
from splitio.api.client import HttpClientException
from splitio.models.token import from_raw


_LOGGER = logging.getLogger(__name__)


class AuthAPI(object): # pylint: disable=too-few-public-methods
"""Class that uses an httpClient to communicate with the SDK Auth Service API."""

def __init__(self, client, apikey, sdk_metadata):
"""
Class constructor.

:param client: HTTP Client responsble for issuing calls to the backend.
:type client: HttpClient
:param apikey: User apikey token.
:type apikey: string
:param sdk_metadata: SDK version & machine name & IP.
:type sdk_metadata: splitio.client.util.SdkMetadata
"""
self._client = client
self._apikey = apikey
self._metadata = headers_from_metadata(sdk_metadata)

def authenticate(self):
"""
Perform authentication.

:return: Json representation of an authentication.
:rtype: splitio.models.token.Token
"""
try:
response = self._client.get(
'auth',
'/auth',
self._apikey,
extra_headers=self._metadata
)
if 200 <= response.status_code < 300:
payload = json.loads(response.body)
return from_raw(payload)
else:
raise APIException(response.body, response.status_code)
except HttpClientException as exc:
_LOGGER.error('Exception raised while authenticating')
_LOGGER.debug('Exception information: ', exc_info=True)
raise_from(APIException('Could not perform authentication.'), exc)
19 changes: 11 additions & 8 deletions splitio/api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ class HttpClient(object):

SDK_URL = 'https://sdk.split.io/api'
EVENTS_URL = 'https://events.split.io/api'
AUTH_URL = 'https://auth.split.io/api'

def __init__(self, timeout=None, sdk_url=None, events_url=None):
def __init__(self, timeout=None, sdk_url=None, events_url=None, auth_url=None):
"""
Class constructor.

Expand All @@ -38,11 +39,14 @@ def __init__(self, timeout=None, sdk_url=None, events_url=None):
:type sdk_url: str
:param events_url: Optional alternative events URL.
:type events_url: str
:param auth_url: Optional alternative auth URL.
:type auth_url: str
"""
self._timeout = timeout / 1000 if timeout else None # Convert ms to seconds.
self._timeout = timeout/1000 if timeout else None # Convert ms to seconds.
self._urls = {
'sdk': sdk_url if sdk_url is not None else self.SDK_URL,
'events': events_url if events_url is not None else self.EVENTS_URL,
'auth': auth_url if auth_url is not None else self.AUTH_URL,
}

def _build_url(self, server, path):
Expand Down Expand Up @@ -72,11 +76,11 @@ def _build_basic_headers(apikey):
'Authorization': "Bearer %s" % apikey
}

def get(self, server, path, apikey, query=None, extra_headers=None): #pylint: disable=too-many-arguments
def get(self, server, path, apikey, query=None, extra_headers=None): # pylint: disable=too-many-arguments
"""
Issue a get request.

:param server: Whether the request is for SDK server or Events server.
:param server: Whether the request is for SDK server, Events server or Auth server.
:typee server: str
:param path: path to append to the host url.
:type path: str
Expand All @@ -91,7 +95,6 @@ def get(self, server, path, apikey, query=None, extra_headers=None): #pylint: d
:rtype: HttpResponse
"""
headers = self._build_basic_headers(apikey)

if extra_headers is not None:
headers.update(extra_headers)

Expand All @@ -103,10 +106,10 @@ def get(self, server, path, apikey, query=None, extra_headers=None): #pylint: d
timeout=self._timeout
)
return HttpResponse(response.status_code, response.text)
except Exception as exc: #pylint: disable=broad-except
except Exception as exc: # pylint: disable=broad-except
raise_from(HttpClientException('requests library is throwing exceptions'), exc)

def post(self, server, path, apikey, body, query=None, extra_headers=None): #pylint: disable=too-many-arguments
def post(self, server, path, apikey, body, query=None, extra_headers=None): # pylint: disable=too-many-arguments
"""
Issue a POST request.

Expand Down Expand Up @@ -140,5 +143,5 @@ def post(self, server, path, apikey, body, query=None, extra_headers=None): #py
timeout=self._timeout
)
return HttpResponse(response.status_code, response.text)
except Exception as exc: #pylint: disable=broad-except
except Exception as exc: # pylint: disable=broad-except
raise_from(HttpClientException('requests library is throwing exceptions'), exc)
8 changes: 5 additions & 3 deletions splitio/api/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
from splitio.api.client import HttpClientException


_LOGGER = logging.getLogger(__name__)


class EventsAPI(object): # pylint: disable=too-few-public-methods
"""Class that uses an httpClient to communicate with the events API."""

Expand All @@ -21,7 +24,6 @@ def __init__(self, http_client, apikey, sdk_metadata):
:param sdk_metadata: SDK version & machine name & IP.
:type sdk_metadata: splitio.client.util.SdkMetadata
"""
self._logger = logging.getLogger(self.__class__.__name__)
self._client = http_client
self._apikey = apikey
self._metadata = headers_from_metadata(sdk_metadata)
Expand Down Expand Up @@ -71,6 +73,6 @@ def flush_events(self, events):
if not 200 <= response.status_code < 300:
raise APIException(response.body, response.status_code)
except HttpClientException as exc:
self._logger.error('Http client is throwing exceptions')
self._logger.debug('Error: ', exc_info=True)
_LOGGER.error('Error posting events because an exception was raised by the HTTPClient')
_LOGGER.debug('Error: ', exc_info=True)
raise_from(APIException('Events not flushed properly.'), exc)
80 changes: 67 additions & 13 deletions splitio/api/impressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@

from splitio.api import APIException, headers_from_metadata
from splitio.api.client import HttpClientException
from splitio.engine.impressions import ImpressionsMode


_LOGGER = logging.getLogger(__name__)


class ImpressionsAPI(object): # pylint: disable=too-few-public-methods
"""Class that uses an httpClient to communicate with the impressions API."""

def __init__(self, client, apikey, sdk_metadata):
def __init__(self, client, apikey, sdk_metadata, mode=ImpressionsMode.OPTIMIZED):
"""
Class constructor.

Expand All @@ -21,10 +25,10 @@ def __init__(self, client, apikey, sdk_metadata):
:param apikey: User apikey token.
:type apikey: string
"""
self._logger = logging.getLogger(self.__class__.__name__)
self._client = client
self._apikey = apikey
self._metadata = headers_from_metadata(sdk_metadata)
self._metadata['SplitSDKImpressionsMode'] = mode.name

@staticmethod
def _build_bulk(impressions):
Expand All @@ -35,19 +39,20 @@ def _build_bulk(impressions):
:type impressions: list(splitio.models.impressions.Impression)

:return: Dictionary of lists of impressions.
:rtype: dict
:rtype: list
"""
return [
{
'testName': test_name,
'keyImpressions': [
'f': test_name,
'i': [
{
'keyName': impression.matching_key,
'treatment': impression.treatment,
'time': impression.time,
'changeNumber': impression.change_number,
'label': impression.label,
'bucketingKey': impression.bucketing_key
'k': impression.matching_key,
't': impression.treatment,
'm': impression.time,
'c': impression.change_number,
'r': impression.label,
'b': impression.bucketing_key,
'pt': impression.previous_time
}
for impression in imps
]
Expand All @@ -58,6 +63,27 @@ def _build_bulk(impressions):
)
]

@staticmethod
def _build_counters(counters):
"""
Build an impression bulk formatted as the API expects it.

:param counters: List of impression counters per feature.
:type counters: list[splitio.engine.impressions.Counter.CountPerFeature]

:return: dict with list of impression count dtos
:rtype: dict
"""
return {
'pf': [
{
'f': pf_count.feature,
'm': pf_count.timeframe,
'rc': pf_count.count
} for pf_count in counters
]
}

def flush_impressions(self, impressions):
"""
Send impressions to the backend.
Expand All @@ -77,6 +103,34 @@ def flush_impressions(self, impressions):
if not 200 <= response.status_code < 300:
raise APIException(response.body, response.status_code)
except HttpClientException as exc:
self._logger.error('Http client is throwing exceptions')
self._logger.debug('Error: ', exc_info=True)
_LOGGER.error(
'Error posting impressions because an exception was raised by the HTTPClient'
)
_LOGGER.debug('Error: ', exc_info=True)
raise_from(APIException('Impressions not flushed properly.'), exc)

def flush_counters(self, counters):
"""
Send impressions to the backend.

:param impressions: Impressions bulk
:type impressions: list
"""
bulk = self._build_counters(counters)
try:
response = self._client.post(
'events',
'/testImpressions/count',
self._apikey,
body=bulk,
extra_headers=self._metadata
)
if not 200 <= response.status_code < 300:
raise APIException(response.body, response.status_code)
except HttpClientException as exc:
_LOGGER.error(
'Error posting impressions counters because an exception was raised by the '
'HTTPClient'
)
_LOGGER.debug('Error: ', exc_info=True)
raise_from(APIException('Impressions not flushed properly.'), exc)
13 changes: 9 additions & 4 deletions splitio/api/segments.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
from splitio.api.client import HttpClientException


class SegmentsAPI(object): #pylint: disable=too-few-public-methods
_LOGGER = logging.getLogger(__name__)


class SegmentsAPI(object): # pylint: disable=too-few-public-methods
"""Class that uses an httpClient to communicate with the segments API."""

def __init__(self, http_client, apikey):
Expand All @@ -21,7 +24,6 @@ def __init__(self, http_client, apikey):
:param apikey: User apikey token.
:type apikey: string
"""
self._logger = logging.getLogger(self.__class__.__name__)
self._client = http_client
self._apikey = apikey

Expand Down Expand Up @@ -50,6 +52,9 @@ def fetch_segment(self, segment_name, change_number):
else:
raise APIException(response.body, response.status_code)
except HttpClientException as exc:
self._logger.error('Http client is throwing exceptions')
self._logger.debug('Error: ', exc_info=True)
_LOGGER.error(
'Error fetching %s because an exception was raised by the HTTPClient',
segment_name
)
_LOGGER.debug('Error: ', exc_info=True)
raise_from(APIException('Segments not fetched properly.'), exc)
10 changes: 6 additions & 4 deletions splitio/api/splits.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
from splitio.api.client import HttpClientException


class SplitsAPI(object): #pylint: disable=too-few-public-methods
_LOGGER = logging.getLogger(__name__)


class SplitsAPI(object): # pylint: disable=too-few-public-methods
"""Class that uses an httpClient to communicate with the splits API."""

def __init__(self, client, apikey):
Expand All @@ -21,7 +24,6 @@ def __init__(self, client, apikey):
:param apikey: User apikey token.
:type apikey: string
"""
self._logger = logging.getLogger(self.__class__.__name__)
self._client = client
self._apikey = apikey

Expand All @@ -47,6 +49,6 @@ def fetch_splits(self, change_number):
else:
raise APIException(response.body, response.status_code)
except HttpClientException as exc:
self._logger.error('Http client is throwing exceptions')
self._logger.debug('Error: ', exc_info=True)
_LOGGER.error('Error fetching splits because an exception was raised by the HTTPClient')
_LOGGER.debug('Error: ', exc_info=True)
raise_from(APIException('Splits not fetched correctly.'), exc)
Loading