from flask import Flask

from ddtrace.internal.telemetry import telemetry_writer
from ddtrace.internal.telemetry.constants import TELEMETRY_NAMESPACE_TAG_TRACER


app = Flask(__name__)


@app.route("/")
def index():
    return "OK", 200


@app.route("/start_application")
def starting_app_view():
    # We must call app-started before telemetry events can be sent to the agent.
    # This endpoint mocks the behavior of the agent writer.
    telemetry_writer._app_started_event()
    return "OK", 200


@app.route("/count_metric")
def metrics_view():
    telemetry_writer.add_count_metric(
        TELEMETRY_NAMESPACE_TAG_TRACER,
        "test_metric",
        1.0,
    )
    return "OK", 200
