Web frameworks in Python

Use the installation instructions below if you're installing Helios in a Python web framework.

Django

Install the latest Helios OpenTelemetry SDK:

pip install helios-opentelemetry-sdk

Under one of your Django project's apps, in the __init__.py file, paste the following code snippet:

from helios import initialize

initialize(
    api_token='<YOUR_API_TOKEN>', # TODO: Insert API Token here.
    service_name=<SERVICE_NAME>,  # TODO: Insert service name.
    enabled=True,                 # Defaults to False if omitted.
    environment=<ENVIRONMENT>,    # Defaults to os.environ.get('DEPLOYMENT_ENV') if omitted.
    commit_hash=<COMMIT_HASH>,    # Defaults to os.environ.get('COMMIT_HASH') if omitted.
)

FastAPI

Install the latest Helios OpenTelemetry SDK:

pip install helios-opentelemetry-sdk

On the module where you initialize your FastAPI app, add the following before the FastAPI call:

from fastapi import FastAPI
from helios import initialize

initialize(
    api_token='<YOUR_API_TOKEN>', # TODO: Insert API Token here.
    service_name=<SERVICE_NAME>,  # TODO: Insert service name.
    enabled=True,                 # Defaults to False if omitted.
    environment=<ENVIRONMENT>,    # Defaults to os.environ.get('DEPLOYMENT_ENV') if omitted.
    commit_hash=<COMMIT_HASH>,    # Defaults to os.environ.get('COMMIT_HASH') if omitted.
)

Only after initializing Helios, initialize your app:

app = FastAPI(__name__)

Flask

Install the latest Helios OpenTelemetry SDK:

pip install helios-opentelemetry-sdk

On the module where you initialize your Flask app, add the following before the Flask call:

from flask import Flask
from helios import initialize

initialize(
    api_token='<YOUR_API_TOKEN>', # TODO: Insert API Token here.
    service_name=<SERVICE_NAME>,  # TODO: Insert service name.
    enabled=True,                 # Defaults to False if omitted.
    environment=<ENVIRONMENT>,    # Defaults to os.environ.get('DEPLOYMENT_ENV') if omitted.
    commit_hash=<COMMIT_HASH>,    # Defaults to os.environ.get('COMMIT_HASH') if omitted.
)

Only after initializing Helios, initialize your app:

app = Flask(__name__)

πŸ‘

All set

After setup is complete and once the service is up and running, it will show up in the Helios application.


Did this page help you?