Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions bench_fastapi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from skywalking import agent, config

config.init(agent_collector_backend_services='localhost:11800')

agent.start()
from flask import Flask, jsonify
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

10% of developers fix this issue

reportMissingImports: Import "flask" could not be resolved


ℹ️ Expand to see all @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.

import logging

app = Flask(__name__)

# benchmarking: sw-python run python flask_single.py

@app.route('/cat', methods=['POST', 'GET'])
def cat():
try:
logging.critical('fun cat got a request')
return jsonify({'Cat Fun Fact': 'Fact is cat, cat is fat'})
except Exception as e: # noqa
return jsonify({'message': str(e)})
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Exception message is returned to the user: Data from [Exception] source(s) may reach [ReturnedToUser] sink(s)


ℹ️ Expand to see all @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


if __name__ == '__main__':
app.run(host='0.0.0.0', port=9999, debug=False, use_reloader=False)
89 changes: 89 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
services:
oap:
container_name: oap
image: apache/skywalking-oap-server:9.2.0
# Python agent supports gRPC/ HTTP/ Kafka reporting
expose:
- 11800 # gRPC
- 12800 # HTTP
networks:
- manual
# environment:
# # SW_KAFKA_FETCHER: default
# # SW_KAFKA_FETCHER_SERVERS: kafka:9092
# # SW_KAFKA_FETCHER_PARTITIONS: 2
# # SW_KAFKA_FETCHER_PARTITIONS_FACTOR: 1
healthcheck:
test: [ "CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/11800" ]
interval: 5s
timeout: 100s
retries: 120
ports:
- "12800:12800"
- "11800:11800"
# depends_on:
# - kafka


ui:
image: apache/skywalking-ui:9.2.0
container_name: ui
depends_on:
oap:
condition: service_healthy
networks:
- manual
ports:
- "8080:8080"
environment:
SW_OAP_ADDRESS: "http://oap:12800"

# zookeeper:
# container_name: zk
# image: confluentinc/cp-zookeeper:latest
# ports:
# - "2181:2181"
# environment:
# ZOOKEEPER_CLIENT_PORT: 2181
# ZOOKEEPER_TICK_TIME: 2000
# networks:
# - manual

# kafka:
# container_name: kafka
# image: confluentinc/cp-kafka
# expose:
# - 9092
# - 9094
# ports:
# - 9092:9092
# - 9094:9094
# depends_on:
# - zookeeper
# environment:
# KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
# KAFKA_LISTENERS: INTERNAL://0.0.0.0:9092,OUTSIDE://0.0.0.0:9094
# KAFKA_ADVERTISED_LISTENERS: INTERNAL://kafka:9092,OUTSIDE://localhost:9094
# KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: INTERNAL:PLAINTEXT,OUTSIDE:PLAINTEXT
# KAFKA_INTER_BROKER_LISTENER_NAME: INTERNAL
# KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
# networks:
# - manual


# kafka-ui:
# image: provectuslabs/kafka-ui
# container_name: kafka-ui
# ports:
# - "8088:8080"
# restart: always
# environment:
# - KAFKA_CLUSTERS_0_NAME=local
# - KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS=kafka:9092
# depends_on:
# - kafka
# networks:
# - manual

networks:
manual:
124 changes: 34 additions & 90 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ wrapt = '*'
psutil = '*'
requests = { version = ">=2.26.0", optional = true }
kafka-python = { version = "*", optional = true }
janus = "^1.0.0"
uvloop = "^0.17.0"

[tool.poetry.extras]
all=[
Expand Down
4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
uvicorn
fastapi
flask
uvloop
Loading