You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2021/07/28 03:12:54 UTC

[GitHub] [skywalking] ZhouWlnd opened a new issue #7381: How does python agent use skywalking in a non-intrusive way?

ZhouWlnd opened a new issue #7381:
URL: https://github.com/apache/skywalking/issues/7381


   Please answer these questions before submitting your issue.
   
   - Why do you submit this issue?
   - [x] Question or discussion
   - [ ] Bug
   - [ ] Requirement
   - [ ] Feature or performance improvement
   ___
   ### Question
   - What do you want to know?
   Now java can use non-invasive way to use skywalking, such as : 
   `java -jar $JAVA_AGENT -jar lab-39-demo-2.2.2.RELEASE.jar`
   
   But python needs to add code to the original project, such as:
   ```
   from skywalking import agent, config
   
   config.init(collector_address='127.0.0.1:11800', service_name='your awesome service')
   agent.start()
   ```
   How does python use skywalking in a non-intrusive way like java?
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking] kezhenxu94 closed issue #7381: [Python] provide a wrapper script to initiate the Python agent without code changes in user app

Posted by GitBox <gi...@apache.org>.
kezhenxu94 closed issue #7381:
URL: https://github.com/apache/skywalking/issues/7381


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking] wu-sheng commented on issue #7381: [Python] provide a wrapper script to initiate the Python agent without code changes in user app

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on issue #7381:
URL: https://github.com/apache/skywalking/issues/7381#issuecomment-888001526


   Is this possible in theory? 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking] kezhenxu94 commented on issue #7381: [Python] provide a wrapper script to initiate the Python agent without code changes in user app

Posted by GitBox <gi...@apache.org>.
kezhenxu94 commented on issue #7381:
URL: https://github.com/apache/skywalking/issues/7381#issuecomment-901583999


   @Superskyyy site module is another option, if it works, I'm totally OK to use it.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking] Superskyyy commented on issue #7381: [Python] provide a wrapper script to initiate the Python agent without code changes in user app

Posted by GitBox <gi...@apache.org>.
Superskyyy commented on issue #7381:
URL: https://github.com/apache/skywalking/issues/7381#issuecomment-898299630


   > > @kezhenxu94  Shall we introduce some new user friendly config file for the command-line option to use?
   > > It could be used like the following
   > > `sw-python --config=sw_agent.yaml run your application`
   > 
   > We could do that but it's optional because all the configurations can be set via env vars, it's the wrapper script's responsibility to pass the env vars down to the agent.
   
   Got it, will make it optional.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking] Superskyyy edited a comment on issue #7381: [Python] provide a wrapper script to initiate the Python agent without code changes in user app

