Skip to content

Add Flask plugin#25

Closed
alonelaval wants to merge 0 commit intoapache:masterfrom
alonelaval:master
Closed

Add Flask plugin#25
alonelaval wants to merge 0 commit intoapache:masterfrom
alonelaval:master

Conversation

@alonelaval
Copy link
Copy Markdown
Member

@alonelaval alonelaval commented Jun 26, 2020

@kezhenxu94 kezhenxu94 added the plugin Plugin label Jun 26, 2020
@kezhenxu94 kezhenxu94 added this to the 0.2.0 milestone Jun 26, 2020
Copy link
Copy Markdown
Member

@kezhenxu94 kezhenxu94 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alonelaval thanks very much

  1. We tend to keep a single blank line at the end of a file, please keep those
  2. It seems that the tests(expected.data.yaml) are not adjusted according to this plugin

Comment thread skywalking/plugins/sw_flask/__init__.py Outdated
Comment thread skywalking/plugins/sw_flask/__init__.py Outdated
def _sw_handle_user_exception(this: Flask, e):
if e is not None:
entry_span = get_context().active_span()
entry_span.log(e)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't actually have a log method on Span type, please implement it first

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And better to have a sanity check here, entry_span is possible to be None

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also mark the span as error by setting error_occurred to True

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And, can we get the response of the request, then we can determine the span's status by the http status code, like other plugins

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok,i use skywalking 6.6 test... i will use skywalking 8.0.1 test first.

Comment thread skywalking/plugins/sw_flask/__init__.py Outdated

except Exception:
logger.warning('failed to install plugin %s', __name__)
traceback.print_exc()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest not to print the traceback in this plugin, other plugins are for built-in libraries, which are rarely failed to install, but this plugin is tend to be failed because not all users are using Flask

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

import socketserver
from http.server import BaseHTTPRequestHandler

class SimpleHTTPRequestHandler(BaseHTTPRequestHandler):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be better to use Flask as well in the consumer service, we can check the propagation of context by that

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@kezhenxu94 kezhenxu94 changed the title add flask plugin Add Flask plugin Jun 26, 2020
@kezhenxu94 kezhenxu94 closed this Jul 2, 2020
@wu-sheng
Copy link
Copy Markdown
Member

wu-sheng commented Jul 2, 2020

Forse push and close? What happens?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

plugin Plugin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[PythonAgent] Support Flask framework

3 participants