<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Takahiro Ebato</title>
    <description>The latest articles on DEV Community by Takahiro Ebato (@takaebato).</description>
    <link>https://dev.to/takaebato</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1130155%2Fe4f45143-a68b-4fb2-b6ed-4f3132114268.jpeg</url>
      <title>DEV Community: Takahiro Ebato</title>
      <link>https://dev.to/takaebato</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/takaebato"/>
    <language>en</language>
    <item>
      <title>Introducing rack-dev_insight: A New Development Tool for Rack (Rails) Application</title>
      <dc:creator>Takahiro Ebato</dc:creator>
      <pubDate>Mon, 08 Jan 2024 14:28:45 +0000</pubDate>
      <link>https://dev.to/takaebato/introducing-rack-devinsight-a-new-development-tool-for-rack-rails-application-387l</link>
      <guid>https://dev.to/takaebato/introducing-rack-devinsight-a-new-development-tool-for-rack-rails-application-387l</guid>
      <description>&lt;p&gt;Hi! I'm excited to introduce a tool I've been developing over the past few months: rack-dev_insight.&lt;br&gt;
This tool, comprising a &lt;a href="https://github.com/takaebato/rack-dev_insight"&gt;gem&lt;/a&gt; and a &lt;a href="https://chromewebstore.google.com/detail/rack-dev-insight/blpooeljpmpagkbfflnfnjgelafpfeid"&gt;chrome extension&lt;/a&gt;, is designed to provide insights into your Rack applications.&lt;br&gt;
While it's still in its early stages, it's already valuable to be added to your development toolbox.&lt;/p&gt;
&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;What is rack-dev_insight?&lt;/li&gt;
&lt;li&gt;Overview video of rack-dev_insight&lt;/li&gt;
&lt;li&gt;
Unique features of rack-dev_insight

&lt;ul&gt;
&lt;li&gt;1. Grouping SQL queries by CRUD operation&lt;/li&gt;
&lt;li&gt;2. Grouping SQL queries by Normalized SQL&lt;/li&gt;
&lt;li&gt;3. Detailed HTTP request / response data&lt;/li&gt;
&lt;li&gt;4. Functional devtools panel&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;What is next?&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  What is rack-dev_insight?
&lt;/h2&gt;

&lt;p&gt;rack-dev_insight is a simple, yet unique monitoring tool for Rack applications.&lt;br&gt;
The &lt;a href="(https://github.com/takaebato/rack-dev_insight)"&gt;rack-dev_insight gem&lt;/a&gt; serves as a middleware for recording and analyzing SQL queries and HTTP request / response data.&lt;br&gt;
To visualize this data, &lt;a href="https://chromewebstore.google.com/detail/rack-dev-insight/blpooeljpmpagkbfflnfnjgelafpfeid"&gt;Chrome Devtools panel&lt;/a&gt; is offered, making it a developer-friendly tool.&lt;br&gt;
Currently, this tool is intended for use in development environments only.&lt;/p&gt;
&lt;h2&gt;
  
  
  Overview video of rack-dev_insight
&lt;/h2&gt;

&lt;p&gt;Here is overview video of rack-dev_insight. Detailed explanations of its key features are described in next section.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/ES9DnZEdeDY"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Unique features of rack-dev_insight
&lt;/h2&gt;

&lt;p&gt;Inspired by tools like &lt;a href="https://github.com/dejan/rails_panel"&gt;rails_panel&lt;/a&gt; and &lt;a href="https://github.com/MiniProfiler/rack-mini-profiler"&gt;rack-mini-profiler&lt;/a&gt;, rack-dev_insight stands out with its unique features:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Grouping SQL queries by CRUD operation
&lt;/h3&gt;

&lt;p&gt;This feature basically creates a CRUD matrix. &lt;/p&gt;

&lt;h4&gt;
  
  
  What is CRUD matrix?
&lt;/h4&gt;

&lt;p&gt;A CRUD matrix is a tabular representation showing how different entities (tables) are involved in CRUD (Create, Read, Update, Delete) operations in a business process. It's helpful for visualizing the interactions between various business processes and the tables involved.&lt;/p&gt;

&lt;p&gt;For example, let's take a business process where a user updates a comment on a post. This action typically requires reading data from the &lt;code&gt;users&lt;/code&gt; and &lt;code&gt;posts&lt;/code&gt; tables and updating the &lt;code&gt;comments&lt;/code&gt; table. The CRUD matrix would look like this:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Process \ Table&lt;/th&gt;
&lt;th&gt;users&lt;/th&gt;
&lt;th&gt;posts&lt;/th&gt;
&lt;th&gt;comments&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Update a comment&lt;/td&gt;
&lt;td&gt;READ&lt;/td&gt;
&lt;td&gt;READ&lt;/td&gt;
&lt;td&gt;UPDATE&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h4&gt;
  
  
  Visualization in Devtools panel
&lt;/h4&gt;

