Граф коммитов

594 Коммитов

Автор SHA1 Сообщение Дата
Sergey Kanzhelev 037dbed615
Merge pull request #158 from CatalystCode/fix-flask-exception-logger
Avoid swallowing flask control-flow exceptions
2019-03-18 11:27:21 -07:00
Sergey Kanzhelev 8fb5a831c5
Merge branch 'develop' into fix-flask-exception-logger 2019-03-18 11:18:42 -07:00
Sergey Kanzhelev 0e29b77b23
Merge branch 'develop' into weakref 2019-03-18 11:15:56 -07:00
Sergey Kanzhelev af804cef0c
Merge pull request #150 from CatalystCode/log-level-in-enable
Add option to customize log level in enable
2019-03-18 11:15:41 -07:00
Sergey Kanzhelev 53d3c17655
Merge branch 'develop' into log-level-in-enable 2019-03-18 10:48:47 -07:00
Sergey Kanzhelev b71802a765
Merge pull request #154 from CatalystCode/add-queue-persistence-option
Add option to make the telemetry queue persistent
2019-03-18 10:47:33 -07:00
Sergey Kanzhelev a16b84ffd2
Merge branch 'develop' into add-queue-persistence-option 2019-03-18 10:47:09 -07:00
Clemens Wolff e4bf02e55a Add accessor for the Flask telemetry context
This enables use-cases to set custom properties to be sent along the
telemetry such as a user id or a role name.
2019-03-18 13:47:08 -04:00
Sergey Kanzhelev d7b5fdf4a9
Merge pull request #155 from CatalystCode/null-sender-async
Fix bug when NullSender is used with Async Queue
2019-03-18 10:46:48 -07:00
Clemens Wolff d5ca42601a Avoid swallowing flask control-flow exceptions
The Flask 1.0 release changed the semantics of
`@app.errorhandler(Exception)`.

Previously, this feature would catch application internal exceptions
only. Since the Flask 1.0 release, this now catches all exceptions,
including werkzeug's HTTPException which is used internally by Flask for
control flow, e.g. 404 not found, 403 forbidden, etc. The side-effect of
this change is that the AppInsights exception handler now translated
these control flow exceptions into uncaught exceptions, i.e. HTTP 500
errors.
2019-03-18 13:46:11 -04:00
Clemens Wolff fcebaa2581 Add option to make the telemetry queue persistent
Currently the Application Insights client SDK already has some great
resiliency built-in, e.g. retrying to send telemetry if there are
intermittent connectivity issues or service interruptions. However,
there still is a risk to lose telemetry if the app crashes before
sending telemetry since the telemetry queue is in-memory only.

