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
14 changes: 12 additions & 2 deletions flask_sqlalchemy_tutorial/__init__.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,33 @@
"""Initialize Flask app."""
import uptrace
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from ddtrace import patch_all
from opentelemetry.instrumentation.flask import FlaskInstrumentor
from opentelemetry.instrumentation.sqlalchemy import SQLAlchemyInstrumentor

upclient = uptrace.Client(dsn="")


db = SQLAlchemy()
patch_all()


def create_app():
"""Construct the core application."""
app = Flask(__name__, instance_relative_config=False)
app.config.from_object("config.Config")

FlaskInstrumentor().instrument_app(app)

db.init_app(app)

with app.app_context():
from . import routes # Import routes

db.create_all() # Create database tables for our data models

SQLAlchemyInstrumentor().instrument(
engine=db.engine,
service="database",
)

return app
Loading