&lt;p&gt;In devtools panel this scenario is displayed as follows.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr6ytz4wp807zv61erc8y.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr6ytz4wp807zv61erc8y.jpg" alt="CRUD" width="800" height="367"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Usefulness
&lt;/h4&gt;

&lt;p&gt;This feature is particularly useful in complex scenarios where dozens of tables are involved or when working with unfamiliar APIs, helping you recognize exhaustive table lists involved, and understand data dependencies more clearly.&lt;/p&gt;

&lt;h4&gt;
  
  
  Details
&lt;/h4&gt;

&lt;p&gt;When extracting CRUD operations for the matrix, the following subtle cases are considered:&lt;/p&gt;

&lt;h5&gt;
  
  
  Conversion of Table Alias Names to Original Table Names
&lt;/h5&gt;

&lt;p&gt;In scenarios where table aliases are used, such as in the following SQL query,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT a FROM t1 AS t1_alias
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;it is counted as READ on the original table t1, instead of the alias t1_alias.&lt;/p&gt;

&lt;h5&gt;
  
  
  Recognition of Read Operations in CREATE, UPDATE, DELETE Queries
&lt;/h5&gt;

&lt;p&gt;Not just the primary operation but also implicit operations within a query are considered.&lt;br&gt;
For instance, the following SQL query&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;INSERT INTO t1 (a) SELECT a FROM t2 INNER JOIN t3 USING (id) WHERE t3.b = 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;is counted as INSERT operation for t1, and READ operation for t2 and t3.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Grouping SQL queries by Normalized SQL
&lt;/h3&gt;

&lt;p&gt;This feature groups SQL queries by Normalized SQL, which is a uniform format of SQL statement.&lt;/p&gt;

&lt;h4&gt;
  
  
  How Normalization works
&lt;/h4&gt;

&lt;p&gt;Normalization works similarly to &lt;a href="https://docs.percona.com/percona-toolkit/pt-fingerprint.html"&gt;pt-fingerprint&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;For instance, consider the following set of SQL queries:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT * FROM users WHERE id = 1
SELECT * FROM users WHERE id = 2
SELECT * FROM users WHERE id = 3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These are normalized into a uniform format:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT * FROM users WHERE id = ?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Visualization in Devtools panel
&lt;/h4&gt;

&lt;p&gt;This is displayed in the Devtools panel as follows.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbuznqujq0laguno3zh3x.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbuznqujq0laguno3zh3x.jpg" alt="Normalized" width="800" height="236"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Usefulness
&lt;/h4&gt;

&lt;p&gt;This feature is helpful to detect so-called N+1 queries, but not limited to SELECT statements.&lt;/p&gt;

&lt;h4&gt;
  
  
  Details
&lt;/h4&gt;

&lt;p&gt;Other DML queries are normalized in the same way like the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;INSERT INTO users (name) VALUES (?)
UPDATE users SET name = ? WHERE id = ?
DELETE FROM users WHERE id = ?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Detailed HTTP request / response data
&lt;/h3&gt;

&lt;p&gt;rack-dev_insight captures detailed HTTP request and response data, displayed in a Devtools panel similar to Chrome's network panel.&lt;br&gt;
It currently supports the net-http gem, with future plans to include more HTTP clients, GraphQL, and gRPC.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2xynytf10xi8c8pfivd5.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2xynytf10xi8c8pfivd5.jpg" alt="HTTP" width="800" height="620"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Functional devtools panel
&lt;/h3&gt;

&lt;p&gt;The Devtools panel has the following features:&lt;/p&gt;

&lt;h4&gt;
  
  
  Editor integration
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Open files directly in your editor by clicking their paths in the backtrace.&lt;/li&gt;
&lt;li&gt;Set up path mapping between local and remote file systems for seamless navigation.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwxkwwm8lfda7hkh5le5i.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwxkwwm8lfda7hkh5le5i.jpg" alt="Settings" width="599" height="499"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Recording control
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Start or stop data recording, and flush recorded data, similar to the functionality of Chrome's network panel.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Sorting by columns
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Easily sort data by clicking on column headers for quick organization and analysis.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What is next?
&lt;/h2&gt;

&lt;p&gt;If you are interested in this tool, please try it out! I would love to hear your feedback.&lt;br&gt;
The following enhancements are currently under consideration:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Additional options to normalization format&lt;/li&gt;
&lt;li&gt;Recording only the specified block&lt;/li&gt;
&lt;li&gt;Support for HTTP clients other than net-http&lt;/li&gt;
&lt;li&gt;Support for GraphQL and gRPC&lt;/li&gt;
&lt;li&gt;Support for other SQL dialects such as Microsoft SQL Server&lt;/li&gt;
&lt;li&gt;Alerting and reporting&lt;/li&gt;
&lt;li&gt;Background job (remote machines) support&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Stay tuned for more updates. Your suggestions and ideas are always welcome.&lt;/p&gt;

&lt;p&gt;Thank you for your time and interest!&lt;/p&gt;

</description>
      <category>ruby</category>
      <category>rails</category>
      <category>gem</category>
      <category>extensions</category>
    </item>
  </channel>
</rss>
