Skip to main content

SkyWalking Python Agent

Sky Walking logo

SkyWalking-Python: The Python Agent for Apache SkyWalking, which provides the native tracing abilities for Python project.

SkyWalking: an APM(application performance monitor) system, especially designed for microservices, cloud native and container-based (Docker, Kubernetes, Mesos) architectures.

GitHub stars Twitter Follow

Build

Set up Python Agent

SkyWalking Python SDK requires SkyWalking 8.0+.

If you want to try out the latest features that're not released yet, please refer to the guide to build from sources.

from skywalking import agent, config

config.init(collector='127.0.0.1:11800', service='your awesome service')
agent.start()

Alternatively, you can also pass the configurations via environment variables and you don't need to call config.init.

The supported environment variables are as follows:

Environment Variable Description Default
SW_AGENT_NAME The name of the Python service Python Service Name
SW_AGENT_INSTANCE The name of the Python service instance Randomly generated
SW_AGENT_COLLECTOR_BACKEND_SERVICES The backend OAP server address 127.0.0.1:11800
SW_AGENT_PROTOCOL The protocol to communicate with the backend OAP, http or grpc, we highly suggest using grpc in production as it's well optimized than http grpc
SW_AGENT_AUTHENTICATION The authentication token to verify that the agent is trusted by the backend OAP, as for how to configure the backend, refer to the yaml. not set
SW_AGENT_LOGGING_LEVEL The logging level, could be one of CRITICAL, FATAL, ERROR, WARN(WARNING), INFO, DEBUG INFO
SW_AGENT_DISABLE_PLUGINS The name patterns in CSV pattern, plugins whose name matches one of the pattern won't be installed ''

Supported Libraries

There're some built-in plugins that support automatic instrumentation of Python libraries, the complete lists are as follow:

Library Plugin Name
http.server sw_http_server
urllib.request sw_urllib_request
requests requests

API

Apart from the libraries that can be instrumented automatically, we also provide some APIs to enable manual instrumentation.

Create Spans

The code snippet below shows how to create entry span, exit span and local span.

from skywalking import Component
from skywalking.trace.context import SpanContext, get_context
from skywalking.trace.tags import Tag

context: SpanContext = get_context()  # get a tracing context
# create an entry span, by using `with` statement,
# the span automatically starts/stops when entering/exiting the context
with context.new_entry_span(op='https://github.com/apache') as span:
    span.component = Component.Flask
# the span automatically stops when exiting the `with` context

with context.new_exit_span(op='https://github.com/apache', peer='localhost:8080') as span:
    span.component = Component.Flask

with context.new_local_span(op='https://github.com/apache') as span:
    span.tag(Tag(key='Singer', val='Nakajima'))

Decorators

from time import sleep

from skywalking import Component
from skywalking.decorators import trace
from skywalking.trace.context import SpanContext, get_context

@trace()  # the operation name is the method name('some_other_method') by default
def some_other_method():
    sleep(1)


@trace(op='awesome')  # customize the operation name to 'awesome'
def some_method():
    some_other_method()


context: SpanContext = get_context()
with context.new_entry_span(op=str('https://github.com/apache/skywalking')) as span:
    span.component = Component.Flask
    some_method()

FAQs

Check the FAQ page or add the FAQs there.

License

Apache 2.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

apache-skywalking-0.1.0.tar.gz (26.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

apache_skywalking-0.1.0-py3-none-any.whl (73.3 kB view details)

Uploaded Python 3

File details

Details for the file apache-skywalking-0.1.0.tar.gz.

File metadata

  • Download URL: apache-skywalking-0.1.0.tar.gz
  • Upload date:
  • Size: 26.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.3

File hashes

Hashes for apache-skywalking-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1ae38b99eed42da3d628d82fc45289f7f4e4706222c9de0c326dd523f202954f
MD5 9f9744b2bfa8eb59fcad92cc3d5e95dd
BLAKE2b-256 c8896804deefd7a72f2493c5b2ec0d22bbc401f9a41b68b825f02a76a8b3c6ed

See more details on using hashes here.

File details

Details for the file apache_skywalking-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: apache_skywalking-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 73.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.3

File hashes

Hashes for apache_skywalking-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2a2b9e371e6926fffed9ca16b0272c526116f6920b7f483edae9b6aa7ba39b75
MD5 c3a2950eec36066dc96ae771b1159f04
BLAKE2b-256 ab98aa3785c5bba0a5f32f9b1ad359148b90bfab33de70ec22a46ad281097596

See more details on using hashes here.

Release history Release notifications | RSS feed

1.3.0

2 files

1.2.0

2 files

1.1.0

2 files

1.0.1

2 files

1.0.0

2 files

0.8.0

2 files

0.7.0

2 files

0.6.0

2 files

0.5.0

2 files

0.4.0

2 files

0.3.0

2 files

0.2.0

2 files

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page