All Projects → khusnetdinov → active_endpoint

khusnetdinov / active_endpoint

Licence: MIT license
[ARCHIVE] 🔧 ActiveEndpoint is middleware for Rails application that collect and analize request and response per request for route endpoint. It works with minimum affecting to application response time.

Programming Languages

ruby
36898 projects - #4 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to active endpoint

Guzzlette
🌀 Guzzle integration into Nette Framework (@nette)
Stars: ✭ 19 (+46.15%)
Mutual labels:  request, response
Alamofire
Elegant HTTP Networking in Swift
Stars: ✭ 36,896 (+283715.38%)
Mutual labels:  request, response
Alagarr
🦍 Alagarr is a request-response helper library that removes the boilerplate from your Node.js (AWS Lambda) serverless functions and helps make your code portable.
Stars: ✭ 58 (+346.15%)
Mutual labels:  request, response
Swiftyjson
The better way to deal with JSON data in Swift.
Stars: ✭ 21,042 (+161761.54%)
Mutual labels:  request, response
Cortex
Cortex: a Powerful Observable Analysis and Active Response Engine
Stars: ✭ 676 (+5100%)
Mutual labels:  analyzer, response
Fast Cgi Client
A PHP fast CGI client for sending requests (a)synchronously to PHP-FPM
Stars: ✭ 478 (+3576.92%)
Mutual labels:  request, response
Kitura Net
Kitura networking
Stars: ✭ 98 (+653.85%)
Mutual labels:  request, response
psr7-http-message
💫 PSR #7 [HTTP Message Interface] to Nette Framework (@nette)
Stars: ✭ 17 (+30.77%)
Mutual labels:  request, response
Examples
Examples of Mock Service Worker usage with various frameworks and libraries.
Stars: ✭ 163 (+1153.85%)
Mutual labels:  request, response
Holen
Declarative fetch for React
Stars: ✭ 152 (+1069.23%)
Mutual labels:  request, response
Wiremock.net
WireMock.Net is a flexible library for stubbing and mocking web HTTP responses using request matching and response templating. Based on the functionality from http://WireMock.org, but extended with more functionality.
Stars: ✭ 408 (+3038.46%)
Mutual labels:  request, response
chronosjs
JS Channels (Events / Commands / Reqest-Response / Courier) Mechanism
Stars: ✭ 35 (+169.23%)
Mutual labels:  request, response
Netfox
A lightweight, one line setup, iOS / OSX network debugging library! 🦊
Stars: ✭ 3,188 (+24423.08%)
Mutual labels:  request, response
Ngx Restangular
Restangular for Angular 2 and higher versions
Stars: ✭ 787 (+5953.85%)
Mutual labels:  request, response
Cors
🔮Supported(Laravel/Lumen/PSR-15/Swoft/Slim/ThinkPHP) - PHP CORS (Cross-origin resource sharing) middleware.
Stars: ✭ 266 (+1946.15%)
Mutual labels:  request, response
Aura.http
HTTP Request and Response tools
Stars: ✭ 69 (+430.77%)
Mutual labels:  request, response
httpmate
Non-invasive, flexible and ultra-extendable http framework that offers you 3 modes of handling http requests - UseCase driven, low-level http and event-driven request handling, as well as a mix of those modes
Stars: ✭ 15 (+15.38%)
Mutual labels:  request, response
mock-req-res
Extensible mock req / res objects for use in unit tests of Express controller and middleware functions.
Stars: ✭ 39 (+200%)
Mutual labels:  request, response
Netclient Ios
Versatile HTTP Networking in Swift
Stars: ✭ 117 (+800%)
Mutual labels:  request, response
reqres
Powerful classes for http requests and responses
Stars: ✭ 36 (+176.92%)
Mutual labels:  request, response

ActiveEndpoint Build Status Gem Version Open Source Helpers

Your request tracking tool for rails applications

Attention! Gem in under active test and is preparing for first release !

img

Usage

ActiveEndpoint is middleware for Rails applications that collects and analyses requests and responses per request for endpoint. It works with minimal impact on application's response time.

This gem uses ActiveSupport::Notifications and Cache Storage to reduce possible impact on application request / response processing time.

Features

  • Metrics are stored in database for further tracking and analysis.
  • History rotation with configurable limits of records amount and age.
  • Routes filter (blacklist).
  • Probes tagging by processing time.

Metrics

These endpoint metrics are stored in DB:

  • :uuid - uniq probe identifier
  • :endpoint - requested endpoint
  • :path - requested full path
  • :query_string - request query string
  • :request_method - http request method
  • :ip - ip address asked request
  • :url - request full url
  • :xhr - is request ajax?
  • :started_at - probe start time
  • :finished_at - probe finish time
  • :duration - probe request duration
  • :params - parsed requested params
  • :response - Base64 encoded html response
  • :body - Base64 encoded request body