This change adds an option to persist the queue to disk via the
[persist-queue](https://pypi.org/project/persist-queue/) module which
will protect customers against potential data loss, at the cost of a
slight loss in performance.
2019-03-08 13:50:54 -05:00
Clemens Wolff b22b1586cc Fix bug when NullSender is used with Async Queue
Currently the NullSender crashes when used in conjunction with
AsynchronousQueue since the AsynchronousQueue relies on some methods
that are not part of the SenderBase interface.

This limitation leads to unexpected behavior when for example using the
NullSender to avoid sending telemetry in an application when the
instrumentation key isn't configured in the environment.

This change makes the NullSender work with the AsynchronousQueue so that
the class can be used with both queues included in the SDK.
2019-03-07 12:47:06 -05:00
Clemens Wolff 289f8f055a Add option to set async and endpoint in enable
It's a very common use-case to set up AppInsights telemetry in a project
and customize the telemetry channel to be asynchronous; for example to
transparently integrate AppInsights into an existing daemon, worker
thread or webserver that already uses the logging module. It's currently
tedious if the user always has to write the same code over and over
again to import the AsynchronousQueue, AsynchronousSender,
TelemetryChannel, write them all up, before being able to pass them into
the enable function. As such, this change introduces a new shortcut that
lets the user specify async mode as a high-level concept on the enable
function.

This change simplifies the following code:

```py
from applicationinsights.logging import enable
from applicationinsights.channel import AsynchronousQueue
from applicationinsights.channel import AsynchronousSender
from applicationinsights.channel import TelemetryChannel

sender = AsynchronousSender()
queue = AsynchronousQueue(sender)
channel = TelemetryChannel(queue=queue)

enable('my-instrumentation-key', telemetry_channel=channel)
```

The new code is much nicer for the user:

```py
from applicationinsights.logging import enable

enable('my-instrumentation-key', async_=True)
```

As a companion to this new functionality, this change also introduces an
argument that lets the user customize the endpoint to which the
telemetry is being sent:

```py
from applicationinsights.logging import enable

enable('my-instrumentation-key', async_=True, endpoint='http://custom')
```

Together, the two new arguments raise the enable function to feature
parity with the other high level integrations (e.g. Django or Flask) in
terms of ease of developer use and high-level API.
2019-03-05 13:38:35 -05:00
Clemens Wolff 47f4313faa Fix memory leak in logging.enable
The `logging.enable` function caches references to the LoggingHandler
instances that it creates in a dictionary private to the module.

This means that references to the handler objects survive even if they
were removed from all loggers that referenced them, causing two
undesirable side-effects:

1) The LoggingHandler instances created by `logging.enable` can never be
   reclaimed by the garbage collector.

2) Removing all references to the LoggingHandler from the logger doesn't
   mark the instrumentation key as "no longer used".

This change fixes these issues by replacing the cache with a
WeakValueDictionary: as soon as the last reference to the LoggingHandler
is removed (e.g. when `some_logger.removeHandler(...)` is called), the
WeakValueDictionary will also evict its cached entry.
2019-03-01 14:08:00 -05:00
Clemens Wolff 552562b32b Add option to customize log level in enable
This removes an assumption that the log level should always be INFO by
enabling users to call the function like so:

```py
import logging
from applicationinsights.logging import enable

enable('my-instrumentation-key', level=logging.DEBUG)
```
2019-03-01 13:03:58 -05:00
Clemens Wolff fd1153a786 Ensure CI and PyPI Python versions match
The classifiers list in `setup.py` mentions support for Python 3.4 and
yet the CI on Travis doesn't run the tests on that version which means
that we can't be certain that the package works correctly on the
declared version.

To fix this discrepancy, this change makes the Python versions used
during CI match up with the Python versions declared in the classifiers
list.
2019-03-01 12:23:54 -05:00
Sergey Kanzhelev 419abf0055 community supported note 2019-02-01 16:14:39 -08:00
Sergey Kanzhelev 5866580ce8
Merge pull request #145 from RedSquirrelious/removeBrokenTests
no longer testing for removed async prop
2019-02-01 15:18:15 -08:00
Sergey Kanzhelev b030158d15
Merge branch 'develop' into removeBrokenTests 2019-02-01 15:13:39 -08:00
Sasha Pierson d229e78515 no longer testing for removed async prop 2019-02-01 14:49:03 -08:00
Sergey Kanzhelev 778f3186a9
Update CHANGELOG.md 2019-02-01 13:27:25 -08:00
Sergey Kanzhelev 520d11c58e
Merge pull request #144 from CatalystCode/default-endpoint-url
Extract constant for default sender endpoint
2019-02-01 13:26:50 -08:00
Clemens Wolff 75440df65e Extract constant for default sender endpoint
This change brings three main benefits:

1) Clients can now programmatically access the value of the default
   sender endpoint, for example to forward requests to it. This benefit
   is demonstrated by the changes to the test code.

2) Avoid copy/paste of the endpoint URL between async and sync senders.

3) Defaulting the service_endpoint_url to None instead of the string
   value and checking against null later to look up the default endpoint
   url means that the class now supports use-cases like
   `Sender(os.getenv('SERVICE_URL'))` which simplifies client code that
   may want to optionally override the service url. This benefit is
   demonstrated by the changes to the Django and Flask integrations.
