Skip to content
This repository was archived by the owner on Sep 17, 2025. It is now read-only.

Commit 9ba948f

Browse files
authored
Bump version for release to 0.7.6 (#819)
1 parent 3afd7bc commit 9ba948f

File tree

9 files changed

+88
-5
lines changed

9 files changed

+88
-5
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
## Unreleased
44

5+
## 0.7.6
6+
Released 2019-11-26
7+
8+
- Initial release for `datadog` module
9+
([#793](https://github.com/census-instrumentation/opencensus-python/pull/793))
10+
- Updated `azure` module
11+
([#789](https://github.com/census-instrumentation/opencensus-python/pull/789),
12+
[#822](https://github.com/census-instrumentation/opencensus-python/pull/822))
13+
514
## 0.7.5
615
Released 2019-10-01
716

contrib/opencensus-ext-azure/CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
## Unreleased
44

55
## 1.0.1
6-
Released 2019-11-18
6+
Released 2019-11-26
77

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

1113
## 1.0.0
1214
Released 2019-09-30

contrib/opencensus-ext-azure/README.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,20 @@ You can enrich the logs with trace IDs and span IDs by using the `logging integr
7373
logger.warning('In the span')
7474
logger.warning('After the span')
7575
76+
You can also add custom properties to your log messages in the form of key-values.
77+
78+
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.
79+
80+
.. code:: python
81+
82+
import logging
83+
84+
from opencensus.ext.azure.log_exporter import AzureLogHandler
85+
86+
logger = logging.getLogger(__name__)
87+
logger.addHandler(AzureLogHandler(connection_string='InstrumentationKey=<your-instrumentation_key-here>'))
88+
logger.warning('action', {'key-1': 'value-1', 'key-2': 'value2'})
89+
7690
Metrics
7791
~~~~~~~
7892

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Copyright 2019, OpenCensus Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import logging
16+
17+
from opencensus.ext.azure.log_exporter import AzureLogHandler
18+
19+
logger = logging.getLogger(__name__)
20+
# TODO: you need to specify the instrumentation key in a connection string
21+
# and place it in the APPLICATIONINSIGHTS_CONNECTION_STRING
22+
# environment variable.
23+
logger.addHandler(AzureLogHandler())
24+
logger.warning('action', {'key-1': 'value-1', 'key-2': 'value2'})

contrib/opencensus-ext-azure/opencensus/ext/azure/log_exporter/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,8 @@ def log_record_to_envelope(self, record):
198198
)
199199
envelope.data = Data(baseData=data, baseType='ExceptionData')
200200
else:
201+
if isinstance(record.args, dict):
202+
properties.update(record.args)
201203
envelope.name = 'Microsoft.ApplicationInsights.Message'
202204
data = Message(
203205
message=self.format(record),

contrib/opencensus-ext-azure/tests/test_azure_log_exporter.py

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@
1313
# limitations under the License.
1414

1515
import logging
16-
import mock
1716
import os
1817
import shutil
1918
import unittest
2019

20+
import mock
21+
2122
from opencensus.ext.azure import log_exporter
2223

2324
TEST_FOLDER = os.path.abspath('.test.logs')
@@ -133,3 +134,34 @@ def test_log_record_to_envelope(self):
133134
envelope.iKey,
134135
'12345678-1234-5678-abcd-12345678abcd')
135136
handler.close()
137+
138+
@mock.patch('requests.post', return_value=mock.Mock())
139+
def test_log_record_with_custom_properties(self, requests_mock):
140+
logger = logging.getLogger(self.id())
141+
handler = log_exporter.AzureLogHandler(
142+
instrumentation_key='12345678-1234-5678-abcd-12345678abcd',
143+
storage_path=os.path.join(TEST_FOLDER, self.id()),
144+
)
145+
logger.addHandler(handler)
146+
logger.warning('action', {'key-1': 'value-1', 'key-2': 'value-2'})
147+
handler.close()
148+
post_body = requests_mock.call_args_list[0][1]['data']
149+
self.assertTrue('action' in post_body)
150+
self.assertTrue('key-1' in post_body)
151+
self.assertTrue('key-2' in post_body)
152+
153+
@mock.patch('requests.post', return_value=mock.Mock())
154+
def test_log_with_invalid_custom_properties(self, requests_mock):
155+
logger = logging.getLogger(self.id())
156+
handler = log_exporter.AzureLogHandler(
157+
instrumentation_key='12345678-1234-5678-abcd-12345678abcd',
158+
storage_path=os.path.join(TEST_FOLDER, self.id()),
159+
)
160+
logger.addHandler(handler)
161+
logger.warning('action_1_%s', None)
162+
logger.warning('action_2_%s', 'not_a_dict')
163+
handler.close()
164+
self.assertEqual(len(os.listdir(handler.storage.path)), 0)
165+
post_body = requests_mock.call_args_list[0][1]['data']
166+
self.assertTrue('action_1' in post_body)
167+
self.assertTrue('action_2' in post_body)

contrib/opencensus-ext-datadog/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## Unreleased
44

55
## 0.1.0
6-
Released 2019-11-18
6+
Released 2019-11-26
77

88
- Initial version
99
([#793](https://github.com/census-instrumentation/opencensus-python/pull/793))

contrib/opencensus-ext-datadog/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
include_package_data=True,
4040
install_requires=[
4141
'bitarray >= 1.0.1, < 2.0.0',
42-
'opencensus >= 0.7.5, < 1.0.0',
42+
'opencensus >= 0.7.6, < 1.0.0',
4343
'requests >= 2.19.0',
4444
],
4545
extras_require={},

opencensus/common/version/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
__version__ = '0.7.5'
15+
__version__ = '0.7.6'

0 commit comments

Comments
 (0)