-
Notifications
You must be signed in to change notification settings - Fork 556
Closed
Labels
Description
How do you use Sentry?
Sentry Saas (sentry.io)
Version
1.22.2
Steps to Reproduce
- Setup with docker-compose as following
- docker-compose.yaml
version: '3.6'
services:
web:
image: a901002666/sentry-example
command: flask run --host 0.0.0.0 --port 8000 --reload
env_file:
- .env
ports:
- 8000:8000
- .env
SENTRY_DSN=${YOUR_DSN}
- Run
docker-compose up
- POST request to localhost:8000/
curl --location --request POST 'http://localhost:8000/' \
--header 'Content-Type: application/json' \
--data-raw '{
"password": "temp1234"
}'
The image is a simple flask application has code.
- app.py
import os
import sentry_sdk
import sentry_sdk.integrations.flask
from flask import Flask, request, current_app
sentry_sdk.init(
traces_sample_rate=1.0,
integrations=[
sentry_sdk.integrations.flask.FlaskIntegration(),
],
)
app = Flask(__name__)
@app.route("/", methods={'POST'})
def hello_world():
print('before', request.get_json())
current_app.logger.error('debug example')
print('after', request.get_json())
return "<p>Hello, World!</p>"
Expected Result
Look at console has 2 print()
call, between the 2 has a logger.error()
which will trigger sentry-sdk report.
expect result should be.
flask-web-1 | before {'password': 'temp1234'}
flask-web-1 | [2023-05-14 11:52:14,330] ERROR in app: debug example
flask-web-1 | after {'password': 'temp1234'}
My expectation is that sentry-sdk should do the scrubbing on data send to report, not affecting data still processing by flask.
Actual Result
But you'll actually get
flask-web-1 | before {'password': 'temp1234'}
flask-web-1 | [2023-05-14 11:52:14,330] ERROR in app: debug example
flask-web-1 | after {'password': <sentry_sdk.utils.AnnotatedValue object at 0xffff91d01ff0>}
The request.get_json()
result had been mocked by sentry-sdk.