I have a Streamlit app running as a Docker container on Azure App Service. I’d like to start using Azure App Insights to log requests and errors. This requires adding telemetry code to the app, as described here.
To add temeltry to a Flask app, I would add the following to the top of the main app.py file:
from opencensus.ext.azure.trace_exporter import AzureExporter from opencensus.ext.flask.flask_middleware import FlaskMiddleware from opencensus.trace.samplers import ProbabilitySampler app = Flask(__name__) middleware = FlaskMiddleware( app, exporter=AzureExporter(connection_string=APP_INSIGHTS_CONN_STR), sampler=ProbabilitySampler(rate=1.0), )
Does anyone know how to do this for a Streamlit app? I suspect that I need a different way of defining
app in the code above.