Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to set async and endpoint in enable #153

Merged
merged 2 commits into from Mar 18, 2019

Conversation

Projects
None yet
2 participants
@c-w
Copy link
Member

commented Mar 5, 2019

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:

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:

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:

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.

c-w and others added some commits Mar 1, 2019

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.

@SergeyKanzhelev SergeyKanzhelev merged commit 63b1c52 into microsoft:develop Mar 18, 2019

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
license/cla All CLA requirements met.
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.