Skip to content

Commit

Permalink
Release/v0.11.2 (#1195)
Browse files Browse the repository at this point in the history
  • Loading branch information
lzchen authored Mar 10, 2023
1 parent 1ff11ef commit e32462c
Show file tree
Hide file tree
Showing 34 changed files with 613 additions and 85 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ on:

jobs:
build:
# 18.04 needed for python3.4
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
env:
# We use these variables to convert between tox and GHA version literals
py27: 2.7
Expand Down
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.11.2
Released 2023-03-10

- Updated `azure`, `fastapi`,`flask` modules

# 0.11.1
Released 2023-01-18

Expand Down
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ Trace Exporter
.. _Datadog: https://github.com/census-instrumentation/opencensus-python/tree/master/contrib/opencensus-ext-datadog
.. _Django: https://github.com/census-instrumentation/opencensus-python/tree/master/contrib/opencensus-ext-django
.. _Flask: https://github.com/census-instrumentation/opencensus-python/tree/master/contrib/opencensus-ext-flask
.. _FastAPI: https://github.com/census-instrumentation/opencensus-python/tree/master/contrib/opencensus-ext-fastapi
.. _gevent: https://github.com/census-instrumentation/opencensus-python/tree/master/contrib/opencensus-ext-gevent
.. _Google Cloud Client Libraries: https://github.com/census-instrumentation/opencensus-python/tree/master/contrib/opencensus-ext-google-cloud-clientlibs
.. _gRPC: https://github.com/census-instrumentation/opencensus-python/tree/master/contrib/opencensus-ext-grpc
Expand Down
9 changes: 9 additions & 0 deletions contrib/opencensus-ext-azure/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

## Unreleased

## 1.1.9

Released 2023-03-10

- Fix export of exception information in traces
([#1187](https://github.com/census-instrumentation/opencensus-python/pull/1187))
- Modify metrics exporter to include setting export interval to 60s
([#1193](https://github.com/census-instrumentation/opencensus-python/pull/1193))

## 1.1.8

Released 2023-01-18
Expand Down
24 changes: 16 additions & 8 deletions contrib/opencensus-ext-azure/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,11 @@ The **Azure Monitor Metrics Exporter** allows you to export metrics to `Azure Mo
def main():
# Enable metrics
# Set the interval in seconds in which you want to send metrics
exporter = metrics_exporter.new_metrics_exporter(connection_string='InstrumentationKey=<your-instrumentation-key-here>')
# Set the interval in seconds to 60s, which is the time interval application insights
# aggregates your metrics
exporter = metrics_exporter.new_metrics_exporter(
connection_string='InstrumentationKey=<your-instrumentation-key-here>'
)
view_manager.register_exporter(exporter)
view_manager.register_view(CARROTS_VIEW)
Expand All @@ -176,7 +179,6 @@ The **Azure Monitor Metrics Exporter** allows you to export metrics to `Azure Mo
mmap.measure_int_put(CARROTS_MEASURE, 1000)
mmap.record(tmap)
# Default export interval is every 15.0s
print("Done recording metrics")
Expand All @@ -196,10 +198,13 @@ The exporter also includes a set of performance counters that are exported to Az
from opencensus.ext.azure import metrics_exporter
def main():
# All you need is the next line. You can disable performance counters by
# Performance counters are sent by default. You can disable performance counters by
# passing in enable_standard_metrics=False into the constructor of
# new_metrics_exporter()
_exporter = metrics_exporter.new_metrics_exporter(connection_string='InstrumentationKey=<your-instrumentation-key-here>')
_exporter = metrics_exporter.new_metrics_exporter(
connection_string='InstrumentationKey=<your-instrumentation-key-here>',
export_interval=60,
)
for i in range(100):
print(psutil.virtual_memory())
Expand Down Expand Up @@ -256,8 +261,12 @@ Modifying Metrics
def main():
# Enable metrics
# Set the interval in seconds in which you want to send metrics
exporter = metrics_exporter.new_metrics_exporter(connection_string='InstrumentationKey=<your-instrumentation-key-here>')
# Set the interval in seconds to 60s, which is the time interval application insights
# aggregates your metrics
exporter = metrics_exporter.new_metrics_exporter(
connection_string='InstrumentationKey=<your-instrumentation-key-here>',
export_interval=60,
)
exporter.add_telemetry_processor(callback_function)
view_manager.register_exporter(exporter)
Expand All @@ -267,7 +276,6 @@ Modifying Metrics
mmap.measure_int_put(CARROTS_MEASURE, 1000)
mmap.record(tmap)
# Default export interval is every 15.0s
print("Done recording metrics")
Expand Down
14 changes: 8 additions & 6 deletions contrib/opencensus-ext-azure/examples/metrics/simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import os

from opencensus.ext.azure import metrics_exporter
from opencensus.stats import aggregation as aggregation_module
from opencensus.stats import measure as measure_module
Expand All @@ -34,12 +36,12 @@


def main():
# Enable metrics
# Set the interval in seconds in which you want to send metrics
# TODO: you need to specify the instrumentation key in a connection string
# and place it in the APPLICATIONINSIGHTS_CONNECTION_STRING
# environment variable.
exporter = metrics_exporter.new_metrics_exporter()
# Enable metrics. Set the interval in seconds to 60s, which is the time
# interval application insights aggregates your metrics
exporter = metrics_exporter.new_metrics_exporter(
connection_string=os.environ["APPLICATIONINSIGHTS_CONNECTION_STRING"],
export_interval=60,
)
view_manager.register_exporter(exporter)

view_manager.register_view(CARROTS_VIEW)
Expand Down
40 changes: 0 additions & 40 deletions contrib/opencensus-ext-azure/examples/metrics/standard.py

This file was deleted.

13 changes: 7 additions & 6 deletions contrib/opencensus-ext-azure/examples/metrics/sum.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import os
import time

from opencensus.ext.azure import metrics_exporter
Expand All @@ -36,12 +37,12 @@


def main():
# Enable metrics
# Set the interval in seconds in which you want to send metrics
# TODO: you need to specify the instrumentation key in a connection string
# and place it in the APPLICATIONINSIGHTS_CONNECTION_STRING
# environment variable.
exporter = metrics_exporter.new_metrics_exporter()
# Enable metrics. Set the interval in seconds to 60s, which is the time
# interval application insights aggregates your metrics
exporter = metrics_exporter.new_metrics_exporter(
connection_string=os.environ["APPLICATIONINSIGHTS_CONNECTION_STRING"],
export_interval=60,
)
view_manager.register_exporter(exporter)

view_manager.register_view(NUM_REQUESTS_VIEW)
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.1.8'
__version__ = '1.1.9'
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ def span_data_to_envelope(self, sd):
)
if sd.span_kind == SpanKind.SERVER:
if ERROR_MESSAGE in sd.attributes:
envelope.name = 'Microsoft.ApplicationInsights.Exception'
exc_env = Envelope(**envelope)
exc_env.name = 'Microsoft.ApplicationInsights.Exception'
data = ExceptionData(
exceptions=[{
'id': 1,
Expand All @@ -107,8 +108,8 @@ def span_data_to_envelope(self, sd):
'parsedStack': sd.attributes.get(STACKTRACE, None)
}],
)
envelope.data = Data(baseData=data, baseType='ExceptionData')
yield envelope
exc_env.data = Data(baseData=data, baseType='ExceptionData')
yield exc_env

envelope.name = 'Microsoft.ApplicationInsights.Request'
data = Request(
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 @@ -43,7 +43,7 @@
install_requires=[
'azure-core >= 1.12.0, < 2.0.0',
'azure-identity >= 1.5.0, < 2.0.0',
'opencensus >= 0.11.1, < 1.0.0',
'opencensus >= 0.11.2, < 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 @@ -498,7 +498,7 @@ def test_span_data_to_envelope(self):
'RequestData')

# SpanKind.SERVER HTTP - with exceptions
envelopes = exporter.span_data_to_envelope(SpanData(
envelopes = list(exporter.span_data_to_envelope(SpanData(
name='test',
context=SpanContext(
trace_id='6e0c63257de34c90bf9efcd03927272e',
Expand Down Expand Up @@ -529,9 +529,10 @@ def test_span_data_to_envelope(self):
same_process_as_parent_span=None,
child_span_count=None,
span_kind=SpanKind.SERVER,
))
)))
self.assertEqual(len(envelopes), 2)

envelope = next(envelopes)
envelope = envelopes[0]
self.assertEqual(
envelope.iKey,
'12345678-1234-5678-abcd-12345678abcd')
Expand All @@ -551,7 +552,7 @@ def test_span_data_to_envelope(self):
envelope.data.baseType,
'ExceptionData')

envelope = next(envelopes)
envelope = envelopes[1]
self.assertEqual(
envelope.iKey,
'12345678-1234-5678-abcd-12345678abcd')
Expand Down
10 changes: 10 additions & 0 deletions contrib/opencensus-ext-fastapi/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Changelog

## Unreleased

## 0.1.0

Released 2023-03-10

- Initial version
([#1124](https://github.com/census-instrumentation/opencensus-python/pull/1124))
50 changes: 50 additions & 0 deletions contrib/opencensus-ext-fastapi/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
OpenCensus FastAPI Integration
============================================================================

|pypi|

.. |pypi| image:: https://badge.fury.io/py/opencensus-ext-fastapi.svg
:target: https://pypi.org/project/opencensus-ext-fastapi/

Installation
------------

::

pip install opencensus-ext-fastapi

Usage
-----

.. code:: python
from fastapi import FastAPI
from opencensus.ext.fastapi.fastapi_middleware import FastAPIMiddleware
app = FastAPI(__name__)
app.add_middleware(FastAPIMiddleware)
@app.get('/')
def hello():
return 'Hello World!'
Additional configuration can be provided, please read
`Customization <https://github.com/census-instrumentation/opencensus-python#customization>`_
for a complete reference.

.. code:: python
app.add_middleware(
FastAPIMiddleware,
excludelist_paths=["paths"],
excludelist_hostnames=["hostnames"],
sampler=sampler,
exporter=exporter,
propagator=propagator,
)
References
----------

* `OpenCensus Project <https://opencensus.io/>`_
1 change: 1 addition & 0 deletions contrib/opencensus-ext-fastapi/opencensus/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
1 change: 1 addition & 0 deletions contrib/opencensus-ext-fastapi/opencensus/ext/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
Loading

0 comments on commit e32462c

Please sign in to comment.