Python agent

The Python Agent discovers, maps, and tracks metrics for transactions, app services, and backend in your web application by injecting instrumentation into the Python application at runtime. You can also extend your performance monitoring to collect and analyze business data to help you improve the customer experience and to make data-driven business decisions. With flexible options for custom instrumentation and APIs, it offers multiple building blocks to customize the data you need.

System Requirements for Installation

  • Python3 (version 3.5 and above) is required 

Prerequisites

  • For prerequisite checks for agent installation, see Prerequisite checks for agent installation.
  • SixthSense Python Agent See Installing the agent.
  • URL/IP of the Sixthsense collector (your tenant URL which will be provided by Customer Support)
  • Access token - For accessing the token, see Accessing your Access Token under Getting started with the Observability Portal.
  • Variables
    • PACKAGE_TOKEN - Access Token required for downloading SixthSense Package provided by Customer Support.
    • PACKAGE_TOKEN_USERNAME - Username for Access Token provided by Customer Support.
    • TOKEN - Access Token from the SixthSense portal. See Accessing your Access Token under Getting started with the Observability Portal.

Installing the agent

Use the variables mentioned to install the agent.

pip install sixthsense --extra-index-url https://${PACKAGE_TOKEN_USERNAME}:${PACKAGE_TOKEN}@artifacts-observability.sixthsense.rakuten.com/api/v4/projects/2/packages/pypi/simple

Configuring the Python agent

Copy and paste the below configuration to the top of your main application file. Add the $TOKEN to the environment file or add it manually to the configuration.

from sixthsense import agent, config
serviceName="My_SERVICE_NAME"
config.init(collector=grpc-collector-observability.sixthsense.rakuten.com:443,service=serviceName, token=token_from_ui)
agent.start()

Naming an application

  • Name your application.

Example:

serviceName=My_SERVICE_NAME
serviceName=my-python-app (here application/service name is "my-python-app" )

Example:

from sixthsense import agent, config
serviceName="my-python-app"
config.init(collector='grpc-collector-observability.sixthsense.rakuten.com:443', service=serviceName, //for token passed in environment add// token=os.getenv('TOKEN'))
agent.start()

For OneCloud Platform, use the following example:

from sixthsense import agent, config
serviceName="my-python-app"
# For connectivity to backend using onecloud private network: 100.99.116.221:80
# For pconnectivity to backend using intra public network: 133.237.176.44:80
config.init(collector='133.237.176.44:80',secured=false, service=serviceName, token=os.getenv('TOKEN'))

Installing on Docker

  • Before you build your Docker image, follow all the instructions mentioned earlier and deploy the Docker.

Example:

FROM python:3.8-slim
RUN apt-get update -qqy && \
apt-get -qqy install wget g++ && \
rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY requirement.txt requirement.txt
ARG TOKEN
RUN pip install sixthsense --extra-index-url https://agent_read:${TOKEN}@artifacts-observability.sixthsense.rakuten.com/api/v4/projects/2/packages/pypi/simple
RUN pip install -r requirement.txt
COPY . .
EXPOSE 5000
ENTRYPOINT ["python", "/app/app.py"]

Python Frameworks and Protocols

LibraryVersionPlugin Name
1http.serverPython 3.5 ~ 3.8sw_http_server
2urllib.requestPython 3.5 ~ 3.8sw_urllib_request
3requests>= 2.9.0 < 2.15.0, >= 2.17.0 <= 2.24.0sw_requests
4Flask>=1.0.4 <= 1.1.2sw_flask
5PyMySQL0.10.0sw_pymysql
6Django>=2.0 <= 3.1sw_django
7redis-py3.5.3sw_redis
8kafka-python2.0.1sw_kafka
9tornado6.0.4sw_tornado
10pika1.1.0sw_rabbitmq
11pymongo3.11.0sw_pymongo
12elasticsearch7.9.0sw_elasticsearch
13urllib3>= 1.25.9 <= 1.25.10sw_urllib3