diff --git a/application/single_app/app.py b/application/single_app/app.py index 3f023956..8002098c 100644 --- a/application/single_app/app.py +++ b/application/single_app/app.py @@ -62,8 +62,14 @@ from route_plugin_logging import bpl as plugin_logging_bp from functions_debug import debug_print +from opentelemetry.instrumentation.flask import FlaskInstrumentor + app = Flask(__name__, static_url_path='/static', static_folder='static') +disable_flask_instrumentation = os.environ.get("DISABLE_FLASK_INSTRUMENTATION", "0") +if not (disable_flask_instrumentation == "1" or disable_flask_instrumentation.lower() == "true"): + FlaskInstrumentor().instrument_app(app) + app.config['EXECUTOR_TYPE'] = EXECUTOR_TYPE app.config['EXECUTOR_MAX_WORKERS'] = EXECUTOR_MAX_WORKERS executor = Executor() diff --git a/docs/troubleshooting/troubleshooting.md b/docs/troubleshooting/troubleshooting.md new file mode 100644 index 00000000..12c646dd --- /dev/null +++ b/docs/troubleshooting/troubleshooting.md @@ -0,0 +1,40 @@ +# Troubleshooting + +- [OpenTelemetry Settings](#opentelemetry-settings) +- [Backend call failing](#backend-call-failing) +- [Flask Instrumentation Startup Error](#flask-instrumentation-startup-error) + +## OpenTelemetry Settings + +- [Azure Monitor Info](https://pypi.org/project/azure-monitor-opentelemetry) +- [OpenTelemetry Settings](https://opentelemetry.io/docs/specs/otel/configuration/sdk-environment-variables/) + +## Backend call failing + +SimpleChat uses flask instrumentation by default and backend calls are logged to Application Insights. Query the 'requests' table to find the failing call and note the 'operation_Id'. Use the operation ID to find associated exceptions like below. + +### Query failed requests + +``` +requests +| where success == false +``` + +### Query most recent exceptions + +``` +exceptions +| top 10 by timestamp +``` + +### Query exceptions associated with a specific operation_Id + +``` +exceptions +| where operation_Id == '61a97b6a6ddc11b465b5289738bddcf1' +``` + +## Flask Instrumentation Startup Error + +If startup logs show an error initializing Flask Instrumentation it can be disabled using environment variable DISABLE_FLASK_INSTRUMENTATION. Set it to '1' or 'true' to disable flask instrumentation. **REQUIRES APP RESTART**. +