Todos los productos
Search
Centro de documentos

Application Real-Time Monitoring Service:Reporte de datos de aplicaciones Python con SkyWalking

Última actualización: Sep 05, 2026

Después de instrumentar su aplicación con SkyWalking y enviar datos de rastreo distribuido a Managed Service for OpenTelemetry, Managed Service for OpenTelemetry comienza a monitorear su aplicación. Posteriormente, puede consultar diversos datos de monitoreo, como la topología de la aplicación, trazas, transacciones con errores, transacciones lentas y análisis de SQL. Este tema describe cómo usar el agente de SkyWalking para Python para habilitar la instrumentación automática y reportar los datos de la aplicación.

Requisitos previos

  • Ha descargado el agente de Python para Apache SkyWalking. Se recomienda utilizar la versión más reciente.

  • Ha agregado el agente de SkyWalking para Python a su proyecto de Python.

  • Obtención de un endpoint

    1. Inicie sesión en la consola de ARMS. En el panel de navegación izquierdo, haga clic en Integration Center.

    2. En la página Integration Center, haga clic en la tarjeta SkyWalking dentro de la sección Server-side Applications.

    3. En el panel SkyWalking, haga clic en la pestaña Start Integration y seleccione la región donde desea reportar los datos.

      Nota

      Al acceder a una región por primera vez, los recursos se inicializan automáticamente en dicha ubicación.

    4. Configure el parámetro Connection Type y copie un endpoint.

      Si su servicio está desplegado en Alibaba Cloud y reside en la región seleccionada, se recomienda establecer este parámetro en Alibaba Cloud VPC Network. De lo contrario, establézcalo en Public Network.

      image.png

Contexto

SkyWalking es una herramienta popular de código abierto para el monitoreo del rendimiento de aplicaciones (APM), diseñada para microservices y arquitecturas nativas de la nube o basadas en contenedores, como Docker, Kubernetes y Mesos. En esencia, SkyWalking funciona como un sistema de rastreo distribuido.

skywalking-python es la biblioteca oficial de agentes de Python para SkyWalking. Puede integrar skywalking-python para monitorear aplicaciones escritas en Python. Admite la instrumentación automática de numerosas bibliotecas de terceros, tales como Kafka, HTTP, AIOHTTP, Redis y WebSockets.

Bibliotecas de terceros compatibles

Biblioteca

Versión de Python - versión de la biblioteca

Nombre del plugin

aiohttp

Python ≥ 3.7 - 3.7.*

sw_aiohttp

aioredis

Python ≥ 3.7 - 2.0.*

sw_aioredis

aiormq

Python ≥ 3.7 - 6.3, 6.4

sw_aiormq

amqp

Python ≥ 3.7 - 2.6.1

sw_amqp

asyncpg

Python ≥ 3.7 - 0.25.0

sw_asyncpg

bottle

Python ≥ 3.7 - 0.12.23

sw_bottle

celery

Python ≥ 3.7 - 5.1

sw_celery

confluent_kafka

Python ≥ 3.7 - 1.5.0, 1.7.0, 1.8.2

sw_confluent_kafka

django

Python ≥ 3.7 - 3.2

sw_django

elasticsearch

Python ≥ 3.7 - 7.13, 7.14, 7.15

sw_elasticsearch

hug

Python ≥ 3.11 - No compatible

Python ≥ 3.10 - 2.5, 2.6

Python ≥ 3.7 - 2.4.1, 2.5, 2.6

sw_falcon

fastapi

Python ≥ 3.7 - 0.89., 0.88.

sw_fastapi

flask

Python ≥ 3.7 - 2.0

sw_flask

happybase

Python ≥ 3.7 - 1.2.0

sw_happybase

http_server

Python ≥ 3.7 - *

sw_http_server

werkzeug

Python ≥ 3.7 - 1.0.1, 2.0

sw_http_server

httpx

Python ≥ 3.7 - 0.23., 0.22.

sw_httpx

kafka-python

Python ≥ 3.7 - 2.0

sw_kafka

loguru

Python ≥ 3.7 - 0.6.0, 0.7.0

sw_loguru

mysqlclient

Python ≥ 3.7 - 2.1.*

sw_mysqlclient

neo4j

Python ≥ 3.7 - 5.*

sw_neo4j

psycopg[binary]

Python ≥ 3.11 - 3.1.*

Python ≥ 3.7 - 3.0.18, 3.1.*

sw_psycopg

psycopg2-binary

Python ≥ 3.10 - No compatible

Python ≥ 3.7 - 2.9

sw_psycopg2

pymongo

Python ≥ 3.7 - 3.11.*

