Skip to content

Commit

Permalink
Release for v0.7.12 (#995)
Browse files Browse the repository at this point in the history
  • Loading branch information
lzchen authored Jan 15, 2021
1 parent 86c2e8a commit ea40da8
Show file tree
Hide file tree
Showing 62 changed files with 281 additions and 191 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# This file controls who is tagged for review for any given pull request.

# For anything not explicitly taken by someone else:
* @census-instrumentation/global-owners @aabmass @c24t @hectorhdzg @lzchen @reyang @songy23 @victoraugustolls
* @census-instrumentation/global-owners @aabmass @hectorhdzg @lzchen @songy23 @victoraugustolls
41 changes: 41 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Build

on:
push:
branches-ignore:
- 'release/*'
pull_request:

jobs:
build:
# 18.04 needed for python3.4
runs-on: ubuntu-18.04
env:
# We use these variables to convert between tox and GHA version literals
py27: 2.7
py34: 3.4
py35: 3.5
py36: 3.6
py37: 3.7
strategy:
# ensures the entire test matrix is run, even if one permutation fails
fail-fast: false
matrix:
python-version: [py27, py34, py35, py36, py37]
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python ${{ env[matrix.python-version] }}
uses: actions/setup-python@v2
with:
python-version: ${{ env[matrix.python-version] }}
- name: Install tox
run: pip install -U tox-factor
- name: Cache tox environment
uses: actions/cache@v2
with:
path: .tox
# bump version prefix to fully reset caches
key: v1-tox-${{ matrix.python-version }}-${{ hashFiles('tox.ini') }}
- name: run tox
run: tox -f ${{ matrix.python-version }}
4 changes: 2 additions & 2 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
# run arbitrary code.
extension-pkg-whitelist=

# Add files or directories to the blacklist. They should be base names, not
# Add files or directories to the excludelist. They should be base names, not
# paths.
ignore=CVS

# Add files or directories matching the regex patterns to the blacklist. The
# Add files or directories matching the regex patterns to the excludelist. The
# regex matches against base names, not paths.
ignore-patterns=

Expand Down
17 changes: 0 additions & 17 deletions .travis.yml

This file was deleted.

5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## Unreleased

## 0.7.12
Released 2021-01-14
- Change blacklist to excludelist
([#977](https://github.com/census-instrumentation/opencensus-python/pull/977))

## 0.7.11
Released 2020-10-13

Expand Down
8 changes: 4 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ Customization

There are several things you can customize in OpenCensus:

* **Blacklist**, which excludes certain hosts and paths from being tracked.
* **Excludelist**, which excludes certain hosts and paths from being tracked.
By default, the health check path for the App Engine flexible environment is
not tracked, you can turn it on by excluding it from the blacklist setting.
not tracked, you can turn it on by excluding it from the excludelist setting.

* **Exporter**, which sends the traces.
By default, the traces are printed to stdout in JSON format. You can choose
Expand Down Expand Up @@ -174,8 +174,8 @@ information, please read the
'OPENCENSUS': {
'TRACE': {
'BLACKLIST_HOSTNAMES': ['localhost', '127.0.0.1'],
'BLACKLIST_PATHS': ['_ah/health'],
'EXCLUDELIST_HOSTNAMES': ['localhost', '127.0.0.1'],
'EXCLUDELIST_PATHS': ['_ah/health'],
'SAMPLER': 'opencensus.trace.samplers.ProbabilitySampler(rate=1)',
'EXPORTER': '''opencensus.ext.ocagent.trace_exporter.TraceExporter(
service_name='foobar',
Expand Down
8 changes: 8 additions & 0 deletions contrib/opencensus-ext-azure/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

## Unreleased

## 1.0.6
Released 2021-01-14

- Disable heartbeat metrics in exporters
([#984](https://github.com/census-instrumentation/opencensus-python/pull/984))
- Loosen instrumentation key validation to GUID
([#984](https://github.com/census-instrumentation/opencensus-python/pull/984))

## 1.0.5
Released 2020-10-13

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def __init__(self, src, dst):

def run(self): # pragma: NO COVER
# Indicate that this thread is an exporter thread.
# Used to suppress tracking of requests in this thread.
# Used to suppress tracking of requests in this thread
execution_context.set_is_exporter(True)
src = self.src
dst = self.dst
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ def _transmit(self, envelopes):
except Exception:
pass
if response.status_code == 200:
logger.info('Transmission succeeded: %s.', text)
return 0
if response.status_code == 206: # Partial Content
if data:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,9 @@ def timestamp_to_iso_str(timestamp):
return to_iso_str(datetime.datetime.utcfromtimestamp(timestamp))


# Validate UUID format
# Specs taken from https://tools.ietf.org/html/rfc4122
# Validate GUID format
uuid_regex_pattern = re.compile('^[0-9a-f]{8}-'
'[0-9a-f]{4}-'
'[1-5][0-9a-f]{3}-'
'[89ab][0-9a-f]{3}-'
'([0-9a-f]{4}-){3}'
'[0-9a-f]{12}$')


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.

__version__ = '1.0.5'
__version__ = '1.0.6'
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ def __init__(self, probability=1.0):
self.probability = probability

def filter(self, record):
return random.random() < self.probability
val = random.random()
print(val)
return val < self.probability


class AzureLogHandler(TransportMixin, ProcessorMixin, BaseLogHandler):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,4 @@ def new_metrics_exporter(**options):
producers,
exporter,
interval=exporter.options.export_interval)
from opencensus.ext.azure.metrics_exporter import heartbeat_metrics
heartbeat_metrics.enable_heartbeat_metrics(
exporter.options.connection_string,
exporter.options.instrumentation_key
)
return exporter
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ def __init__(self, **options):
self._telemetry_processors = []
super(AzureExporter, self).__init__(**options)
atexit.register(self._stop, self.options.grace_period)
heartbeat_metrics.enable_heartbeat_metrics(
self.options.connection_string, self.options.instrumentation_key)

def span_data_to_envelope(self, sd):
envelope = Envelope(
Expand Down
2 changes: 1 addition & 1 deletion contrib/opencensus-ext-azure/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
include_package_data=True,
long_description=open('README.rst').read(),
install_requires=[
'opencensus >= 0.7.11, < 1.0.0',
'opencensus >= 0.7.12, < 1.0.0',
'psutil >= 5.6.3',
'requests >= 2.19.0',
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,13 @@ def test_heartbeat_metric_init(self):
self.assertFalse(metric.init)
self.assertEqual(len(metric.properties), 0)

def test_heartbeat_metric_get_metric_init(self):
@mock.patch(
'requests.get',
throw(requests.exceptions.ConnectionError)
)
@mock.patch('os.environ.get')
def test_heartbeat_metric_get_metric_init(self, environ_mock):
environ_mock.return_value = None
metric = heartbeat_metrics.HeartbeatMetric()
self.assertFalse(metric.init)
metrics = metric.get_metrics()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ def test_new_metrics_exporter_no_standard_metrics(self, exporter_mock):
self.assertFalse(isinstance(exporter_mock.call_args[0][0][0],
producer_class))

@unittest.skip("Skip because disabling heartbeat metrics")
@mock.patch('opencensus.ext.azure.metrics_exporter'
'.transport.get_exporter_thread')
def test_new_metrics_exporter_heartbeat(self, exporter_mock):
Expand Down
18 changes: 10 additions & 8 deletions contrib/opencensus-ext-azure/tests/test_azure_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,14 @@ def test_invalid_key_section5_hex(self):
self.assertRaises(ValueError,
lambda: utils.validate_instrumentation_key(key))

def test_invalid_key_version(self):
key = '1234abcd-5678-6efa-8abc-1234567890ab'
self.assertRaises(ValueError,
lambda: utils.validate_instrumentation_key(key))
def test_valid_key_section2_hex(self):
key = '1234abcd-567a-4efa-8abc-1234567890ab'
self.assertIsNone(utils.validate_instrumentation_key(key))

def test_invalid_key_variant(self):
key = '1234abcd-5678-4efa-2abc-1234567890ab'
self.assertRaises(ValueError,
lambda: utils.validate_instrumentation_key(key))
def test_valid_key_section3_hex(self):
key = '1234abcd-5678-befa-8abc-1234567890ab'
self.assertIsNone(utils.validate_instrumentation_key(key))

def test_valid_key_section4_hex(self):
key = '1234abcd-5678-4efa-cabc-1234567890ab'
self.assertIsNone(utils.validate_instrumentation_key(key))
2 changes: 1 addition & 1 deletion contrib/opencensus-ext-datadog/examples/datadog.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

app = Flask(__name__)
middleware = FlaskMiddleware(app,
blacklist_paths=['/healthz'],
excludelist_paths=['/healthz'],
sampler=AlwaysOnSampler(),
exporter=DatadogTraceExporter(
Options(service='python-export-test',
Expand Down
6 changes: 6 additions & 0 deletions contrib/opencensus-ext-django/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## Unreleased

## 0.7.3
Released 2021-01-14

- Change blacklist to excludelist
([#977](https://github.com/census-instrumentation/opencensus-python/pull/977))

## 0.7.2
Released 2019-09-30

Expand Down
27 changes: 15 additions & 12 deletions contrib/opencensus-ext-django/opencensus/ext/django/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
REQUEST_THREAD_LOCAL_KEY = 'django_request'
SPAN_THREAD_LOCAL_KEY = 'django_span'

BLACKLIST_PATHS = 'BLACKLIST_PATHS'
BLACKLIST_HOSTNAMES = 'BLACKLIST_HOSTNAMES'
EXCLUDELIST_PATHS = 'EXCLUDELIST_PATHS'
EXCLUDELIST_HOSTNAMES = 'EXCLUDELIST_HOSTNAMES'

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -160,9 +160,12 @@ def __init__(self, get_response=None):
if isinstance(self.propagator, six.string_types):
self.propagator = configuration.load(self.propagator)

self.blacklist_paths = settings.get(BLACKLIST_PATHS, None)
self.excludelist_paths = settings.get(EXCLUDELIST_PATHS, None)

self.blacklist_hostnames = settings.get(BLACKLIST_HOSTNAMES, None)
self.excludelist_hostnames = settings.get(EXCLUDELIST_HOSTNAMES, None)

if django.VERSION >= (2,): # pragma: NO COVER
connection.execute_wrappers.append(_trace_db_call)

if django.VERSION >= (2,): # pragma: NO COVER
connection.execute_wrappers.append(_trace_db_call)
Expand All @@ -173,8 +176,8 @@ def process_request(self, request):
:type request: :class:`~django.http.request.HttpRequest`
:param request: Django http request.
"""
# Do not trace if the url is blacklisted
if utils.disable_tracing_url(request.path, self.blacklist_paths):
# Do not trace if the url is excludelisted
if utils.disable_tracing_url(request.path, self.excludelist_paths):
return

# Add the request to thread local
Expand All @@ -183,8 +186,8 @@ def process_request(self, request):
request)

execution_context.set_opencensus_attr(
'blacklist_hostnames',
self.blacklist_hostnames)
'excludelist_hostnames',
self.excludelist_hostnames)

try:
# Start tracing this request
Expand Down Expand Up @@ -234,8 +237,8 @@ def process_view(self, request, view_func, *args, **kwargs):
function name add set it as the span name.
"""

# Do not trace if the url is blacklisted
if utils.disable_tracing_url(request.path, self.blacklist_paths):
# Do not trace if the url is excludelisted
if utils.disable_tracing_url(request.path, self.excludelist_paths):
return

try:
Expand All @@ -248,8 +251,8 @@ def process_view(self, request, view_func, *args, **kwargs):
log.error('Failed to trace request', exc_info=True)

def process_response(self, request, response):
# Do not trace if the url is blacklisted
if utils.disable_tracing_url(request.path, self.blacklist_paths):
# Do not trace if the url is excludelisted
if utils.disable_tracing_url(request.path, self.excludelist_paths):
return response

try:
Expand Down
2 changes: 1 addition & 1 deletion contrib/opencensus-ext-django/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
long_description=open('README.rst').read(),
install_requires=[
'Django >= 1.11',
'opencensus >= 0.7.0, < 1.0.0',
'opencensus >= 0.7.12, < 1.0.0',
],
extras_require={},
license='Apache-2.0',
Expand Down
12 changes: 6 additions & 6 deletions contrib/opencensus-ext-django/tests/test_django_middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,17 +127,17 @@ def test_process_request(self):

self.assertEqual(span.name, 'mock.mock.Mock')

def test_blacklist_path(self):
def test_excludelist_path(self):
from opencensus.ext.django import middleware

execution_context.clear()

blacklist_paths = ['test_blacklist_path']
excludelist_paths = ['test_excludelist_path']
settings = type('Test', (object,), {})
settings.OPENCENSUS = {
'TRACE': {
'SAMPLER': 'opencensus.trace.samplers.AlwaysOnSampler()', # noqa
'BLACKLIST_PATHS': blacklist_paths,
'EXCLUDELIST_PATHS': excludelist_paths,
'EXPORTER': mock.Mock(),
}
}
Expand All @@ -148,11 +148,11 @@ def test_blacklist_path(self):
with patch_settings:
middleware_obj = middleware.OpencensusMiddleware()

django_request = RequestFactory().get('/test_blacklist_path')
django_request = RequestFactory().get('/test_excludelist_path')
disabled = utils.disable_tracing_url(django_request.path,
blacklist_paths)
excludelist_paths)
self.assertTrue(disabled)
self.assertEqual(middleware_obj.blacklist_paths, blacklist_paths)
self.assertEqual(middleware_obj.excludelist_paths, excludelist_paths)

# test process_request
middleware_obj.process_request(django_request)
Expand Down
2 changes: 1 addition & 1 deletion contrib/opencensus-ext-django/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.

__version__ = '0.7.2'
__version__ = '0.7.3'
Loading

0 comments on commit ea40da8

Please sign in to comment.