question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Usage with flaskRESTFUL

See original GitHub issue

How can metrics be logged and customized when API is constructed using flaskRESTful library, where instead of routes, you have:

class Coordinates(Resource):
    def __init__(self):
        self.parser = reqparse.RequestParser()
        self.parser.add_argument('radius', type=float, required=False, help="Radius", location='args', default=1)

    def post(self):
        args = self.parser.parse_args()

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:25 (12 by maintainers)

github_iconTop GitHub Comments

4reactions
rycus86commented, Sep 26, 2019

Would the decorator need to be added for the class? (since the end point is defined on starting the flask server)

api.add_resource(Coordinates, '/coordinates')

I just realized I already have an example for Flask-RESTful here 🤦‍♂️ https://github.com/rycus86/prometheus_flask_exporter/blob/master/examples/restful-with-blueprints/server.py

Does this help answer your question @captify-dieter ?

3reactions
captify-dietercommented, Sep 26, 2019

The issues if i don’t expose the metrics endpoints, you cannot collect the metrics as the flask server will reply with 404,

Screen Shot 2019-09-26 at 15 29 46

Screen Shot 2019-09-26 at 15 32 19

Note @ziedbf you have a typo in the url: “/me[r]trics”

Read more comments on GitHub >

github_iconTop Results From Across the Web

Flask-RESTful — Flask-RESTful 0.3.8 documentation
Flask -RESTful is an extension for Flask that adds support for quickly building REST APIs. It is a lightweight abstraction that works with...
Read more >
Flask REST API Tutorial
REST API services let you interact with the database by simply doing HTTP requests. In this article you learn how to write a...
Read more >
Developing RESTful APIs with Python and Flask
TL;DR: Throughout this article, we will use Flask and Python to develop a RESTful API. We will create an endpoint that returns static...
Read more >
Using basic Flask vs Flask-RESTful for API development
REST is a pretty flexible architecture, but there's a few points worth thinking about in your approach using just Flask, which Flask-RESTful ......
Read more >
Python | Build a REST API using Flask
Flask is a popular micro framework for building web applications. Since it is a micro-framework, it is very easy to use and lacks...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found