Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

spring_onion

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

spring_onion

  • 1.1.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

SpringOnion

Log MySQL queries with EXPLAIN that may be slow.

Inspired by MySQLCasualLog.pm.

Build Status

Installation

Add this line to your application's Gemfile:

gem 'spring_onion'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install spring_onion

Usage

#!/usr/bin/env ruby
require 'active_record'
require 'spring_onion'

ActiveRecord::Base.establish_connection(
  adapter:  'mysql2',
  username: 'root',
  database: 'employees'
)

SpringOnion.enabled = true # or `SPRING_ONION_ENABLED=1`
# `SPRING_ONION_DATABASE_URL=mysql2://...`
# default: SpringOnion.connection = ActiveRecord::Base.connection.raw_connection
SpringOnion.source_filter_re = //

class Employee < ActiveRecord::Base; end

p Employee.all.to_a.count
#=> SpringOnion	INFO	2020-07-18 01:53:27 +0900	{"sql":"SELECT `employees`.* FROM `employees`","explain":[{"line":1,"select_type":"SIMPLE","table":"employees","partitions":null,"type":"ALL","possible_keys":null,"key":null,"key_len":null,"ref":null,"rows":298936,"filtered":100.0,"Extra":null}],"warnings":{"line 1":["slow_type"]},"backtrace":["/foo/bar/zoo/baz.rb:18:in `\u003ctop (required)\u003e'"]}
#=> 300024

Log Output

{
    "sql": "SELECT `employees`.* FROM `employees`",
    "explain": [
        {
            "line": 1,
            "select_type": "SIMPLE",
            "table": "employees",
            "partitions": null,
            "type": "ALL",
            "possible_keys": null,
            "key": null,
            "key_len": null,
            "ref": null,
            "rows":298936,
            "filtered": 100.0,
            "Extra": null
        }
    ],
    "warnings": {
        "line 1": [
            "slow_type"
        ]
    },
    "backtrace": [
        "/foo/bar/zoo/baz.rb:18:in `\u003ctop (required)\u003e'"
    ]
}

Test

docker-compose build
docker-compose run client bundle exec appraisal ar60 rake

FAQs

Package last updated on 28 Jul 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc