commit | 2a14ae018dd324b9b8aee5edb9ed55c252fbff55 | [log] [tgz] |
---|---|---|
author | kezhenxu94 <kezhenxu94@163.com> | Sun May 10 14:12:57 2020 +0800 |
committer | kezhenxu94 <kezhenxu94@163.com> | Sun May 10 14:12:57 2020 +0800 |
tree | 35f49b7cedf370b849e9c428f3f224c529874152 | |
parent | 43794ac82d83db4ad21f49dcff149348633f9ddb [diff] |
Test: forward POST method to GET method for e2e tests
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.
SkyWalking Python SDK requires SkyWalking 8.0+.
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, currently only grpc is supported | grpc |
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 | '' |
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 |
Apart from the libraries that can be instrumented automatically, we also provide some APIs to enable manual instrumentation.
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'))
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()
Check the FAQ page or add the FAQs there.
Apache 2.0