<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Matej Minárik on Medium]]></title>
        <description><![CDATA[Stories by Matej Minárik on Medium]]></description>
        <link>https://medium.com/@math3v?source=rss-ddc866b9164e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*plFsSEb0Li6Sz863p9fcQw.jpeg</url>
            <title>Stories by Matej Minárik on Medium</title>
            <link>https://medium.com/@math3v?source=rss-ddc866b9164e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 21:50:40 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@math3v/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How Productboard monitors frontend applications]]></title>
            <link>https://medium.com/productboard-engineering/how-productboard-monitors-frontend-applications-ceace8eacc40?source=rss-ddc866b9164e------2</link>
            <guid isPermaLink="false">https://medium.com/p/ceace8eacc40</guid>
            <category><![CDATA[monorepo]]></category>
            <category><![CDATA[monitoring]]></category>
            <category><![CDATA[logging]]></category>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[error-handling]]></category>
            <dc:creator><![CDATA[Matej Minárik]]></dc:creator>
            <pubDate>Mon, 02 Aug 2021 09:55:22 GMT</pubDate>
            <atom:updated>2021-08-02T10:10:14.828Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Fire alarm" src="https://cdn-images-1.medium.com/max/1024/1*0kt11IGiqeHDqEAbsQw2ng.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@teracomp?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Dave Phillips</a> on <a href="https://unsplash.com/s/photos/alarm?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>“No matter how careful or good you are, sh!t will happen.” — Anonymous</p><p>And that is correct! Network glitches, deployment glitches, dependencies upgrades, developer’s carelessness or just small data inconsistencies. There’s plenty of stuff in web development that can go wrong, and it will go wrong at some point. What’s far more important than trying to prevent anything from going south is having solid monitoring in place and clear processes to follow.</p><p>At Productboard, we already have 5 different teams that contribute to <a href="https://medium.com/productboard-engineering/scaling-monorepo-to-infinity-and-beyond-79bed3d302b2">our frontend monorepo</a>. There are over 290 NX libraries used throughout the applications, where different teams are responsible for different sets of libraries or flows. Solid monitoring and clear ownership are crucial to future growth.</p><p>We originally used <a href="https://rollbar.com/">Rollbar</a> as our logging and exception monitoring platform of choice. Rollbar is a great tool and was working just fine for quite some time. However, when anyone wanted to find out more about the current situation on production, Rollbar was not much help. A pile of log messages and random errors got mixed in with really important issues affecting our customers. We needed to improve this!</p><p>What I truly enjoy about Productboard is that when we realize something can be improved and has a reasonable price-to-value ratio, nobody is going to stop you from taking a stab at it. On the contrary, different people in different roles will support you and sponsor your initiative. Productboard engineers Michal Těhník (<a href="https://github.com/MicTech">@MicTech</a>) and Jakub Beneš (<a href="https://github.com/jukben">@jukben</a>) as well as lower and upper management played a crucial role in this initiative, and I would like to thank them for their support! Having this kind of sponsorship empowers everyone not only to improve technical aspects within an organization they care about, but also to grow both personally and professionally.</p><p>As with all other technical initiatives, I <a href="https://medium.com/productboard-engineering/how-we-revamped-our-rfc-process-at-productboard-9368819ebe06">drafted an RFC</a> and shared it with the rest of my colleagues. After further analysis of the current state and a number of discussion, we realized we were dealing with two issues instead of one:</p><ol><li>Mixing logging and exception monitoring services into one tool was generating too much noise</li><li>There was a clear lack of ownership as to which tribe/team/person is the best candidate for taking care of an incident should one appear</li></ol><h3>Logging</h3><p>Logging takes care of any messages or errors that are handled, and we just want to record a trait that a certain scenario occurred.</p><p>“The user should be always defined here, but let’s make sure by adding a check and logging an error here.” — a Productboard developer</p><p>Our frontend monorepo offers a <em>Logger</em> service, which supports logging messages and additional properties. In the development setup, it only forwards the messages to the <em>console</em> object, which logs them to the developer tools console. We decided to use <a href="https://www.datadoghq.com/">Datadog</a> in staging and production environments. Datadog is a great tool that supports all kinds of advanced monitoring, pre- and post-processing, aggregating, filtering, and grouping of logs based on your needs. We use Datadog for <a href="https://medium.com/productboard-engineering/countering-microservice-disasters-5a8f957803cb">our backend microservices</a>, so it was a natural choice for us to handle logs coming from the frontend monorepo.</p><p>That’s nice pal, you might be thinking to yourself, but how can you ensure a shared level of ownership if different teams work on different parts of the monorepo?</p><p>Great question! I’m glad you asked. Let’s pretend there is a spike of error logs after a recent deployment. How could either the system or the person on-call know who to notify about this? Sure, we can ping everyone, but that’s a huge hassle. At first, we considered having different <em>Logger</em> factories that would just know the ownership based on the current library. However, we wanted to have a more fine-grained granularity and avoid larger manual or even semi-automatic refactoring.</p><p>This was precisely why we decided to go a different route. There is a relatively simple piece of engineering that parses the <a href="https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/creating-a-repository-on-github/about-code-owners">CODEOWNERS file</a>, finds all occurrences of the <em>Logger</em> method calls, and attaches the corresponding team to the message.</p><p>Since we were already using Datadog, we simply added a pre-processing rule that extracts this ownership information from the log and makes it a searchable property of all of our logs. Now it enables us to create custom-alerting rules that notify the relevant owners during a spike.</p><h3>Exception monitoring</h3><p>Exception monitoring takes care of any unhandled errors. Luckily, there are great solutions out there that help you catch these traps. We decided to use <a href="https://sentry.io/welcome/">Sentry</a>. There were multiple reasons for this, but the main one was that Sentry has the concept of ownership baked in. This feature is called <a href="https://sentry.io/features/owners/">Issue Owners</a>. It lets us define custom-matching rules based on the URL, associated tags or originating file, which goes hand-in-hand with the CODEOWNERS file for us. This works great for 90% of new issues reported to Sentry. It automatically assigns an owner based on our custom rules and sends an e-mail or a notification right away.</p><p>Apart from Issue Owners, Sentry has a pretty nice UI, great search capabilities, and awesome integration of <a href="https://docs.sentry.io/product/releases/">Releases</a>. With Releases, it’s easy to benefit from features like “Mark as fixed in current/next release” or easily search for the original release that introduced a particular issue. It even allows us to track the health of the current release and perform an automatic revert if anything goes south.</p><p>Last, but definitely not least, Sentry offers great support for custom <a href="https://docs.sentry.io/product/alerts/">Alerts</a>. We have different Alerts in place. My favourite one is a Slack notification that’s sent out every time the application renders an error page. If it occurs for more than 10 users, we immediately notify the engineer on-call who is responsible for mitigating the incident.</p><h3>Parting words of wisdom</h3><p>The future is bright! We will be tweaking our internal monitoring and alerting rules for a little while, but I’m very happy about the current progress and improvements we made. The end game with Sentry at Productboard is that developers shouldn’t even know there is an exception monitoring tool. It just works on its own and lets you know if something’s wrong. Maybe we’ll implement/enable automatic reverts at some point in the future, who knows.</p><p>What is your setup for frontend monitoring? Let us know in the comments, or write me an email.</p><p><em>Interested in joining our growing team? Well, we’re hiring across the board! Check out our </em><a href="http://bit.ly/CareerSiteMediumEngineering"><em>careers page</em></a><em> for the latest vacancies.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ceace8eacc40" width="1" height="1" alt=""><hr><p><a href="https://medium.com/productboard-engineering/how-productboard-monitors-frontend-applications-ceace8eacc40">How Productboard monitors frontend applications</a> was originally published in <a href="https://medium.com/productboard-engineering">Productboard engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Solving N+1 Query in QraphQL]]></title>
            <link>https://medium.com/@math3v/solving-n-1-query-in-qraphql-f981b8c72ac0?source=rss-ddc866b9164e------2</link>
            <guid isPermaLink="false">https://medium.com/p/f981b8c72ac0</guid>
            <category><![CDATA[optimization]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[graphql]]></category>
            <category><![CDATA[api]]></category>
            <dc:creator><![CDATA[Matej Minárik]]></dc:creator>
            <pubDate>Wed, 13 Nov 2019 08:31:49 GMT</pubDate>
            <atom:updated>2019-11-13T08:31:49.873Z</atom:updated>
            <content:encoded><![CDATA[<p>The N+1 query is a well-known <a href="https://semaphoreci.com/blog/2017/08/09/faster-rails-eliminating-n-plus-one-queries.html">issue</a>, present not only in Rails’s ActiveRecord. The basic idea is that you want to display Addresses based on some query and associated Users. A user can have multiple addresses associated and every address belongs to only one user. We could do something like this:</p><pre># controller<br>addresses = Address.where(country: “Slovakia”)<br>render :view, locals: { addresses: addresses }</pre><pre>&lt;%# view %&gt;<br>&lt;% addresses.each do |address| %&gt;<br>  &lt;p&gt;&lt;%= address.user.name %&gt; lives in &lt;%= address.city %&gt;&lt;/p&gt;<br>&lt;% end %&gt;</pre><p>Most probably, you’ll end up with n queries for the users and one query for the addresses (N+1).</p><pre>Address Load (2.1ms) SELECT “addresses”.* FROM “addresses” WHERE “addresses”.”country” = $1 [[“country”, “Slovakia”]]</pre><pre>User Load (0.9ms) SELECT “users”.* FROM “users” WHERE “users”.”id” = $1 LIMIT 1 [[“id”, 10]]<br>User Load (1.7ms) SELECT “users”.* FROM “users” WHERE “users”.”id” = $1 LIMIT 1 [[“id”, 11]]<br>User Load (1.3ms) SELECT “users”.* FROM “users” WHERE “users”.”id” = $1 LIMIT 1 [[“id”, 12]]<br>User Load (1.3ms) SELECT “users”.* FROM “users” WHERE “users”.”id” = $1 LIMIT 1 [[“id”, 13]]</pre><p>This is obviously not what we wanted. It introduces additional load on our database, server and increases our application’s response time. In Rails, we can solve this by using includes, preload or eager_load. There is also a great gem, called <a href="https://github.com/flyerhzm/bullet">Bullet</a>, which will help you solve this issue. So, how does this issue look like in GraphQL?</p><pre>{<br>  address(country: “Slovakia”) {<br>    user {<br>      name<br>    }<br>  }<br>}</pre><p>GraphQL traverses our query and loads the data in order. So it fetches the first address and its user field, then the second one, etc. We’ll actually end up with the same n queries for the users and one query for the address. N+1 again!</p><h3>Solving the N+1 Query</h3><p>Recently, I wanted to solve this issue in a project I’m working on. I did some research and came to a conclusion, that the de-facto solution in the Rails community is the graphql-batch gem. To be honest, I think the documentation could include more examples. I was not able to tackle every N+1 query we had in our API, but the gem is quite simple to integrate and it did do the job for some low-hanging fruit. <a href="https://github.com/Shopify/graphql-batch#installation">Installation</a> is straightforward, <a href="https://github.com/Shopify/graphql-batch#usage">integration</a> simple and understandable. I ended up using the <a href="https://github.com/Shopify/graphql-batch/commit/058213b78775c791135bf7db784b7d10007d5ade">Association Loader</a> for our associations. So if an Address belongs to a User, you can use it as follows:</p><pre>Types::Address = GraphQL::ObjectType.define do<br>  name ‘Address’<br>  field :user, Types::User do<br>    resolve -&gt;(address, _, _) do<br>      Loaders::Association.for(Address, :user).load(address)<br>    end<br>  end<br>end</pre><p>The GraphQL Batch Gem will pause the actual fetching from the DB. Instead, it will accumulate all the IDs, that need to be retrieved and then fire a single query like this:</p><pre>User Load (2.1ms) SELECT “users”.* FROM “users” WHERE “users”.”id” IN (10, 11, 12, 13)</pre><p>Happy N+1 Hunting!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f981b8c72ac0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Most Useful Git Shortcuts]]></title>
            <link>https://medium.com/@math3v/the-most-useful-git-shortcuts-5867d27e4c65?source=rss-ddc866b9164e------2</link>
            <guid isPermaLink="false">https://medium.com/p/5867d27e4c65</guid>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[shortcuts]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[development]]></category>
            <dc:creator><![CDATA[Matej Minárik]]></dc:creator>
            <pubDate>Sat, 09 Nov 2019 13:25:29 GMT</pubDate>
            <atom:updated>2019-11-09T13:25:29.506Z</atom:updated>
            <content:encoded><![CDATA[<p>Git is surely one of the most valuable tools in any developer’s toolkit. I was using SourceTree a lot, but recently switched to command line interface and I don’t think I will go back.</p><p>Now I’m using Oh my ZSH, which comes with some awesome shortcuts for git. In this article, I will describe some of the most useful ones for me.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AtfLyr8TCCPeoMUsSYap8Q.jpeg" /><figcaption>Productivity is the key</figcaption></figure><h3>Fast Commits</h3><pre>gcam ‘My Commit Message’ # git commit -a -m<br>ggp                      # git push origin $(current_branch)</pre><p>You should commit often! Git is an awesome safety net and a tool, which allows multiple developers to work on the same project. However, you need to commit often, if you want to make the best out of it. These two commands enable you to commit and push the files, which are modified and stashed. The biggest gotcha of this command, is that it won’t commit new files, unless you stash them with <em>git add</em>.</p><h3>Fixing The Latest Commit</h3><pre>gcan! # git commit -v -a -no-edit -amend<br>ggfl  # git push -force-with-lease origin $(current_branch)</pre><p>Typos, broken alignments, wrong comments, or just silly mistakes happen to the best of us. These two commands enables you to commit the files, which are modified and stashed. The previous commit will be amended and its commit message reused. The gotcha here is that we’re changing the commit history, because we are not creating the new commit, but changing the latest one. Therefore, we need to force push this commit. Git push force-with-lease option lets you force push your local changes, while making sure that you won’t overwrite someone else’s work. Force with lease option verifies that the remote latest change, is the same as the local one. In other words, no one has committed on top of your latest commit and therefore it is safe to force push your fix.</p><h3>Merging Latest Master Branch Into Your Feature Branch</h3><pre>gfa # git fetch -all -prune<br>git merge origin/master</pre><p>So, you’re working for a couple of days on this new awesome feature. If there are more developers working on the same project, it’s only natural that your feature branch diverges from master. Not only will these commands fetch the latest changes, but also delete/prune the branches which have been removed on the remote. This keeps your local repository nice and clean. Note, that if there are some conflicts, the merge will fail. It will also list all the files in which you need to manually resolve conflicts. Once you’re done, you can add them and run git commit.</p><h3>Other Useful Git Shortcuts</h3><pre>gaa    # git add — all<br>gclean # git clean -fd<br>gcm    # git checkout master<br>gco    # git checkout<br>gcb    # git checkout -b<br>ggsup  # git branch — set-upstream-to=origin/$(current_branch)<br>ggl    # git pull origin $(current_branch)<br>glg    # git log — stat — max-count=10</pre><p>And my secret weapon is an alias.</p><pre>alias gbd=’gb | grep -v master | grep -v \\* | xargs git branch -D’</pre><p>This bad boy will remove all your local branches, except for the current one and master.</p><p>Happy Source Versioning!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5867d27e4c65" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>