Implementing Flask instrumentation
Instrumentation is a mechanism that generates, collects, and exports data about the runtime diagnostics of an application, microservice, or distributed setup. Usually, this observable data includes traces, logs, and metrics that can provide an understanding of the system. Among the many ways to implement instrumentation, OpenTelemetry offers easy configuration and vendor-agnostic approaches to monitoring and observing the systemâs internal state. To utilize OpenTelemetry for Flask, install the following external modules using the pip
command:
pip install opentelemetry-api opentelemetry-sdk opentelemetry-instrumentation-flask opentelemetry-instrumentation-requests
The following snippet added to the create_app()
factory in the __init__.py
of the main Flask application provides the console-based instrumentation:
from opentelemetry import trace from opentelemetry.sdk.resources import Resource from opentelemetry.sdk.trace import TracerProvider...