2019-01-30 12:34:13 -05:00
Sergey Kanzhelev 3d1509ffb7
Merge pull request #141 from cclauss/patch-1
Use feature detection instead of version detection
2019-01-17 14:24:29 -08:00
Sergey Kanzhelev b6c0208d73
Merge branch 'develop' into patch-1 2019-01-14 08:53:38 -08:00
Sergey Kanzhelev c56df09ca0
Merge pull request #142 from cclauss/patch-2
Travis CI: Python 3.4 --> 3.6
2019-01-14 08:52:57 -08:00
cclauss e6e6625157
Travis CI: Python 3.4 --> 3.6
Python 3.4 will end of life in the coming weeks so let's start testing on a more up-to-date version.
* https://devguide.python.org/#branchstatus
2019-01-13 13:18:57 +01:00
cclauss eee279f58b
Use feature detection instead of version detection 2019-01-13 12:56:36 +01:00
Sergey Kanzhelev f98942ff6b
Merge pull request #132 from kd2718/add_api_link
Add api link
2018-12-14 13:25:10 -08:00
Sergey Kanzhelev cedafd9d35
Merge branch 'develop' into add_api_link 2018-12-14 13:25:02 -08:00
Sergey Kanzhelev 1cad9209ba
Merge pull request #133 from DefCon-007/readmefix
Fixes typo in readme
2018-12-14 13:24:33 -08:00
kd2718 9a6820fba9 Merge branch 'master' of github.com:Microsoft/ApplicationInsights-Python into add_api_link 2018-10-29 19:13:41 -07:00
Ayush Goyal 223bd1c4a4 Fixes typo in readme
Fixes #65
2018-10-02 17:36:09 +05:30
kd2718 f661619c52 fixed typo 2018-10-01 19:48:42 -07:00
kd2718 645f2be132 added link to documentation 2018-10-01 19:47:00 -07:00
Sergey Kanzhelev 838acbd897
Merge pull request #131 from Alhern/api-link
Added a link to the API docs in the README
2018-10-01 09:08:29 -07:00
Alhern 6729c06b4f added a link to the API docs 2018-10-01 11:27:53 +02:00
Sergey Kanzhelev 69d20e7dc6 update version to 0.11.8 2018-09-22 22:05:31 -07:00
Sergey Kanzhelev d1d53e1ea7
Merge pull request #130 from Microsoft/develop
prepare for 0.17 release
2018-09-22 21:41:55 -07:00
Sergey Kanzhelev 76803f346e
Merge branch 'master' into develop 2018-09-22 21:41:28 -07:00
Sergey Kanzhelev 33b0450aa8 removed unreleased note 2018-09-22 21:39:28 -07:00
Sergey Kanzhelev c099e4fff6
Merge pull request #126 from dstockhammer/track_dependency
Added track_dependency
2018-09-07 12:53:36 -07:00
Daniel Stockhammer 039eaa7bc6 resolve merge issues 2018-09-07 20:22:10 +01:00
Daniel Stockhammer 3131da6dfa remove type hints 2018-09-07 20:08:36 +01:00
Sergey Kanzhelev db066677bd
Merge branch 'develop' into track_dependency 2018-09-07 10:25:53 -07:00
Sergey Kanzhelev 44175e27b8
Merge pull request #125 from dstockhammer/request_id
Added optional request_id argument to track_request
2018-09-07 10:23:41 -07:00
Daniel Stockhammer 31e23088e2 Added optional request_id argument to track_request 2018-09-07 17:37:57 +01:00
Daniel Stockhammer da7f9a2a56 Added track_dependency 2018-09-07 17:36:53 +01:00
Sergey Kanzhelev 439f175cb4 bumping to the 0.11.7 2018-08-09 14:53:48 -07:00
Sergey Kanzhelev d5ea4c8efc
Merge pull request #122 from Microsoft/develop
releasing 0.11.6
2018-08-09 14:40:35 -07:00