Posted by GitBox <gi...@apache.org>.
Superskyyy edited a comment on issue #7381:
URL: https://github.com/apache/skywalking/issues/7381#issuecomment-901564816


   @kezhenxu94 After some investigation, I believe a [site module](https://docs.python.org/3/library/site.html) is the right way to go. Using pure `exec*` overrides the whole process using a new interpreter instance, therefore won't work. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking] Superskyyy commented on issue #7381: [Python] provide a wrapper script to initiate the Python agent without code changes in user app

Posted by GitBox <gi...@apache.org>.
Superskyyy commented on issue #7381:
URL: https://github.com/apache/skywalking/issues/7381#issuecomment-895270600


   Ha I see how it works. I'll first finish the log reporter related work then start implementing this one.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking] Superskyyy edited a comment on issue #7381: [Python] provide a wrapper script to initiate the Python agent without code changes in user app

Posted by GitBox <gi...@apache.org>.
Superskyyy edited a comment on issue #7381:
URL: https://github.com/apache/skywalking/issues/7381#issuecomment-901564816


   @kezhenxu94 After some investigation, I believe a [site module](https://docs.python.org/3/library/site.html) is the right way to go. Using pure `exec*` overrides the whole process thus using a new interpreter instance, thus won't work. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking] kezhenxu94 commented on issue #7381: [Python] provide a wrapper script to initiate the Python agent without code changes in user app

Posted by GitBox <gi...@apache.org>.
kezhenxu94 commented on issue #7381:
URL: https://github.com/apache/skywalking/issues/7381#issuecomment-898292692


   > @kezhenxu94  Shall we introduce some new user friendly config file for the command-line option to use?
   > 
   > 
   > 
   > It could be used like the following
   > 
   > `sw-python --config=sw_agent.yaml run your application` 
   > 
   > 
   
   We could do that but it's optional because all the configurations can be set via env vars, it's the wrapper script's responsibility to pass the env vars down to the agent. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking] Superskyyy commented on issue #7381: [Python] provide a wrapper script to initiate the Python agent without code changes in user app

Posted by GitBox <gi...@apache.org>.
Superskyyy commented on issue #7381:
URL: https://github.com/apache/skywalking/issues/7381#issuecomment-898282426


   Shall we introduce some new user friendly config file for the command-line option to use?
   
   It could be used like the following
   `sw-python --config=sw_agent.yaml run your application`


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking] Superskyyy edited a comment on issue #7381: [Python] provide a wrapper script to initiate the Python agent without code changes in user app

Posted by GitBox <gi...@apache.org>.
Superskyyy edited a comment on issue #7381:
URL: https://github.com/apache/skywalking/issues/7381#issuecomment-898282426


   @kezhenxu94  Shall we introduce some new user friendly config file for the command-line option to use?
   
   It could be used like the following
   `sw-python --config=sw_agent.yaml run your application` 
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking] kezhenxu94 commented on issue #7381: [Python] provide a wrapper script to initiate the Python agent without code changes in user app

Posted by GitBox <gi...@apache.org>.
kezhenxu94 commented on issue #7381:
URL: https://github.com/apache/skywalking/issues/7381#issuecomment-888048517


   > Is this possible in theory?
   
   It's possible


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking] Superskyyy commented on issue #7381: [Python] provide a wrapper script to initiate the Python agent without code changes in user app

Posted by GitBox <gi...@apache.org>.
Superskyyy commented on issue #7381:
URL: https://github.com/apache/skywalking/issues/7381#issuecomment-895199012


   I'm quite interested in this one, could you elaborate a bit more on how this can be achieved? @kezhenxu94 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking] Superskyyy commented on issue #7381: [Python] provide a wrapper script to initiate the Python agent without code changes in user app

Posted by GitBox <gi...@apache.org>.
Superskyyy commented on issue #7381:
URL: https://github.com/apache/skywalking/issues/7381#issuecomment-901564816


   After some investigation, I believe a `sitecustomize` script is the right way to go. Using pure `exec*` overrides the whole process thus using a new interpreter instance, thus won't work. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking] kezhenxu94 commented on issue #7381: [Python] provide a wrapper script to initiate the Python agent without code changes in user app

Posted by GitBox <gi...@apache.org>.
kezhenxu94 commented on issue #7381:
URL: https://github.com/apache/skywalking/issues/7381#issuecomment-895229962


   > I'm quite interested in this one, could you elaborate a bit more on how this can be achieved? @kezhenxu94
   
   @Superskyyy thanks for your interest, the basic idea is to write a command line tool (in Python language, for example, named `sw-python`) and start the SkyWalking Python agent first, then start the user-app command, e.g. `sw-python app.py`, or `sw-python gunicorn myproject.wsgi`, or `sw-python django ......`, etc.
   
   I haven't had a chance to look into the details but the following might be a start point:
   
   ```python
   import os
   import sys
   
   from skywalking import config, agent
   
   if __name__ == '__main__':
       args = sys.argv[1:]
   
       bin_directory = os.path.dirname(sys.argv[0])
   
       python_exe = os.path.basename(sys.executable)
       python_exe_path = os.path.join(bin_directory, python_exe)
       if (not os.path.exists(python_exe_path) or
               not os.access(python_exe_path, os.X_OK)):
           python_exe_path = sys.executable
   
       config.service_name = 'provider'
       config.logging_level = 'DEBUG'
       agent.start()
   
       os.execl(python_exe_path, python_exe_path, *args)
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org