Added Sphinx documentation generation.
This commit is contained in:
Родитель
8685077c71
Коммит
a1377605bc
|
@ -5,26 +5,55 @@ from applicationinsights import channel
|
|||
NULL_CONSTANT_STRING = 'Null'
|
||||
|
||||
class TelemetryClient(object):
|
||||
"""The telemetry client used for sending all types of telemetry. It serves as the main entry point for
|
||||
interacting with the Application Insights service.
|
||||
"""
|
||||
def __init__(self, telemetry_channel=None):
|
||||
"""Initializes a new instance of the TelemetryClient class."""
|
||||
"""Initializes a new instance of the class.
|
||||
|
||||
Args:
|
||||
telemetry_channel (:class:`channel.TelemetryChannel`) the optional telemetry channel to be used instead of
|
||||
constructing a default one.
|
||||
"""
|
||||
self._context = channel.TelemetryContext()
|
||||
self._channel = telemetry_channel or channel.TelemetryChannel()
|
||||
|
||||
@property
|
||||
def context(self):
|
||||
"""Gets the context associated with this telemetry client."""
|
||||
"""The context associated with this client. All data objects created by this client will be accompanied by
|
||||
this value.
|
||||
|
||||
Returns:
|
||||
:class:`channel.TelemetryChannel`. the context instance.
|
||||
"""
|
||||
return self._context
|
||||
|
||||
@property
|
||||
def channel(self):
|
||||
"""Gets the channel associated with this telemetry client."""
|
||||
"""The channel associated with this telemetry client. All data created by this client will be passed along with
|
||||
the :func:`context` object to :class:`channel.TelemetryChannel`'s :func:`write`.
|
||||
|
||||
Returns:
|
||||
:class:`channel.TelemetryChannel`. the channel instance.
|
||||
"""
|
||||
return self._channel
|
||||
|
||||
def flush(self):
|
||||
"""Flushes data in the queue. Data in the queue will be sent either immediately irrespective of what sender is
|
||||
being used.
|
||||
"""
|
||||
self._channel.flush()
|
||||
|
||||
def track_pageview(self, name, url, duration=0, properties=None, measurements=None):
|
||||
"""Send information about the page viewed in the application."""
|
||||
"""Send information about the page viewed in the application (a web page for instance).
|
||||
|
||||
Args:
|
||||
name (str). the name of the page that was viewed.\n
|
||||
url (str). the URL of the page that was viewed.\n
|
||||
duration (int). the duration of the page view in milliseconds. (defaults to: 0)\n
|
||||
properties (dict). the set of custom properties the client wants attached to this data item. (defaults to: None)\n
|
||||
measurements (dict). the set of custom measurements the client wants to attach to this data item. (defaults to: None)
|
||||
"""
|
||||
data = channel.contracts.PageViewData()
|
||||
data.name = name or NULL_CONSTANT_STRING
|
||||
data.url = url
|
||||
|
@ -37,7 +66,15 @@ class TelemetryClient(object):
|
|||
self._channel.write(data, self._context)
|
||||
|
||||
def track_exception(self, type=None, value=None, tb=None, properties=None, measurements=None):
|
||||
"""Send an ExceptionTelemetry object for display in Diagnostic Search."""
|
||||
""" Send information about a single exception that occurred in the application.
|
||||
|
||||
Args:
|
||||
type (Type). the type of the exception that was thrown.\n
|
||||
value (:class:`Exception`). the exception that the client wants to send.\n
|
||||
tb (:class:`Traceback`). the traceback information as returned by :func:`sys.exc_info`.\n
|
||||
properties (dict). the set of custom properties the client wants attached to this data item. (defaults to: None)\n
|
||||
measurements (dict). the set of custom measurements the client wants to attach to this data item. (defaults to: None)
|
||||
"""
|
||||
if not type or not value or not tb:
|
||||
type, value, tb = sys.exc_info()
|
||||
|
||||
|
@ -76,7 +113,13 @@ class TelemetryClient(object):
|
|||
self._channel.write(data, self._context)
|
||||
|
||||
def track_event(self, name, properties=None, measurements=None):
|
||||
"""Send an EventTelemetry object for display in Diagnostic Search and aggregation in Metrics Explorer."""
|
||||
""" Send information about a single event that has occurred in the context of the application.
|
||||
|
||||
Args:
|
||||
name (str). the data to associate to this event.\n
|
||||
properties (dict). the set of custom properties the client wants attached to this data item. (defaults to: None)\n
|
||||
measurements (dict). the set of custom measurements the client wants to attach to this data item. (defaults to: None)
|
||||
"""
|
||||
data = channel.contracts.EventData()
|
||||
data.name = name or NULL_CONSTANT_STRING
|
||||
if properties:
|
||||
|
@ -87,7 +130,18 @@ class TelemetryClient(object):
|
|||
self._channel.write(data, self._context)
|
||||
|
||||
def track_metric(self, name, value, type=None, count=None, min=None, max=None, std_dev=None, properties=None):
|
||||
"""Send a MetricTelemetry object for aggregation in Metric Explorer."""
|
||||
"""Send information about a single metric data point that was captured for the application.
|
||||
|
||||
Args:
|
||||
name (str). the name of the metric that was captured.\n
|
||||
value (float). the value of the metric that was captured.\n
|
||||
type (:class:`channel.contracts.DataPointType`). the type of the metric. (defaults to: :func:`channel.contracts.DataPointType.aggregation`)\n
|
||||
count (int). the number of metrics that were aggregated into this data point. (defaults to: None)\n
|
||||
min (float). the minimum of all metrics collected that were aggregated into this data point. (defaults to: None)\n
|
||||
max (float). the maximum of all metrics collected that were aggregated into this data point. (defaults to: None)\n
|
||||
std_dev (float). the standard deviation of all metrics collected that were aggregated into this data point. (defaults to: None)\n
|
||||
properties (dict). the set of custom properties the client wants attached to this data item. (defaults to: None)
|
||||
"""
|
||||
dataPoint = channel.contracts.DataPoint()
|
||||
dataPoint.name = name or NULL_CONSTANT_STRING
|
||||
dataPoint.value = value or 0
|
||||
|
@ -105,7 +159,12 @@ class TelemetryClient(object):
|
|||
self._channel.write(data, self._context)
|
||||
|
||||
def track_trace(self, name, properties=None):
|
||||
"""Send a trace message for display in Diagnostic Search."""
|
||||
"""Sends a single trace statement.
|
||||
|
||||
Args:
|
||||
name (str). the trace statement.\n
|
||||
properties (dict). the set of custom properties the client wants attached to this data item. (defaults to: None)
|
||||
"""
|
||||
data = channel.contracts.MessageData()
|
||||
data.message = name or NULL_CONSTANT_STRING
|
||||
if properties:
|
||||
|
|
|
@ -29,6 +29,9 @@ class AsynchronousSender(SenderBase):
|
|||
def send_interval(self):
|
||||
"""The time span in seconds at which the the worker thread will check the :func:`queue` for items (defaults to: 1.0).
|
||||
|
||||
Args:
|
||||
value (int) the interval in seconds.
|
||||
|
||||
Returns:
|
||||
int. the interval in seconds.
|
||||
"""
|
||||
|
@ -40,6 +43,9 @@ class AsynchronousSender(SenderBase):
|
|||
|
||||
Args:
|
||||
value (int) the interval in seconds.
|
||||
|
||||
Returns:
|
||||
int. the interval in seconds.
|
||||
"""
|
||||
self._send_interval = value
|
||||
|
||||
|
@ -47,6 +53,9 @@ class AsynchronousSender(SenderBase):
|
|||
def send_time(self):
|
||||
"""The time span in seconds at which the the worker thread will check the :func:`queue` for items (defaults to: 1.0).
|
||||
|
||||
Args:
|
||||
value (int) the interval in seconds.
|
||||
|
||||
Returns:
|
||||
int. the interval in seconds.
|
||||
"""
|
||||
|
@ -58,10 +67,15 @@ class AsynchronousSender(SenderBase):
|
|||
|
||||
Args:
|
||||
value (int) the interval in seconds.
|
||||
|
||||
Returns:
|
||||
int. the interval in seconds.
|
||||
"""
|
||||
self._send_time = value
|
||||
|
||||
def start(self):
|
||||
"""Starts a new sender thread if none is not already there
|
||||
"""
|
||||
with self._lock_send_remaining_time:
|
||||
if self._send_remaining_time <= 0.0:
|
||||
local_send_interval = self._send_interval
|
||||
|
@ -75,6 +89,8 @@ class AsynchronousSender(SenderBase):
|
|||
thread.start()
|
||||
|
||||
def stop(self):
|
||||
"""Gracefully stops the sender thread if one is there.
|
||||
"""
|
||||
with self._lock_send_remaining_time:
|
||||
self._send_remaining_time = 0.0
|
||||
|
||||
|
|
|
@ -28,6 +28,9 @@ class QueueBase(object):
|
|||
"""The maximum number of items that will be held by the queue before the queue will call the :func:`flush`
|
||||
method.
|
||||
|
||||
Args:
|
||||
value (int). the maximum queue length. The minimum allowed value is 1.
|
||||
|
||||
Returns:
|
||||
int. the maximum queue size. (defaults to: 500)
|
||||
"""
|
||||
|
@ -39,7 +42,10 @@ class QueueBase(object):
|
|||
method.
|
||||
|
||||
Args:
|
||||
value (int): The value for the maximum queue length. The minimum allowed value is 1.
|
||||
value (int): the maximum queue length. The minimum allowed value is 1.
|
||||
|
||||
Returns:
|
||||
int. the maximum queue size. (defaults to: 500)
|
||||
"""
|
||||
if value < 1:
|
||||
value = 1
|
||||
|
|
|
@ -30,6 +30,9 @@ class SenderBase(object):
|
|||
def service_endpoint_uri(self):
|
||||
"""The HTTP or HTTPS endpoint that this sender will send data to.
|
||||
|
||||
Args:
|
||||
value (str). the service endpoint URI.
|
||||
|
||||
Returns:
|
||||
str. the service endpoint URI.
|
||||
"""
|
||||
|
@ -40,7 +43,10 @@ class SenderBase(object):
|
|||
"""The service endpoint URI where this sender will send data to.
|
||||
|
||||
Args:
|
||||
value (str): the service endpoint URI.
|
||||
value (str). the service endpoint URI.
|
||||
|
||||
Returns:
|
||||
str. the service endpoint URI.
|
||||
"""
|
||||
self._service_endpoint_uri = value
|
||||
|
||||
|
@ -49,6 +55,9 @@ class SenderBase(object):
|
|||
"""The queue that this sender is draining. While :class:`SenderBase` doesn't implement any means of doing
|
||||
so, derivations of this class do.
|
||||
|
||||
Args:
|
||||
value (:class:`QueueBase`). the queue instance that this sender is draining.
|
||||
|
||||
Returns:
|
||||
:class:`QueueBase`. the queue instance that this sender is draining.
|
||||
"""
|
||||
|
@ -61,6 +70,9 @@ class SenderBase(object):
|
|||
|
||||
Args:
|
||||
value (:class:`QueueBase`). the queue instance that this sender is draining.
|
||||
|
||||
Returns:
|
||||
:class:`QueueBase`. the queue instance that this sender is draining.
|
||||
"""
|
||||
self._queue = value
|
||||
|
||||
|
@ -69,6 +81,9 @@ class SenderBase(object):
|
|||
"""The buffer size for a single batch of telemetry. This is the maximum number of items in a single service
|
||||
request that this sender is going to send.
|
||||
|
||||
Args:
|
||||
value (int). the maximum number of items in a telemetry batch.
|
||||
|
||||
Returns:
|
||||
int. the maximum number of items in a telemetry batch.
|
||||
"""
|
||||
|
@ -80,7 +95,10 @@ class SenderBase(object):
|
|||
request that this sender is going to send.
|
||||
|
||||
Args:
|
||||
value (int): the maximum number of items in a telemetry batch.
|
||||
value (int). the maximum number of items in a telemetry batch.
|
||||
|
||||
Returns:
|
||||
int. the maximum number of items in a telemetry batch.
|
||||
"""
|
||||
if value < 1:
|
||||
value = 1
|
||||
|
|
|
@ -5,6 +5,8 @@ class SynchronousQueue(QueueBase):
|
|||
:func:`send` on :func:`sender` when it reaches :func:`max_queue_length`, or when the consumer calls
|
||||
:func:`flush`.
|
||||
|
||||
.. code:: python
|
||||
|
||||
from application_insights.channel import SynchronousQueue
|
||||
queue = SynchronousQueue(None)
|
||||
queue.max_queue_length = 1
|
||||
|
|
|
@ -18,6 +18,8 @@ class TelemetryChannel(object):
|
|||
"""The telemetry channel is responsible for constructing a :class:`contracts.Envelope` object from the passed in
|
||||
data and specified telemetry context.
|
||||
|
||||
.. code:: python
|
||||
|
||||
from application_insights.channel import TelemetryChannel, contracts
|
||||
channel = TelemetryChannel()
|
||||
event = contracts.EventData()
|
||||
|
@ -28,7 +30,7 @@ class TelemetryChannel(object):
|
|||
"""Initializes a new instance of the class.
|
||||
|
||||
Args:
|
||||
context (:class:`TelemetryContext') the telemetry context to use when sending telemetry data.
|
||||
context (:class:`TelemetryContext') the telemetry context to use when sending telemetry data.\n
|
||||
queue (:class:`QueueBase`) the queue to enqueue the resulting :class:`contracts.Envelope` to.
|
||||
"""
|
||||
self._context = context or TelemetryContext()
|
||||
|
|
|
@ -19,6 +19,8 @@ contracts.Device._initialize = device_initialize
|
|||
class TelemetryContext(object):
|
||||
"""Represents the context for sending telemetry to the Application Insights service.
|
||||
|
||||
.. code:: python
|
||||
|
||||
context = TelemetryContext()
|
||||
context.instrumentation_key = '<YOUR INSTRUMENTATION KEY GOES HERE>'
|
||||
context.application.id = 'My application'
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
SPHINXOPTS =
|
||||
SPHINXBUILD = sphinx-build
|
||||
PAPER =
|
||||
BUILDDIR = _build
|
||||
BUILDDIR = build
|
||||
|
||||
# User-friendly check for sphinx-build
|
||||
ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
|
||||
|
|
|
@ -1,8 +1,169 @@
|
|||
.. toctree::
|
||||
:hidden:
|
||||
:maxdepth: 2
|
||||
:hidden:
|
||||
|
||||
applicationinsights
|
||||
|
||||
applicationinsights.channel.contracts module
|
||||
============================================
|
||||
|
||||
.. automodule:: applicationinsights.channel.contracts
|
||||
:members: Application, Data, DataPoint, DataPointType, DependencyKind, DependencySourceType, Device, Envelope, EventData, ExceptionData, ExceptionDetails, Internal, Location, MessageData, MetricData, Operation, PageViewData, RemoteDependencyData, RequestData, Session, SeverityLevel, StackFrame, User
|
||||
Application class
|
||||
-----------------
|
||||
.. autoclass:: applicationinsights.channel.contracts.Application
|
||||
:members:
|
||||
:member-order: groupwise
|
||||
:inherited-members:
|
||||
|
||||
Data class
|
||||
----------
|
||||
.. autoclass:: applicationinsights.channel.contracts.Data
|
||||
:members:
|
||||
:member-order: groupwise
|
||||
:inherited-members:
|
||||
|
||||
DataPoint class
|
||||
---------------
|
||||
.. autoclass:: applicationinsights.channel.contracts.DataPoint
|
||||
:members:
|
||||
:member-order: groupwise
|
||||
:inherited-members:
|
||||
|
||||
DataPointType class
|
||||
-------------------
|
||||
.. autoclass:: applicationinsights.channel.contracts.DataPointType
|
||||
:members:
|
||||
:member-order: groupwise
|
||||
:inherited-members:
|
||||
|
||||
DependencyKind class
|
||||
--------------------
|
||||
.. autoclass:: applicationinsights.channel.contracts.DependencyKind
|
||||
:members:
|
||||
:member-order: groupwise
|
||||
:inherited-members:
|
||||
|
||||
DependencySourceType class
|
||||
--------------------------
|
||||
.. autoclass:: applicationinsights.channel.contracts.DependencySourceType
|
||||
:members:
|
||||
:member-order: groupwise
|
||||
:inherited-members:
|
||||
|
||||
Device class
|
||||
------------
|
||||
.. autoclass:: applicationinsights.channel.contracts.Device
|
||||
:members:
|
||||
:member-order: groupwise
|
||||
:inherited-members:
|
||||
|
||||
Envelope class
|
||||
--------------
|
||||
.. autoclass:: applicationinsights.channel.contracts.Envelope
|
||||
:members:
|
||||
:member-order: groupwise
|
||||
:inherited-members:
|
||||
|
||||
EventData class
|
||||
---------------
|
||||
.. autoclass:: applicationinsights.channel.contracts.EventData
|
||||
:members:
|
||||
:member-order: groupwise
|
||||
:inherited-members:
|
||||
|
||||
ExceptionData class
|
||||
----------------------
|
||||
.. autoclass:: applicationinsights.channel.contracts.ExceptionData
|
||||
:members:
|
||||
:member-order: groupwise
|
||||
:inherited-members:
|
||||
|
||||
ExceptionDetails class
|
||||
----------------------
|
||||
.. autoclass:: applicationinsights.channel.contracts.ExceptionDetails
|
||||
:members:
|
||||
:member-order: groupwise
|
||||
:inherited-members:
|
||||
|
||||
Internal class
|
||||
--------------
|
||||
.. autoclass:: applicationinsights.channel.contracts.Internal
|
||||
:members:
|
||||
:member-order: groupwise
|
||||
:inherited-members:
|
||||
|
||||
Location class
|
||||
--------------
|
||||
.. autoclass:: applicationinsights.channel.contracts.Location
|
||||
:members:
|
||||
:member-order: groupwise
|
||||
:inherited-members:
|
||||
|
||||
MessageData class
|
||||
-----------------
|
||||
.. autoclass:: applicationinsights.channel.contracts.MessageData
|
||||
:members:
|
||||
:member-order: groupwise
|
||||
:inherited-members:
|
||||
|
||||
MetricData class
|
||||
----------------
|
||||
.. autoclass:: applicationinsights.channel.contracts.MetricData
|
||||
:members:
|
||||
:member-order: groupwise
|
||||
:inherited-members:
|
||||
|
||||
Operation class
|
||||
---------------
|
||||
.. autoclass:: applicationinsights.channel.contracts.Operation
|
||||
:members:
|
||||
:member-order: groupwise
|
||||
:inherited-members:
|
||||
|
||||
PageViewData class
|
||||
------------------
|
||||
.. autoclass:: applicationinsights.channel.contracts.PageViewData
|
||||
:members:
|
||||
:member-order: groupwise
|
||||
:inherited-members:
|
||||
|
||||
RemoteDependencyData class
|
||||
--------------------------
|
||||
.. autoclass:: applicationinsights.channel.contracts.RemoteDependencyData
|
||||
:members:
|
||||
:member-order: groupwise
|
||||
:inherited-members:
|
||||
|
||||
RequestData class
|
||||
-----------------
|
||||
.. autoclass:: applicationinsights.channel.contracts.RequestData
|
||||
:members:
|
||||
:member-order: groupwise
|
||||
:inherited-members:
|
||||
|
||||
Session class
|
||||
-------------
|
||||
.. autoclass:: applicationinsights.channel.contracts.Session
|
||||
:members:
|
||||
:member-order: groupwise
|
||||
:inherited-members:
|
||||
|
||||
SeverityLevel class
|
||||
-------------------
|
||||
.. autoclass:: applicationinsights.channel.contracts.SeverityLevel
|
||||
:members:
|
||||
:member-order: groupwise
|
||||
:inherited-members:
|
||||
|
||||
StackFrame class
|
||||
----------------
|
||||
.. autoclass:: applicationinsights.channel.contracts.StackFrame
|
||||
:members:
|
||||
:member-order: groupwise
|
||||
:inherited-members:
|
||||
|
||||
User class
|
||||
----------
|
||||
.. autoclass:: applicationinsights.channel.contracts.User
|
||||
:members:
|
||||
:member-order: groupwise
|
||||
:inherited-members:
|
||||
|
|
|
@ -1,10 +1,65 @@
|
|||
.. toctree::
|
||||
:hidden:
|
||||
:maxdepth: 2
|
||||
:hidden:
|
||||
|
||||
applicationinsights.channel.contracts
|
||||
applicationinsights.channel.contracts
|
||||
|
||||
applicationinsights.channel module
|
||||
==================================
|
||||
|
||||
.. automodule:: applicationinsights.channel
|
||||
:members: QueueBase, SenderBase, SynchronousQueue, SynchronousBase, AsynchronousQueue, AsynchronousSender, TelemetryChannel, TelemetryContext
|
||||
SynchronousQueue class
|
||||
----------------------
|
||||
.. autoclass:: applicationinsights.channel.SynchronousQueue
|
||||
:members:
|
||||
:member-order: groupwise
|
||||
:inherited-members:
|
||||
|
||||
SynchronousSender class
|
||||
-----------------------
|
||||
.. autoclass:: applicationinsights.channel.SynchronousSender
|
||||
:members:
|
||||
:member-order: groupwise
|
||||
:inherited-members:
|
||||
|
||||
AsynchronousQueue class
|
||||
-----------------------
|
||||
.. autoclass:: applicationinsights.channel.AsynchronousQueue
|
||||
:members:
|
||||
:member-order: groupwise
|
||||
:inherited-members:
|
||||
|
||||
AsynchronousSender class
|
||||
------------------------
|
||||
.. autoclass:: applicationinsights.channel.AsynchronousSender
|
||||
:members:
|
||||
:member-order: groupwise
|
||||
:inherited-members:
|
||||
|
||||
QueueBase class
|
||||
---------------
|
||||
.. autoclass:: applicationinsights.channel.QueueBase
|
||||
:members:
|
||||
:member-order: groupwise
|
||||
:inherited-members:
|
||||
|
||||
SenderBase class
|
||||
----------------
|
||||
.. autoclass:: applicationinsights.channel.SenderBase
|
||||
:members:
|
||||
:member-order: groupwise
|
||||
:inherited-members:
|
||||
|
||||
TelemetryChannel class
|
||||
----------------------
|
||||
.. automodule:: applicationinsights.channel.TelemetryChannel
|
||||
:members:
|
||||
:member-order: groupwise
|
||||
:inherited-members:
|
||||
|
||||
TelemetryContext class
|
||||
----------------------
|
||||
.. autoclass:: applicationinsights.channel.TelemetryContext
|
||||
:members:
|
||||
:member-order: groupwise
|
||||
:inherited-members:
|
||||
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
.. toctree::
|
||||
:hidden:
|
||||
:maxdepth: 2
|
||||
:hidden:
|
||||
|
||||
applicationinsights.channel
|
||||
applicationinsights.channel
|
||||
|
||||
applicationinsights module
|
||||
==========================
|
||||
|
||||
.. automodule:: applicationinsights
|
||||
:members: TelemetryClient
|
||||
TelemetryClient class
|
||||
----------------------
|
||||
.. autoclass:: applicationinsights.TelemetryClient
|
||||
:members:
|
||||
:member-order: groupwise
|
||||
:inherited-members:
|
||||
|
|
18
doc/conf.py
18
doc/conf.py
|
@ -39,7 +39,7 @@ extensions = [
|
|||
]
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['_templates']
|
||||
templates_path = [ 'templates' ]
|
||||
|
||||
# The suffix of source filenames.
|
||||
source_suffix = '.rst'
|
||||
|
@ -59,9 +59,9 @@ copyright = '2014, Microsoft'
|
|||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = '0.3.0'
|
||||
version = '0.5.0'
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = '0.3.0'
|
||||
release = '0.5.0'
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
|
@ -78,7 +78,7 @@ language = None
|
|||
|
||||
# List of patterns, relative to source directory, that match files and
|
||||
# directories to ignore when looking for source files.
|
||||
exclude_patterns = ['_build']
|
||||
exclude_patterns = [ 'build' ]
|
||||
|
||||
# The reST default role (used for this markup: `text`) to use for all
|
||||
# documents.
|
||||
|
@ -138,7 +138,7 @@ html_theme = 'default'
|
|||
# Add any paths that contain custom static files (such as style sheets) here,
|
||||
# relative to this directory. They are copied after the builtin static files,
|
||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||
html_static_path = ['_static']
|
||||
html_static_path = [ 'static' ]
|
||||
|
||||
# Add any extra paths that contain custom files (such as robots.txt or
|
||||
# .htaccess) here, relative to this directory. These files are copied
|
||||
|
@ -161,7 +161,7 @@ html_static_path = ['_static']
|
|||
#html_additional_pages = {}
|
||||
|
||||
# If false, no module index is generated.
|
||||
#html_domain_indices = True
|
||||
html_domain_indices = False
|
||||
|
||||
# If false, no index is generated.
|
||||
#html_use_index = True
|
||||
|
@ -223,8 +223,7 @@ latex_elements = {
|
|||
# (source start file, target name, title,
|
||||
# author, documentclass [howto, manual, or own class]).
|
||||
latex_documents = [
|
||||
('index', 'ApplicationInsightsSDKforPython.tex', 'Application Insights SDK for Python Documentation',
|
||||
'Microsoft', 'manual'),
|
||||
('index', 'ApplicationInsightsSDKforPython.tex', 'Application Insights SDK for Python Documentation', 'Microsoft', 'manual'),
|
||||
]
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top of
|
||||
|
@ -253,8 +252,7 @@ latex_documents = [
|
|||
# One entry per manual page. List of tuples
|
||||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [
|
||||
('index', 'applicationinsightssdkforpython', 'Application Insights SDK for Python Documentation',
|
||||
['Microsoft'], 1)
|
||||
('index', 'applicationinsightssdkforpython', 'Application Insights SDK for Python Documentation', ['Microsoft'], 1)
|
||||
]
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
|
|
386
doc/index.rst
386
doc/index.rst
|
@ -1,181 +1,205 @@
|
|||
.. Application Insights SDK for Python documentation master file, created by
|
||||
sphinx-quickstart on Mon Dec 22 23:32:45 2014.
|
||||
You can adapt this file completely to your liking, but it should at least
|
||||
contain the root `toctree` directive.
|
||||
|
||||
.. toctree::
|
||||
:hidden:
|
||||
|
||||
applicationinsights
|
||||
applicationinsights.channel
|
||||
|
||||
Application Insights SDK for Python
|
||||
===================================
|
||||
|
||||
| Python is an easy to learn, powerful programming language. It has efficient high-level data structures and a simple but effective approach to object-oriented programming. Python's elegant syntax and dynamic typing, together with its interpreted nature, make it an ideal language for scripting and rapid application development in many areas on most platforms.
|
||||
| -- \ `The Python Tutorial - Introduction <https://docs.python.org/3/tutorial/>`__\
|
||||
|
||||
This project extends the Application Insights API surface to support Python. `Application
|
||||
Insights <http://azure.microsoft.com/en-us/services/application-insights/>`__ is a service that allows developers to keep their application available, performing and succeeding. This Python module will allow you to send telemetry of various kinds (event, trace, exception, etc.) to the Application Insights service where they can be visualized in the Azure Portal.
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
Python 2.7 and Python 3.4 are currently supported by this module.
|
||||
|
||||
For opening the project in Microsoft Visual Studio you will need `Python Tools for Visual Studio <http://pytools.codeplex.com/>`__.
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
To install the latest release you can use `pip <http://www.pip-installer.org/>`__.
|
||||
|
||||
::
|
||||
|
||||
$ pip install applicationinsights
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
Once installed, you can send telemetry to Application Insights. Here are a few samples.
|
||||
|
||||
**Note**: before you can send data to you will need an instrumentation key. Please see the `Getting an Application Insights
|
||||
Instrumentation Key <https://github.com/Microsoft/AppInsights-Home/wiki#getting-an-application-insights-instrumentation-key>`__
|
||||
section for more information.
|
||||
|
||||
**Sending a simple event telemetry item**
|
||||
|
||||
.. code:: python
|
||||
|
||||
from applicationinsights import TelemetryClient
|
||||
tc = TelemetryClient()
|
||||
tc.context.instrumentation_key = '<YOUR INSTRUMENTATION KEY GOES HERE>'
|
||||
tc.track_event("Test event")
|
||||
tc.flush()
|
||||
|
||||
**Sending an event telemetry item with custom properties and measurements**
|
||||
|
||||
.. code:: python
|
||||
|
||||
from applicationinsights import TelemetryClient
|
||||
tc = TelemetryClient()
|
||||
tc.context.instrumentation_key = '<YOUR INSTRUMENTATION KEY GOES HERE>'
|
||||
tc.track_event('Test event', { 'foo': 'bar' }, { 'baz': 42 })
|
||||
tc.flush()
|
||||
|
||||
**Sending a trace telemetry item with custom properties**
|
||||
|
||||
.. code:: python
|
||||
|
||||
from applicationinsights import TelemetryClient
|
||||
tc = TelemetryClient()
|
||||
tc.context.instrumentation_key = '<YOUR INSTRUMENTATION KEY GOES HERE>'
|
||||
tc.track_trace('Test trace', { 'foo': 'bar' })
|
||||
tc.flush()
|
||||
|
||||
**Sending a metric telemetry item**
|
||||
|
||||
.. code:: python
|
||||
|
||||
from applicationinsights import TelemetryClient
|
||||
tc = TelemetryClient()
|
||||
tc.context.instrumentation_key = '<YOUR INSTRUMENTATION KEY GOES HERE>'
|
||||
tc.track_metric('My Metric', 42)
|
||||
tc.flush()
|
||||
|
||||
**Sending an exception telemetry item with custom properties and measurements**
|
||||
|
||||
.. code:: python
|
||||
|
||||
import sys
|
||||
from applicationinsights import TelemetryClient
|
||||
tc = TelemetryClient()
|
||||
tc.context.instrumentation_key = '<YOUR INSTRUMENTATION KEY GOES HERE>'
|
||||
try:
|
||||
raise Exception('blah')
|
||||
except:
|
||||
tc.track_exception()
|
||||
|
||||
try:
|
||||
raise Exception("blah")
|
||||
except:
|
||||
tc.track_exception(*sys.exc_info(), properties={ 'foo': 'bar' }, measurements={ 'x': 42 })
|
||||
|
||||
tc.flush()
|
||||
|
||||
**Configuring context for a telemetry client instance**
|
||||
|
||||
.. code:: python
|
||||
|
||||
from applicationinsights import TelemetryClient
|
||||
tc = TelemetryClient()
|
||||
tc.context.instrumentation_key = '<YOUR INSTRUMENTATION KEY GOES HERE>'
|
||||
tc.context.application.id = 'My application'
|
||||
tc.context.application.ver = '1.2.3'
|
||||
tc.context.device.id = 'My current device'
|
||||
tc.context.device.oem_name = 'Asus'
|
||||
tc.context.device.model = 'X31A'
|
||||
tc.context.device.type = "Other"
|
||||
tc.context.user.id = 'santa@northpole.net'
|
||||
tc.track_trace('My trace with context')
|
||||
tc.flush()
|
||||
|
||||
**Configuring channel related properties**
|
||||
|
||||
.. code:: python
|
||||
|
||||
from applicationinsights import TelemetryClient
|
||||
tc = TelemetryClient()
|
||||
# flush telemetry every 30 seconds (assuming we don't hit max_queue_item_count first)
|
||||
tc.channel.sender.send_interval_in_milliseconds = 30 * 1000
|
||||
# flush telemetry if we have 10 or more telemetry items in our queue
|
||||
tc.channel.sender.max_queue_item_count = 10
|
||||
|
||||
**Configuring synchronous (default) channel properties**
|
||||
|
||||
.. code:: python
|
||||
|
||||
from applicationinsights import TelemetryClient
|
||||
tc = TelemetryClient()
|
||||
# flush telemetry if we have 10 or more telemetry items in our queue
|
||||
tc.channel.queue.max_queue_length = 10
|
||||
# send telemetry to the service in batches of 5
|
||||
tc.channel.sender.send_buffer_size = 5
|
||||
|
||||
**Configuring an asynchronous channel instead of the synchronous default**
|
||||
|
||||
.. code:: python
|
||||
|
||||
from applicationinsights import TelemetryClient, channel
|
||||
sender = channel.AsynchronousSender()
|
||||
queue = channel.AsynchronousQueue(sender)
|
||||
channel = channel::TelemetryChannel(None, queue)
|
||||
tc = TelemetryClient(channel)
|
||||
# Note: the event will be sent on a separate thread; if the app finishes before
|
||||
# the thread finishes, the data is lost
|
||||
tc.track_event('My event')
|
||||
|
||||
**Configuring asynchronous channel properties**
|
||||
|
||||
.. code:: python
|
||||
|
||||
from applicationinsights import TelemetryClient, channel
|
||||
sender = channel.AsynchronousSender()
|
||||
queue = channel.AsynchronousQueue(sender)
|
||||
channel = channel::TelemetryChannel(None, queue)
|
||||
tc = TelemetryClient(channel)
|
||||
# flush telemetry if we have 10 or more telemetry items in our queue
|
||||
tc.channel.queue.max_queue_length = 10
|
||||
# send telemetry to the service in batches of 5
|
||||
tc.channel.sender.send_buffer_size = 5
|
||||
# the background worker thread will be active for 5 seconds before it shuts down. if
|
||||
# during this time items are picked up from the queue, the timer is reset.
|
||||
tc.channel.sender.send_time = 5
|
||||
# the background worker thread will poll the queue every 0.5 seconds for new items
|
||||
tc.channel.sender.send_interval = 0.5
|
||||
|
||||
|
||||
* :ref:`genindex`
|
||||
* :ref:`modindex`
|
||||
* :ref:`search`
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
:hidden:
|
||||
|
||||
applicationinsights
|
||||
|
||||
Application Insights SDK for Python
|
||||
===================================
|
||||
|
||||
.. sidebar:: Usage
|
||||
|
||||
Once installed, you can send telemetry to Application Insights. Here are a few samples.
|
||||
|
||||
* :ref:`Sending a simple event telemetry item <usage-sample-01>`
|
||||
* :ref:`Sending an event telemetry item with custom properties and measurements <usage-sample-02>`
|
||||
* :ref:`Sending a trace telemetry item with custom properties <usage-sample-03>`
|
||||
* :ref:`Sending a metric telemetry item <usage-sample-04>`
|
||||
* :ref:`Sending an exception telemetry item with custom properties and measurements <usage-sample-05>`
|
||||
* :ref:`Configuring context for a telemetry client instance <usage-sample-06>`
|
||||
* :ref:`Configuring channel related properties <usage-sample-07>`
|
||||
* :ref:`Configuring synchronous (default) channel properties <usage-sample-08>`
|
||||
* :ref:`Configuring an asynchronous channel instead of the synchronous default <usage-sample-09>`
|
||||
* :ref:`Configuring asynchronous channel properties <usage-sample-10>`
|
||||
|
||||
| Python is an easy to learn, powerful programming language. It has efficient high-level data structures and a simple but effective approach to object-oriented programming. Python's elegant syntax and dynamic typing, together with its interpreted nature, make it an ideal language for scripting and rapid application development in many areas on most platforms.
|
||||
| -- \ `The Python Tutorial - Introduction <https://docs.python.org/3/tutorial/>`__\
|
||||
|
||||
This project extends the Application Insights API surface to support Python. `Application
|
||||
Insights <http://azure.microsoft.com/en-us/services/application-insights/>`__ is a service that allows developers to keep their application available, performing and succeeding. This Python module will allow you to send telemetry of various kinds (event, trace, exception, etc.) to the Application Insights service where they can be visualized in the Azure Portal.
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
Python 2.7 and Python 3.4 are currently supported by this module.
|
||||
|
||||
For opening the project in Microsoft Visual Studio you will need `Python Tools for Visual Studio <http://pytools.codeplex.com/>`__.
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
To install the latest release you can use `pip <http://www.pip-installer.org/>`__.
|
||||
|
||||
::
|
||||
|
||||
$ pip install applicationinsights
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
Once installed, you can send telemetry to Application Insights. Here are a few samples.
|
||||
|
||||
**Note**: before you can send data to you will need an instrumentation key. Please see the `Getting an Application Insights
|
||||
Instrumentation Key <https://github.com/Microsoft/AppInsights-Home/wiki#getting-an-application-insights-instrumentation-key>`__
|
||||
section for more information.
|
||||
|
||||
.. _usage-sample-01:
|
||||
|
||||
**Sending a simple event telemetry item**
|
||||
|
||||
.. code:: python
|
||||
|
||||
from applicationinsights import TelemetryClient
|
||||
tc = TelemetryClient()
|
||||
tc.context.instrumentation_key = '<YOUR INSTRUMENTATION KEY GOES HERE>'
|
||||
tc.track_event("Test event")
|
||||
tc.flush()
|
||||
|
||||
.. _usage-sample-02:
|
||||
|
||||
**Sending an event telemetry item with custom properties and measurements**
|
||||
|
||||
.. code:: python
|
||||
|
||||
from applicationinsights import TelemetryClient
|
||||
tc = TelemetryClient()
|
||||
tc.context.instrumentation_key = '<YOUR INSTRUMENTATION KEY GOES HERE>'
|
||||
tc.track_event('Test event', { 'foo': 'bar' }, { 'baz': 42 })
|
||||
tc.flush()
|
||||
|
||||
.. _usage-sample-03:
|
||||
|
||||
**Sending a trace telemetry item with custom properties**
|
||||
|
||||
.. code:: python
|
||||
|
||||
from applicationinsights import TelemetryClient
|
||||
tc = TelemetryClient()
|
||||
tc.context.instrumentation_key = '<YOUR INSTRUMENTATION KEY GOES HERE>'
|
||||
tc.track_trace('Test trace', { 'foo': 'bar' })
|
||||
tc.flush()
|
||||
|
||||
.. _usage-sample-04:
|
||||
|
||||
**Sending a metric telemetry item**
|
||||
|
||||
.. code:: python
|
||||
|
||||
from applicationinsights import TelemetryClient
|
||||
tc = TelemetryClient()
|
||||
tc.context.instrumentation_key = '<YOUR INSTRUMENTATION KEY GOES HERE>'
|
||||
tc.track_metric('My Metric', 42)
|
||||
tc.flush()
|
||||
|
||||
.. _usage-sample-05:
|
||||
|
||||
**Sending an exception telemetry item with custom properties and measurements**
|
||||
|
||||
.. code:: python
|
||||
|
||||
import sys
|
||||
from applicationinsights import TelemetryClient
|
||||
tc = TelemetryClient()
|
||||
tc.context.instrumentation_key = '<YOUR INSTRUMENTATION KEY GOES HERE>'
|
||||
try:
|
||||
raise Exception('blah')
|
||||
except:
|
||||
tc.track_exception()
|
||||
|
||||
try:
|
||||
raise Exception("blah")
|
||||
except:
|
||||
tc.track_exception(*sys.exc_info(), properties={ 'foo': 'bar' }, measurements={ 'x': 42 })
|
||||
|
||||
tc.flush()
|
||||
|
||||
.. _usage-sample-06:
|
||||
|
||||
**Configuring context for a telemetry client instance**
|
||||
|
||||
.. code:: python
|
||||
|
||||
from applicationinsights import TelemetryClient
|
||||
tc = TelemetryClient()
|
||||
tc.context.instrumentation_key = '<YOUR INSTRUMENTATION KEY GOES HERE>'
|
||||
tc.context.application.id = 'My application'
|
||||
tc.context.application.ver = '1.2.3'
|
||||
tc.context.device.id = 'My current device'
|
||||
tc.context.device.oem_name = 'Asus'
|
||||
tc.context.device.model = 'X31A'
|
||||
tc.context.device.type = "Other"
|
||||
tc.context.user.id = 'santa@northpole.net'
|
||||
tc.track_trace('My trace with context')
|
||||
tc.flush()
|
||||
|
||||
.. _usage-sample-07:
|
||||
|
||||
**Configuring channel related properties**
|
||||
|
||||
.. code:: python
|
||||
|
||||
from applicationinsights import TelemetryClient
|
||||
tc = TelemetryClient()
|
||||
# flush telemetry every 30 seconds (assuming we don't hit max_queue_item_count first)
|
||||
tc.channel.sender.send_interval_in_milliseconds = 30 * 1000
|
||||
# flush telemetry if we have 10 or more telemetry items in our queue
|
||||
tc.channel.sender.max_queue_item_count = 10
|
||||
|
||||
.. _usage-sample-08:
|
||||
|
||||
**Configuring synchronous (default) channel properties**
|
||||
|
||||
.. code:: python
|
||||
|
||||
from applicationinsights import TelemetryClient
|
||||
tc = TelemetryClient()
|
||||
# flush telemetry if we have 10 or more telemetry items in our queue
|
||||
tc.channel.queue.max_queue_length = 10
|
||||
# send telemetry to the service in batches of 5
|
||||
tc.channel.sender.send_buffer_size = 5
|
||||
|
||||
.. _usage-sample-09:
|
||||
|
||||
**Configuring an asynchronous channel instead of the synchronous default**
|
||||
|
||||
.. code:: python
|
||||
|
||||
from applicationinsights import TelemetryClient, channel
|
||||
sender = channel.AsynchronousSender()
|
||||
queue = channel.AsynchronousQueue(sender)
|
||||
channel = channel::TelemetryChannel(None, queue)
|
||||
tc = TelemetryClient(channel)
|
||||
# Note: the event will be sent on a separate thread; if the app finishes before
|
||||
# the thread finishes, the data is lost
|
||||
tc.track_event('My event')
|
||||
|
||||
.. _usage-sample-10:
|
||||
|
||||
**Configuring asynchronous channel properties**
|
||||
|
||||
.. code:: python
|
||||
|
||||
from applicationinsights import TelemetryClient, channel
|
||||
sender = channel.AsynchronousSender()
|
||||
queue = channel.AsynchronousQueue(sender)
|
||||
channel = channel::TelemetryChannel(None, queue)
|
||||
tc = TelemetryClient(channel)
|
||||
# flush telemetry if we have 10 or more telemetry items in our queue
|
||||
tc.channel.queue.max_queue_length = 10
|
||||
# send telemetry to the service in batches of 5
|
||||
tc.channel.sender.send_buffer_size = 5
|
||||
# the background worker thread will be active for 5 seconds before it shuts down. if
|
||||
# during this time items are picked up from the queue, the timer is reset.
|
||||
tc.channel.sender.send_time = 5
|
||||
# the background worker thread will poll the queue every 0.5 seconds for new items
|
||||
tc.channel.sender.send_interval = 0.5
|
||||
|
|
|
@ -5,7 +5,7 @@ REM Command file for Sphinx documentation
|
|||
if "%SPHINXBUILD%" == "" (
|
||||
set SPHINXBUILD=sphinx-build
|
||||
)
|
||||
set BUILDDIR=_build
|
||||
set BUILDDIR=build
|
||||
set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% .
|
||||
set I18NSPHINXOPTS=%SPHINXOPTS% .
|
||||
if NOT "%PAPER%" == "" (
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
div.bodywrapper {
|
||||
margin: 0px 0px 0px 265px;
|
||||
}
|
||||
|
||||
div.sphinxsidebar {
|
||||
width: 265px;
|
||||
}
|
||||
|
||||
div.sphinxsidebar #searchbox input[type="text"] {
|
||||
width: 205px;
|
||||
}
|
||||
|
||||
dl.method dl.docutils dd p {
|
||||
margin-bottom: 0;
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
{# layout.html #}
|
||||
{# Import the theme's layout. #}
|
||||
{% extends "!layout.html" %}
|
||||
|
||||
{% set css_files = css_files + [ '_static/overrides.css' ] %}
|
Загрузка…
Ссылка в новой задаче