sw_pymongo

pymysql

Python ≥ 3.7 - 1.0

sw_pymysql

pyramid

Python ≥ 3.7 - 1.10, 2.0

sw_pyramid

pika

Python ≥ 3.7 - 1.2

sw_rabbitmq

redis

Python ≥ 3.7 - 3.5.*, 4.5.1

sw_redis

requests

Python ≥ 3.7 - 2.26, 2.25

sw_requests

sanic

Python ≥ 3.10 - No compatible

Python ≥ 3.7 - 20.12

sw_sanic

tornado

Python ≥ 3.7 - 6.0, 6.1

sw_tornado

urllib3

Python ≥ 3.7 - 1.26, 1.25

sw_urllib3

urllib_request

Python ≥ 3.7 - *

sw_urllib_request

websockets

Python ≥ 3.7 - 10.3, 10.4

sw_websockets

Aplicación de ejemplo

Repositorio de la aplicación de ejemplo: Demostración de SkyWalking

Esta demostración es un ejemplo sencillo basado en Flask que reenvía solicitudes e interactúa con una base de datos MySQL. El agente de SkyWalking monitorea la aplicación y reporta los datos correspondientes.

Habilitación de la instrumentación automática para una aplicación de Python

Puede configurar los parámetros del agente de SkyWalking para Python directamente en los archivos de su proyecto o mediante variables de entorno.

Configuración de parámetros en el código

Modifique los parámetros de config.init en el archivo de su proyecto de Python. En la aplicación de ejemplo, los archivos correspondientes son proxy/TestProxy.py y controller/TestController.py.

from skywalking import config
config.init(ConfigurationName = ConfigurationValue)

Configuración de parámetros como variables de entorno

Agregue el siguiente contenido a su archivo de variables de entorno y reinicie la aplicación para que los cambios surtan efecto.

export SW_AGENT_ConfigurationName=ConfigurationValue
Nota

Para entornos de contenedores Docker, puede configurar las variables de entorno bajo la opción environment en el archivo docker-compose.yaml.

  1. Configure el endpoint y el token.

    1. Importe SkyWalking en su archivo de Python.

      from skywalking import agent, config
    2. Configure el endpoint y el token de autenticación.

      Reemplace <endpoint> y <auth-token> con el endpoint y el token de autenticación que obtuvo en la sección de requisitos previos.

      config.init(agent_collector_backend_services='<endpoint>',
                  agent_authentication='<auth-token>')
  2. Configure un nombre de servicio como identificador de la aplicación.

    config.init(agent_name='<service name>')
  3. Configure el protocolo de reporte de datos. El único protocolo compatible es gRPC.

    ### The only available reporting protocol is 'grpc'.
    config.init(agent_protocol='<protocol>')
  4. Configure otros parámetros opcionales según sea necesario. Para obtener más información, consulte la documentación oficial de Apache SkyWalking.

  5. Reinicie la aplicación.

Preguntas frecuentes

  • ¿Qué debo hacer si ocurre el error Method not found: skywalking.v3.LogReportService/collect al reportar datos mediante gRPC?

    grpc._channel._InactiveRpcError: &lt;_InactiveRpcError of RPC that terminated with:
        status = StatusCode.UNIMPLEMENTED
        details = &quot;Method not found: skywalking.v3.LogReportService/collect&quot;
        debug_error_string = &quot;UNKNOWN:Error received from peer  {grpc_message:&quot;Method not found: skywalking.v3.LogReportService/collect&quot;, grpc_status:12, created_time:&quot;2023-07-05T15:58:00&quot;}&quot;
    &gt;

    Establezca agent_log_reporter_active en False dentro de la llamada a config.init.

    config.init(agent_log_reporter_active=False)
  • ¿Qué debo hacer si ocurre el error Method not found: skywalking.v3.MeterReportService/collect al reportar datos mediante gRPC?

    grpc._channel._InactiveRpcError: &lt;_InactiveRpcError of RPC that terminated with:
            status = StatusCode.UNIMPLEMENTED
            details = &quot;Method not found: skywalking.v3.MeterReportService/collect&quot;
            debug_error_string = &quot;UNKNOWN:Error received from peer  {grpc_message:&quot;Method not found: skywalking.v3.MeterReportService/collect&quot;, grpc_status:12, created_time:&quot;2023-07-05T16:00:00+08:00&quot;}&quot;
    &gt;

    La consola no admite el reporte de datos de metric. En la llamada a config.init, establezca agent_meter_reporter_active en False.

    config.init(agent_meter_reporter_active=False)

Referencias

Sitio web oficial de Apache SkyWalking