Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Python] Apache Skywalking, flask uwsgi, no metrics send to server #6324

Closed
4 tasks
MichaelProjects opened this issue Feb 4, 2021 · 7 comments
Closed
4 tasks
Assignees
Labels
python Python agent related

Comments

@MichaelProjects
Copy link

MichaelProjects commented Feb 4, 2021

Please answer these questions before submitting your issue.

  • Why do you submit this issue?
    Because I like apache skywalking and it's really annoying
  • Question or discussion
    So the following issue is, if I run my flask app with a normal "python3 run.app" and call an endpoint, then it will send the needed metrics to the aop server(it runs in a docker container) but if i run my app with uwsgi, then it wont send the needed metrics to the server.
  • Bug
    Flask==1.1.2
    apache-skywalking[http]==0.5.0
  • Requirement
  • Feature or performance improvement

Question

  • What do you want to know?

Bug

serverlog:
contentservice | skywalking [HeartbeatThread] [DEBUG] service heart beats, [Contentservice], [dc037ddc672111eb94ef0242c0a8f002]
imageservice | skywalking [HeartbeatThread] [DEBUG] service heart beats, [Imageservice], [dc0047ac672111eba89e0242c0a8f003]
userservice | skywalking [HeartbeatThread] [DEBUG] service heart beats, [Userservice], [dbbe190e672111eb95d70242c0a8f007]
contentservice | skywalking [HeartbeatThread] [DEBUG] service heart beats, [Contentservice], [dc037ddc672111eb94ef0242c0a8f002]
imageservice | skywalking [HeartbeatThread] [DEBUG] service heart beats, [Imageservice], [dc0047ac672111eba89e0242c0a8f003]
contentservice | [pid: 16|app: 0|req: 19/25] 95.91.253.112 () {40 vars in 740 bytes} [Thu Feb 4 21:14:21 2021] GET /contentservice/getcontent => generated 1479 bytes in 60 msecs (HTTP/2.0 200) 2 headers in 73 bytes (1 switches on core 0)
nginx | 95.91.253.112 - - [04/Feb/2021:21:14:21 +0000] "GET /contentservice/getcontent HTTP/2.0" 200 1479 "-" "insomnia/2020.5.2" "-"
userservice | skywalking [HeartbeatThread] [DEBUG] service heart beats, [Userservice], [dbbe190e672111eb95d70242c0a8f007]
contentservice | skywalking [HeartbeatThread] [DEBUG] service heart beats, [Contentservice], [dc037ddc672111eb94ef0242c0a8f002]

Programmcode:

from gevent import monkey
monkey.patch_all()

config.flask_collect_http_params = True
config.logging_level = 'DEBUG'
config.disable_plugins = 'sw_tornado'
config.init(collector='X.X.X.X:11800', service='Contentservice')
agent.start()

import grpc.experimental.gevent as grpc_gevent # key point
grpc_gevent.init_gevent() # key point


Requirement or improvement

  • Please describe your requirements or improvement suggestions.
@wu-sheng wu-sheng added the python Python agent related label Feb 5, 2021
@wu-sheng wu-sheng changed the title Apache Skywalking, flask uwsgi, no metrics send to server [Python] Apache Skywalking, flask uwsgi, no metrics send to server Feb 5, 2021
@kezhenxu94
Copy link
Member

@MichaelProjects this seems to be duplicated with #5263 but also seems you had referred to it already. Can you move the grpc patch part to the top like this

from gevent import monkey
monkey.patch_all()

import grpc.experimental.gevent as grpc_gevent # key point
grpc_gevent.init_gevent() # key point

config.flask_collect_http_params = True
config.logging_level = 'DEBUG'
config.disable_plugins = 'sw_tornado'
config.init(collector='X.X.X.X:11800', service='Contentservice')
agent.start()

@kezhenxu94 kezhenxu94 added this to the PythonAgent 0.6.0 milestone Feb 5, 2021
@kezhenxu94
Copy link
Member

As this is exactly the same question with #5263 and the answer was provided, I'll close this for now, if @MichaelProjects you have any further question, feel free to continue this issue by adding comments here

@MichaelProjects
Copy link
Author

Thanks for your answer, I saw the issue and tried it out before, but it didn't work. I think uwsgi is blocking the request to the server. If I run it, it only prints heartbeats send and a hash value every 10 seconds or something between, and it doesn't show the value of the sended metric after an endpoint request. However, if it runs with python3 and run.py then it behaves the way it should.

@kezhenxu94
Copy link
Member

kezhenxu94 commented Feb 5, 2021

@MichaelProjects did you try the same code snippets posted 👆? I tried that it works, if you saw heartbeats logs, the agent is working normally, make sure to send traffics / requests to the service, and the metrics are not sent by agent, they are calculated in SkyWalking backend with the traces caused by traffics.

@MichaelProjects
Copy link
Author

MichaelProjects commented Feb 5, 2021

Yes I did, now I saw that the server is reciving following requests:

2021-02-05 19:26:25,506 - org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.client.ElasticSearch7Client -14095820 [pool-7-thread-1] INFO [] - Synchronous bulk took time: 7990 millis, size: 3

But the content isn't displayed in the web ui of skywalking, but if i ping it in the development server with python3, then it shows them in the ui.

@MichaelProjects
Copy link
Author

I also, found out if i stop my docker containers, then it displays the content in the skywalking ui.

@kezhenxu94
Copy link
Member

@MichaelProjects did you try uwsgi in a container and try Python3 on your development machine? If so, pay attention to the time zone on the SkyWalking web ui (bottom right), I believe the time zones in your machine and container are different.

If you can reproduce using docker container, it would be more convenient to share your docker image registry / name (privately via email if not applicable on GitHub) to help reproduce. See my email in my GitHub profile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
python Python agent related
Projects
None yet
Development

No branches or pull requests

3 participants