Skip to content

Commit

Permalink
Bump version for release to 0.7.6 (#819)
Browse files Browse the repository at this point in the history
  • Loading branch information
lzchen authored Nov 26, 2019
1 parent 3afd7bc commit 9ba948f
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 5 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

## Unreleased

## 0.7.6
Released 2019-11-26

- Initial release for `datadog` module
([#793](https://github.com/census-instrumentation/opencensus-python/pull/793))
- Updated `azure` module
([#789](https://github.com/census-instrumentation/opencensus-python/pull/789),
[#822](https://github.com/census-instrumentation/opencensus-python/pull/822))

## 0.7.5
Released 2019-10-01

Expand Down
4 changes: 3 additions & 1 deletion contrib/opencensus-ext-azure/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
## Unreleased

## 1.0.1
Released 2019-11-18
Released 2019-11-26

- Validate instrumentation key in Azure Exporters
([#789](https://github.com/census-instrumentation/opencensus-python/pull/789))
- Add optional custom properties to logging messages
([#822](https://github.com/census-instrumentation/opencensus-python/pull/822))

## 1.0.0
Released 2019-09-30
Expand Down
14 changes: 14 additions & 0 deletions contrib/opencensus-ext-azure/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,20 @@ You can enrich the logs with trace IDs and span IDs by using the `logging integr
logger.warning('In the span')
logger.warning('After the span')
You can also add custom properties to your log messages in the form of key-values.

WARNING: For this feature to work, you need to pass a dictionary as the argument. If you pass arguments of any other type, the logger will ignore them. The solution is to convert these arguments into a dictionary.

.. code:: python
import logging
from opencensus.ext.azure.log_exporter import AzureLogHandler
logger = logging.getLogger(__name__)
logger.addHandler(AzureLogHandler(connection_string='InstrumentationKey=<your-instrumentation_key-here>'))
logger.warning('action', {'key-1': 'value-1', 'key-2': 'value2'})
Metrics
~~~~~~~

Expand Down
24 changes: 24 additions & 0 deletions contrib/opencensus-ext-azure/examples/logs/properties.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright 2019, OpenCensus Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import logging

from opencensus.ext.azure.log_exporter import AzureLogHandler

logger = logging.getLogger(__name__)
# TODO: you need to specify the instrumentation key in a connection string
# and place it in the APPLICATIONINSIGHTS_CONNECTION_STRING
# environment variable.
logger.addHandler(AzureLogHandler())
logger.warning('action', {'key-1': 'value-1', 'key-2': 'value2'})
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ def log_record_to_envelope(self, record):
)
envelope.data = Data(baseData=data, baseType='ExceptionData')
else:
if isinstance(record.args, dict):
properties.update(record.args)
envelope.name = 'Microsoft.ApplicationInsights.Message'
data = Message(
message=self.format(record),
Expand Down
34 changes: 33 additions & 1 deletion contrib/opencensus-ext-azure/tests/test_azure_log_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@
# limitations under the License.

import logging
import mock
import os
import shutil
import unittest

import mock

from opencensus.ext.azure import log_exporter

TEST_FOLDER = os.path.abspath('.test.logs')
Expand Down Expand Up @@ -133,3 +134,34 @@ def test_log_record_to_envelope(self):
envelope.iKey,
'12345678-1234-5678-abcd-12345678abcd')
handler.close()

@mock.patch('requests.post', return_value=mock.Mock())
def test_log_record_with_custom_properties(self, requests_mock):
logger = logging.getLogger(self.id())
handler = log_exporter.AzureLogHandler(
instrumentation_key='12345678-1234-5678-abcd-12345678abcd',
storage_path=os.path.join(TEST_FOLDER, self.id()),
)
logger.addHandler(handler)
logger.warning('action', {'key-1': 'value-1', 'key-2': 'value-2'})
handler.close()
post_body = requests_mock.call_args_list[0][1]['data']
self.assertTrue('action' in post_body)
self.assertTrue('key-1' in post_body)
self.assertTrue('key-2' in post_body)

@mock.patch('requests.post', return_value=mock.Mock())
def test_log_with_invalid_custom_properties(self, requests_mock):
logger = logging.getLogger(self.id())
handler = log_exporter.AzureLogHandler(
instrumentation_key='12345678-1234-5678-abcd-12345678abcd',
storage_path=os.path.join(TEST_FOLDER, self.id()),
)
logger.addHandler(handler)
logger.warning('action_1_%s', None)
logger.warning('action_2_%s', 'not_a_dict')
handler.close()
self.assertEqual(len(os.listdir(handler.storage.path)), 0)
post_body = requests_mock.call_args_list[0][1]['data']
self.assertTrue('action_1' in post_body)
self.assertTrue('action_2' in post_body)
2 changes: 1 addition & 1 deletion contrib/opencensus-ext-datadog/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Unreleased

## 0.1.0
Released 2019-11-18
Released 2019-11-26

- Initial version
([#793](https://github.com/census-instrumentation/opencensus-python/pull/793))
2 changes: 1 addition & 1 deletion contrib/opencensus-ext-datadog/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
include_package_data=True,
install_requires=[
'bitarray >= 1.0.1, < 2.0.0',
'opencensus >= 0.7.5, < 1.0.0',
'opencensus >= 0.7.6, < 1.0.0',
'requests >= 2.19.0',
],
extras_require={},
Expand Down
2 changes: 1 addition & 1 deletion opencensus/common/version/__init__.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.5'
__version__ = '0.7.6'

0 comments on commit 9ba948f

Please sign in to comment.