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

Commit 5b064c9

Browse files
authored
GA for Azure exporter v1.0.0, minor Releases for certain packages (#792)
1 parent f109f0a commit 5b064c9

File tree

27 files changed

+559
-92
lines changed

27 files changed

+559
-92
lines changed

CHANGELOG.md

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22

33
## Unreleased
44

5+
## 0.7.4
6+
Released 2019-09-30
7+
8+
- Updated `azure` module
9+
([#773](https://github.com/census-instrumentation/opencensus-python/pull/773),
10+
[#767](https://github.com/census-instrumentation/opencensus-python/pull/767))
11+
12+
- Updated `django` module
13+
([#775](https://github.com/census-instrumentation/opencensus-python/pull/775))
14+
515
## 0.7.3
616
Released 2019-08-26
717

@@ -28,22 +38,6 @@ Released 2019-08-05
2838
## 0.7.0
2939
Released 2019-07-31
3040

31-
## 0.7.2
32-
Released 2019-08-16
33-
34-
- Fix GCP resource loading for certain environments
35-
([#761](https://github.com/census-instrumentation/opencensus-python/pull/761))
36-
37-
## 0.7.1
38-
Released 2019-08-05
39-
40-
- Added `set_status` to `span`
41-
([#738](https://github.com/census-instrumentation/opencensus-python/pull/738))
42-
- Update released stackdriver exporter version
43-
44-
## 0.7.0
45-
Released 2019-07-31
46-
4741
- Fix exporting int-valued stats with sum and lastvalue aggregations
4842
([#696](https://github.com/census-instrumentation/opencensus-python/pull/696))
4943
- Fix cloud format propagator to use decimal span_id encoding instead of hex

contrib/opencensus-ext-azure/CHANGELOG.md

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

33
## Unreleased
44

5+
## 1.0.0
6+
Released 2019-09-30
7+
8+
- Standard Metrics - Incoming requests execution time
9+
([#773](https://github.com/census-instrumentation/opencensus-python/pull/773))
10+
- Implement connection strings
11+
([#767](https://github.com/census-instrumentation/opencensus-python/pull/767))
12+
513
## 0.7.1
614
Released 2019-08-26
715

contrib/opencensus-ext-azure/README.rst

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ The **Azure Monitor Log Handler** allows you to export Python logs to `Azure Mon
2424
This example shows how to send a warning level log to Azure Monitor.
2525

2626
* Create an Azure Monitor resource and get the instrumentation key, more information can be found `here <https://docs.microsoft.com/azure/azure-monitor/app/create-new-resource>`_.
27-
* Put the instrumentation key in ``APPINSIGHTS_INSTRUMENTATIONKEY`` environment variable.
28-
* You can also specify the instrumentation key explicitly in the code, which will take priority over a set environment variable.
27+
* Place your instrumentation key in a `connection string` and directly into your code.
28+
* Alternatively, you can specify your `connection string` in an environment variable ``APPLICATIONINSIGHTS_CONNECTION_STRING``.
2929

3030
.. code:: python
3131
@@ -34,15 +34,16 @@ This example shows how to send a warning level log to Azure Monitor.
3434
from opencensus.ext.azure.log_exporter import AzureLogHandler
3535
3636
logger = logging.getLogger(__name__)
37-
logger.addHandler(AzureLogHandler())
37+
logger.addHandler(AzureLogHandler(connection_string='InstrumentationKey=<your-instrumentation_key-here>'))
3838
logger.warning('Hello, World!')
3939
40+
* Alternatively, you can specify your `connection string` in an environment variable ``APPLICATIONINSIGHTS_CONNECTION_STRING``.
41+
4042
You can enrich the logs with trace IDs and span IDs by using the `logging integration <../opencensus-ext-logging>`_.
4143

4244
* Create an Azure Monitor resource and get the instrumentation key, more information can be found `here <https://docs.microsoft.com/azure/azure-monitor/app/create-new-resource>`_.
43-
* Install the `logging integration package <../opencensus-ext-logging>`_ using ``pip install opencensus-ext-logging``.
44-
* Put the instrumentation key in ``APPINSIGHTS_INSTRUMENTATIONKEY`` environment variable.
45-
* You can also specify the instrumentation key explicitly in the code, which will take priority over a set environment variable.
45+
* Place your instrumentation key in a `connection string` and directly into your code.
46+
* Alternatively, you can specify your `connection string` in an environment variable ``APPLICATIONINSIGHTS_CONNECTION_STRING``.
4647

4748
.. code:: python
4849
@@ -58,25 +59,28 @@ You can enrich the logs with trace IDs and span IDs by using the `logging integr
5859
5960
logger = logging.getLogger(__name__)
6061
61-
handler = AzureLogHandler()
62+
handler = AzureLogHandler(connection_string='InstrumentationKey=<your-instrumentation_key-here>')
6263
handler.setFormatter(logging.Formatter('%(traceId)s %(spanId)s %(message)s'))
6364
logger.addHandler(handler)
6465
65-
tracer = Tracer(exporter=AzureExporter(), sampler=ProbabilitySampler(1.0))
66+
tracer = Tracer(
67+
exporter=AzureExporter(connection_string='InstrumentationKey=<your-instrumentation_key-here>'),
68+
sampler=ProbabilitySampler(1.0)
69+
)
6670
6771
logger.warning('Before the span')
6872
with tracer.span(name='test'):
6973
logger.warning('In the span')
70-
logger.warning('After the span')
74+
logger.warning('After the span')s
7175
7276
Metrics
7377
~~~~~~~
7478

7579
The **Azure Monitor Metrics Exporter** allows you to export metrics to `Azure Monitor`_.
7680

7781
* Create an Azure Monitor resource and get the instrumentation key, more information can be found `here <https://docs.microsoft.com/azure/azure-monitor/app/create-new-resource>`_.
78-
* Put the instrumentation key in ``APPINSIGHTS_INSTRUMENTATIONKEY`` environment variable.
79-
* You can also specify the instrumentation key explicitly in the code, which will take priority over a set environment variable.
82+
* Place your instrumentation key in a `connection string` and directly into your code.
83+
* Alternatively, you can specify your `connection string` in an environment variable ``APPLICATIONINSIGHTS_CONNECTION_STRING``.
8084

8185
.. code:: python
8286
@@ -105,7 +109,7 @@ The **Azure Monitor Metrics Exporter** allows you to export metrics to `Azure Mo
105109
def main():
106110
# Enable metrics
107111
# Set the interval in seconds in which you want to send metrics
108-
exporter = metrics_exporter.new_metrics_exporter()
112+
exporter = metrics_exporter.new_metrics_exporter(connection_string='InstrumentationKey=<your-instrumentation-key-here>')
109113
view_manager.register_exporter(exporter)
110114
111115
view_manager.register_view(CARROTS_VIEW)
@@ -138,7 +142,7 @@ The exporter also includes a set of standard metrics that are exported to Azure
138142
# All you need is the next line. You can disable standard metrics by
139143
# passing in enable_standard_metrics=False into the constructor of
140144
# new_metrics_exporter()
141-
_exporter = metrics_exporter.new_metrics_exporter()
145+
_exporter = metrics_exporter.new_metrics_exporter(connection_string='InstrumentationKey=<your-instrumentation-key-here>')
142146
143147
for i in range(100):
144148
print(psutil.virtual_memory())
@@ -154,6 +158,7 @@ Below is a list of standard metrics that are currently available:
154158
- Available Memory (bytes)
155159
- CPU Processor Time (percentage)
156160
- Incoming Request Rate (per second)
161+
- Incoming Request Average Execution Time (milliseconds)
157162
- Outgoing Request Rate (per second)
158163
- Process CPU Usage (percentage)
159164
- Process Private Bytes (bytes)
@@ -166,26 +171,31 @@ The **Azure Monitor Trace Exporter** allows you to export `OpenCensus`_ traces t
166171
This example shows how to send a span "hello" to Azure Monitor.
167172

168173
* Create an Azure Monitor resource and get the instrumentation key, more information can be found `here <https://docs.microsoft.com/azure/azure-monitor/app/create-new-resource>`_.
169-
* Put the instrumentation key in ``APPINSIGHTS_INSTRUMENTATIONKEY`` environment variable.
170-
* You can also specify the instrumentation key explicitly in the code, which will take priority over a set environment variable.
174+
* Place your instrumentation key in a `connection string` and directly into your code.
175+
* Alternatively, you can specify your `connection string` in an environment variable ``APPLICATIONINSIGHTS_CONNECTION_STRING``.
171176

172-
.. code:: python
177+
.. code:: python
173178
174179
from opencensus.ext.azure.trace_exporter import AzureExporter
175180
from opencensus.trace.samplers import ProbabilitySampler
176181
from opencensus.trace.tracer import Tracer
177182
178-
tracer = Tracer(exporter=AzureExporter(), sampler=ProbabilitySampler(1.0))
183+
tracer = Tracer(
184+
exporter=AzureExporter(connection_string='InstrumentationKey=<your-instrumentation-key-here>'),
185+
sampler=ProbabilitySampler(1.0)
186+
)
179187
180188
with tracer.span(name='hello'):
181189
print('Hello, World!')
182190
183-
You can also specify the instrumentation key explicitly in the code.
191+
OpenCensus also supports several [integrations](https://github.com/census-instrumentation/opencensus-python#integration) which allows OpenCensus to integrate with third party libraries.
192+
193+
This example shows how to integrate with the [requests](https://2.python-requests.org/en/master/) library.
184194

185195
* Create an Azure Monitor resource and get the instrumentation key, more information can be found `here <https://docs.microsoft.com/azure/azure-monitor/app/create-new-resource>`_.
186196
* Install the `requests integration package <../opencensus-ext-requests>`_ using ``pip install opencensus-ext-requests``.
187-
* Put the instrumentation key in ``APPINSIGHTS_INSTRUMENTATIONKEY`` environment variable.
188-
* You can also specify the instrumentation key explicitly in the code, which will take priority over a set environment variable.
197+
* Place your instrumentation key in a `connection string` and directly into your code.
198+
* Alternatively, you can specify your `connection string` in an environment variable ``APPLICATIONINSIGHTS_CONNECTION_STRING``.
189199

190200
.. code:: python
191201

contrib/opencensus-ext-azure/examples/logs/correlated.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@
2424

2525
logger = logging.getLogger(__name__)
2626

27-
# TODO: you need to specify the instrumentation key in the
28-
# APPINSIGHTS_INSTRUMENTATIONKEY environment variable.
27+
# TODO: you need to specify the instrumentation key in a connection string
28+
# and place it in the APPLICATIONINSIGHTS_CONNECTION_STRING
29+
# environment variable.
2930
handler = AzureLogHandler()
3031
logger.addHandler(handler)
3132

contrib/opencensus-ext-azure/examples/logs/error.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717
from opencensus.ext.azure.log_exporter import AzureLogHandler
1818

1919
logger = logging.getLogger(__name__)
20-
# TODO: you need to specify the instrumentation key in the
21-
# APPINSIGHTS_INSTRUMENTATIONKEY environment variable.
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.
2223
logger.addHandler(AzureLogHandler())
2324

2425

contrib/opencensus-ext-azure/examples/logs/simple.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
from opencensus.ext.azure.log_exporter import AzureLogHandler
1818

1919
logger = logging.getLogger(__name__)
20-
# TODO: you need to specify the instrumentation key in the
21-
# APPINSIGHTS_INSTRUMENTATIONKEY environment variable.
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.
2223
logger.addHandler(AzureLogHandler())
2324
logger.warning('Hello, World!')

contrib/opencensus-ext-azure/examples/metrics/simple.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@
3838
def main():
3939
# Enable metrics
4040
# Set the interval in seconds in which you want to send metrics
41+
# TODO: you need to specify the instrumentation key in a connection string
42+
# and place it in the APPLICATIONINSIGHTS_CONNECTION_STRING
43+
# environment variable.
4144
exporter = metrics_exporter.new_metrics_exporter()
4245
view_manager.register_exporter(exporter)
4346

contrib/opencensus-ext-azure/examples/metrics/standard.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919

2020

2121
def main():
22+
# TODO: you need to specify the instrumentation key in a connection string
23+
# and place it in the APPLICATIONINSIGHTS_CONNECTION_STRING
24+
# environment variable.
2225
# All you need is the next line. You can disable standard metrics by
2326
# passing in enable_standard_metrics=False into the constructor of
2427
# new_metrics_exporter()

contrib/opencensus-ext-azure/examples/metrics/sum.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@
3838
def main():
3939
# Enable metrics
4040
# Set the interval in seconds in which you want to send metrics
41+
# TODO: you need to specify the instrumentation key in a connection string
42+
# and place it in the APPLICATIONINSIGHTS_CONNECTION_STRING
43+
# environment variable.
4144
exporter = metrics_exporter.new_metrics_exporter()
4245
view_manager.register_exporter(exporter)
4346

contrib/opencensus-ext-azure/examples/traces/client.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@
2020
from opencensus.trace.tracer import Tracer
2121

2222
config_integration.trace_integrations(['requests'])
23-
# TODO: you need to specify the instrumentation key in the
24-
# APPINSIGHTS_INSTRUMENTATIONKEY environment variable.
23+
# TODO: you need to specify the instrumentation key in a connection string
24+
# and place it in the APPLICATIONINSIGHTS_CONNECTION_STRING
25+
# environment variable.
2526
tracer = Tracer(exporter=AzureExporter(), sampler=ProbabilitySampler(1.0))
2627
with tracer.span(name='parent'):
2728
with tracer.span(name='child'):

0 commit comments

Comments
 (0)