Additional information is taken from Rack log:

:base_url, :content_charset, :content_length, :content_type, :fullpath, :http_version, :http_connection, :http_accept_encoding, :http_accept_language, :media_type, :media_type_params, :method, :path_info, :pattern, :port, :protocol, :server_name, :ssl.

Requests which are not recognized by rails router are stored as unregistred.

Requirements

  • redis as cache storage

Be sure that you have all requrements installed on you machine.

Installation

Add this line to your application's Gemfile:

gem 'active_endpoint'

And then execute:

$ bundle

Or install it yourself as:

$ gem install active_endpoint

Setup project for using gem:

$ rails generate active_endpoint:install

Migrate database for models:

$ rake db:migrate  # Rails <=4
$ rails db:migrate # Rails >=5

Now project has all files and settings that allow you to use gem.

Configuration

Endpoints filter (blacklist)

By default ActiveEndpoint treats all routes as whitelist routes. To filter some endpoints you can use blackilist configuration, as shown below:

ActiveEndpoint.configure do |endpoint|
  endpoint.blacklist.configure  do |blacklist|
    # Ignore endpoint "welcome#index"
    blacklist.add(endpoint: "welcome#index")

    # Ignore "web/users" controller actions
    blacklist.add(resources: ["web/users"])

    # Ignore "web/users#show" action with scoped controller
    blacklist.add(scope: "web", resources: "users", actions: ["show"])

    # Ignore "admin" scope controllers
    blacklist.add(scope: "admin")
  end
end

Ignore one endpoint

blacklist.add(endpoint: "users#index") - Ignore one endpoint.

Ignore controller actions

blacklist.add(resources: "users") - Ignore all actions for UsersController.

blacklist.add(resources: ["users", "managers"]) - Ignore all actions in UsersController and ManagersController.

blacklist.add(resources: "users", actions: ["show"]) - Ignore only show action in UsersController.

Ignore namespace or scope

blacklist.add(scope: "admin") - Ignore all controllers and actions for admin namespace or scope.

Constraints

You can specify the amount and period of request records to keep in database. Records which exceed these limits are automatically removed from database. See example below:

ActiveEndpoint.configure do |endpoint|
 # Defines default settings, 1 probe per 10 minutes for endpoint request
 constraint_limit = 1
 constraint_period = 10.minutes

 endpoint.constraints.configure  do |constraints|
   # Constraint endpoint "welcome#index" with 1 minute period and default limit
   # and configure database constraints to keep 1000 probes per 1 week.
   constraints.add(endpoint: "welcome#index",
     rule: { 1.minute },
     storage: { limit: 1000, period: 1.week })
   # Constraints "web/users" controller actions with custom limit and period
   # with defailt storage constraints
   constraints.add(resources: ["web/users"], rule: { limit: 100, period: 5.minutes })
 end
end

NOTE: To define a constraint you should define at least one limit or period.

Storage settings

ActiveEndpoint creates two models in you rails application: Probe and it's child UnregistredProbe. To prevent problems with database probes are removed when user defines custom period. Also you can limit storage probes in database. It is recommended to define own storage default to prevent unwanted probes deletion. See example below:

ActiveEndpoint.configure do |endpoint|
  # Define default limit for maximum probes amount
  endpoint.storage_limit = 1000

  # Define default period to keep probes in database.
  endpoint.storage_period = 1.week

  # Define amount of periods (constraint periods) that endpoints are kept in database.
  endpoint.storage_keep_periods = 2
end

Tagging probes

You can group probes by tags automatically assigned according to request processing time (ms). See example below:

ActiveEndpoint.configure do |endpoint|
  endpoint.tags.configure do |tags|
    tags.add(:fast, { less_than: 250 })
    tags.add(:normal, { greater_than_or_equal_to: 250, less_than: 500 })
    tags.add(:slow, { greater_than_or_equal_to: 500, less_than: 750 })
    tags.add(:acceptable, { greater_than_or_equal_to: 500, less_than: 1000 })
    tags.add(:need_optimization, { greater_than_or_equal_to: 1000 })
  end
end

Mehods for conditions

  • greater_than = '>'
  • greater_than_or_equal_to = '>=',
  • equal_to = '=',
  • less_than = '<',
  • less_than_or_equal_to = '<=',

Tagged model scopes

Defined tags are also usefull for scopes queries:

ActiveEndpoint::Probe.tagged_as(:need_optimization)
#=> Returns all probes having corresponding tag and thus matching the condition
#   { greater_than_or_equal_to: 1000 }

Instance methods

Check tag on model:

ActiveEndpoint::Probe.last.tag
#=> Returns probe's tag

Web UI

ActiveEndpoint offer rails engine for managing probes. Mount it:

  mount ActiveEndpoint::Engine => '/active_endpoint'

img

License

This gem is available as open source under the terms of the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].