<?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[DealerOn Dev - Medium]]></title>
        <description><![CDATA[Syndicated from https://dev.to/dealeron | On the DealerOn Dev Team, we strive to be the industry leader in code quality, innovation, and culture. The author’s views expressed in this publication are endorsed by DealerOn. The author’s views elsewhere may not be. - Medium]]></description>
        <link>https://medium.com/dealeron-dev?source=rss----c3eae8609d01---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>DealerOn Dev - Medium</title>
            <link>https://medium.com/dealeron-dev?source=rss----c3eae8609d01---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 02:05:21 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/dealeron-dev" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[What does Scrum mean to you?]]></title>
            <link>https://medium.com/dealeron-dev/what-does-scrum-mean-to-you-344bc6c8501b?source=rss----c3eae8609d01---4</link>
            <guid isPermaLink="false">https://medium.com/p/344bc6c8501b</guid>
            <category><![CDATA[teamwork]]></category>
            <category><![CDATA[agile]]></category>
            <category><![CDATA[project-management]]></category>
            <category><![CDATA[scrum]]></category>
            <dc:creator><![CDATA[DealerOn Dev Team]]></dc:creator>
            <pubDate>Fri, 26 Jul 2019 13:01:02 GMT</pubDate>
            <atom:updated>2019-07-26T13:01:02.021Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*IfbBKMkAwij2tYMm" /><figcaption>Photo by <a href="https://unsplash.com/@quinoal?utm_source=medium&amp;utm_medium=referral">Quino Al</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><strong>Scrum</strong> (n): A framework within which can address complex adaptive problems, while productively and creatively delivering products of the <strong><em>highest possible value</em></strong>.</p><p>In my <a href="https://dev.to/dealeron/scrum-a-constant-in-a-world-of-change-2dlh">previous article</a> I expressed the beauty of engagements within ceremonies between Scrum team members but that is only the surface the greatest qualities that Scrum can offer.</p><blockquote>“Scrum is simple, <strong>doing </strong>Scrum is hard”</blockquote><p>This quote from <a href="https://www.scrumguides.org/docs/scrumguide/v1/scrum-guide-us.pdf">Scrum Guide</a> lets us know that while the framework of Scrum may be simple to understand, it is indeed difficult to master. That is something I keep in mind whenever there is someone that comes to me who is interested in learning more about Scrum.</p><p>When I introduce myself to people and the inevitable question of <em>“What do you do for work?”</em> arises, when replying <em>“I am a Scrum Master”</em>, I often receive a strange and puzzled look in return.</p><p>Other than the highest possible value being a primary focus of Scrum, <strong><em>people</em></strong> will always be one as well. We must always remember that without our fellow people, we will not be as effective as we could be. That is why I am fascinated to have a discussion with people that are intrigued with Scrum and what it can offer.</p><p>Recently at <a href="https://www.dealeron.com/join-our-team/">our company</a>, I was approached by two fellow co-workers that are Project Coordinators in a department that I once worked with often, but am are not as tightly coupled with in my new position. The bright and enthusiastic young lads had some questions about Scrum and how it may be integrated into their processes that were ever-changing.</p><p><em>“Does Scrum fit into what we are currently doing?”</em> was the question put plainly, after a brief introduction. Their department had recently integrated with another department not only within work processes but also physical seating as well. They both needed to become more aware of their respective department’s processes, how to incorporate them together, and to simply learn more about one another.</p><p>Of course, this was a perfect instance in which they could apply Scrum framework towards communication and a common goal, and I let them know about the ceremonies which would allow them to benefit from high-quality engagements along with transparency during this time of transition. Both of the gentlemen were inspired and I’m happy to say not only did they start implementing Scrum practices within their department, but they also went quickly went on to become Scrum certified, music to a fellow Scrum Master within the organization ears!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*LdX-HLsi_rglhKas.jpeg" /></figure><p>On another occasion, this one not being work related as it was a 5-year old’s moon bounce birthday party, I also somehow stumbled across a conversation surrounding Scrum. As the other dads surrounded the cooler drinking some ice-cold beers on that newly hot summer day, the topic of work and travel came about. One of the fathers informed of his recent trip overseas and how his company would like him to become Scrum certified to help install the framework into the development team he manages and he was reluctant as he felt it was being pushed on him. I let him know how I too was once unsure of what I was getting into as I signed up for my Scrum Certification, but I also informed him how enlightened I was after completing my class with <a href="https://www.foxhedgeltd.com/">Fox Hedge Ltd.</a></p><p>While the reluctant manager made it clear that he preferred the <a href="https://en.wikipedia.org/wiki/Waterfall_model">Waterfall model</a> as we continued our discussion, he later admitted that there is one thing he appreciated about Scrum, <em>“Fail-fast, I want to know that we aren’t wasting our time quickly!”</em>. <a href="https://en.wikipedia.org/wiki/Fail-fast"><strong>Fail-fast</strong></a> is a system design that allows notifications during error detecting in order to allow it to be addressed accordingly. While this may align more with hardware or software design, the same can be the case between Scrum and the interactions during the high-quality engagements within our teams. When a team is communicating most effectively, they will quickly know whether a process or a system is not capable of delivering towards a goal and will inform the others so proper adjustment can be made… <strong><em>transparency!</em></strong></p><p>The Waterfall model may not allow for that same quick realignment for appropriate change to be made, as bureaucracy or previously decided determinations may be part of contracts in place. That can lead to missed deliverables or deadlines without anyone being able to communicate amongst the parties involved to notify that the prearranged work will not meet objectives. I was glad to know and inform him that at our company, we recognize quickly when we must pivot within a project and even though it can be difficult, our team members quickly adapt to produce high-quality development… <a href="https://www.agilealliance.org/agile101/"><strong><em>Agile!</em></strong></a></p><p>The exchanges between myself, the Project Coordinator coworkers, along with the dad at the children’s birthday party allow me to be cognizant that not only are the opportunities for improvements in transparency, collaborating, and vision present within our organization, they are present at many other organizations as well. Many times, I see those same phrases indicated as I attend webinars and other attendees have questions along those lines. I think to myself <em>“We are not the only ones!”</em>, and it is good to know that other companies, even those who are successful in implementing Scrum properly within their teams, also have these areas to continue improving upon. That is why I am excited to start the collaborative effort between our various teams and departments by initiating the concept and practice of the</p><p>Within the near future, a vast amount of our team leads will be meeting for product collaboration, this will be a key time for our people to unify the vision, road map, release plan, and architecture, as well as address any impediments the teams have not been able to resolve within their scope. During this time, I will recollect on my discussions amidst my coworkers, the skeptical Waterfall-preferring manager at the birthday party or any other conversation that I have had with people before and how we can improve in unison.</p><p>are who we work for and with, whether it be people on your team, the people you are building your product for, or the people you will never even know you had an influence on. Listening to these people, keeping them in mind as you work, and solve problems to make an improvement upon the population is the underlying goal and the vision. That is what Scrum means to me… the opportunity to engage with people, make more informed decisions, and not forgetting to learn from each other,</p><p>People over Process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*e1Lo0M-vTQhRqOJM.jpeg" /></figure><p><em>Originally published by </em><a href="https://medium.com/u/f4282af7eb42"><em>Aaron Thumma</em></a><em> at </em><a href="https://dev.to/dealeron/what-does-scrum-mean-to-you-3gn5"><em>https://dev.to</em></a><em> on July 12, 2019.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=344bc6c8501b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dealeron-dev/what-does-scrum-mean-to-you-344bc6c8501b">What does Scrum mean to you?</a> was originally published in <a href="https://medium.com/dealeron-dev">DealerOn Dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is a Development tool?]]></title>
            <link>https://medium.com/dealeron-dev/what-is-a-development-tool-83b588dd387c?source=rss----c3eae8609d01---4</link>
            <guid isPermaLink="false">https://medium.com/p/83b588dd387c</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[csharp]]></category>
            <dc:creator><![CDATA[sohjsolwin]]></dc:creator>
            <pubDate>Fri, 19 Jul 2019 13:01:01 GMT</pubDate>
            <atom:updated>2019-07-19T13:01:01.182Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NaLJNpW3qU_L3I9w" /><figcaption>Photo by <a href="https://unsplash.com/@pjswinburn?utm_source=medium&amp;utm_medium=referral">Philip Swinburn</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Every developer and engineer has a different set of tools they use. Working primarily in the .NET landscape, my tools frequently include Windows, Visual Studio, VS Code, Git, etc. Typically, the more green a developer is, the more rigid their definition of a “development tool” and the fewer items they’ll install when getting started. I’d like to introduce you to my process for getting a dev environment set up, tell you about some of the ways I use my “development tools” and possibly help expand your definition of “development tool” in the process.</p><h3>Gitting Started</h3><p>At a new job, or when getting a new computer, developers are often presented with needing to set up their “Dev Environment”. This can often be a tedious process, requiring numerous installs and a long, long wait time while everything gets configured. Starting with the blank slate of a newly installed and domain-attached can be daunting, especially for a new hire. Thoughts of “What do I install first?” and “Which items will make me productive the fastest?” often race into their minds while they desperately try not to look useless for the first several hours of their new job.</p><p>It can be stressful, but I’ll let you in on a little (slightly off topic) secret: <strong>No company expects you to be productive in the first few hours</strong>. You’re expected to learn and discover in that time frame. Asking questions, reading through the numerous documents and wikis you’ll be presented with, and generally being curious is your job for the first day and often for the first week.</p><p>In order to maximize that time that you’re spending getting up to speed, there are some tools you can use to aide in setting up your computer while you’re reading those docs and wandering around asking “what was the password for the WiFi again?”.</p><h3>Chocolatey</h3><p><a href="https://chocolatey.org/">Chocolatey</a> is by far the #1 development tool I use. Not in the quantity of time I spend using it, but in the quantity of time I <em>save</em> by using it. Combined with <a href="https://gist.github.com/">Github Gists</a>, you can have a very powerful combination that will save you an immense amount of time when setting up your new PC. You can browse and search through the full list of packages available here: <a href="https://chocolatey.org/packages">https://chocolatey.org/packages</a></p><p>Chocolatey is essentially a package manager, similar to Brew on Mac or APT on Debian/Ubuntu. It allows installing and updating a vast number of programs via the command line or an optional user interface. It’s simple to install and saves immense amounts of time when installing multiple programs at once, like when setting up a new computer. The typical set of packages I’ll install on a new computer is shown in <a href="https://gist.github.com/sohjsolwin/9e7f45ce150e7900f25be33b9ca08500">this gist</a>.</p><p>The -y parameter attached to the Chocolatey command tells it to accept the packages as it&#39;s installing, otherwise you would need to type in Y for each package in order for the installation to continue. Without that parameter, the unattended install we&#39;re trying to do becomes useless.</p><p>While Chocolatey is happily churning away downloading and installing these packages, you’re now free to spend your time reading up on that documentation or shadowing and asking questions from your fellow coworkers while your machine gets set up. The list of applications you install in this initial run of Chocolatey may not be every application you’ll need in your development career, but it should take you most of the way there and allow you to be active while everything is getting set up instead of stuck there banging your head on the keyboard while the progress bar ticks forward on it’s 12th minute of 37 seconds remaining.</p><h3>VS Code</h3><p>I can hear you now. “ <a href="https://code.visualstudio.com/">VS Code</a> is obviously a development tool.” you say, and you’re absolutely right. It <em>is</em> already a development tool, but it’s uses in development extend beyond just the IDE components it contains.</p><p>While my primary development is done through Visual Studio, I always have a window of VS Code open along side it. Code has quickly become my favorite text editor and has surpassed Notepad++ for day to day usage. One of the primary things I’ll do with it is text search. I’ll open up the root folder where I check out all my repositories to and use the powerful, and fast, text search feature of Code to search through all of my repo’s code at once. Often times I’m looking for usages of a table or package that might be shared across projects that I don’t frequently work in or that my team doesn’t maintain. Notepad++ used to be my goto for this, but the search feature when looking across multiple files in multiple directories just became so slow and cumbersome that it was unusable. Thankfully, Code doesn&#39;t seem to have that problem at all and is able to search through everything in around 30-45 seconds, whereas N++ would typically take upwards of 15 minutes.</p><p>Not only is Code good for searching through large amounts of text, but it’s good for editing it too.</p><p>While working through refactors, I’ll often need to update a large amount of items from a switch statement or a large block of if statements at once. This can be quite tiresome to do individually by hand, but thanks to the robust multi-cursor capability of Code, I can make these edits in bulk instead of one by one.</p><p>In the following example, we had several large switch statements operating off of Int values. There was also an Enum which contained these values but was unused in the switch statements for unknown (read: legacy) reasons. In a recent refactor, we had determined that the Enums would be better served by actual objects which contained all of the extra data we were constantly binding the Enum values to instead of keeping that explicitly related information spread across numerous locations.</p><blockquote><em>I’ve changed a few of the names for this example, but the same principle and pattern is there.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*k7Xsix-L2IopyR2H.gif" /></figure><p>In the above gif, you can see me using the multi-cursor ability to simultaneously remove all of the syntax surrounding the case statements, which I then copied into a mapping spreadsheet (more on that in a second) to link the enum values to the names needed for the new object-based class.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*w-eeqcCEnQFn784v.gif" /></figure><p>Next, I cleaned up the artifacts from the mapping spreadsheet and began turning each of the previous case groups and return statements into if statements, using the name of the return value as part of the name for the list being evaluated in the if statement.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*6pp9rmdSuD4ReFvj.gif" /></figure><p>I then wrap each of the groups of cases in a private static readonly array, using the same multi-cursors established based on the return lines. Once they&#39;re all wrapped, I cut out the if statement lines and group them together up top.</p><p>From here, all that’s left is to update the name of the variable in use on each of the new case group arrays to match the values in the if statements at the top which is quick to do manually. I haven&#39;t found a good way to do that using multi-line cursors yet, but if you have an idea I&#39;m interested to hear it.</p><p>Taking this approach to the refactor makes it much less error prone in regards to typos or list transposition, and removes a fair amount of the human factor and fatigue related to looking back and forth between to walls of text trying to match items up.</p><h3>Excel</h3><p>I mentioned a “mapping spreadsheet” earlier. For this, I’m using Excel. Since I knew I would have several of these large switch statements to convert, and that linking up an int to a name in a list is very tedious and error prone, I opted for creating a spreadsheet to help me out with this.</p><p>I set up a “table” in the spreadsheet with 2 columns, one for the int value and one for the name. I then configured another column with a VLOOKUP function to use that table to find and return the name based on the int specified in a fourth, input, column. I also added a CONCAT function to the formula as well to put the results in a format closer to what I needed.</p><p>The end result is a very useful tool for matching up a number of ints to their object-named values while removing the potential for a mis-type or bad copy/paste.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/676/0*oU1_HzkKVJRQxGsX.gif" /></figure><p>The last step is to copy both columns, since the formula column has the value you actually want, but the input column has the return statements in them, and paste back into your text editor over the top of the previous input.</p><p>I use Excel frequently when I need to do large lookups like that, or when I’m needing to work with or manipulate various amounts of data. The CONCAT and other similar functions are useful for building groups of switch or if statements, SQL scripts, and any other type of script or code block that has a number of separate values you need to combine in some way.</p><h3>Commit to Memory</h3><p>These were a couple of the tools I find myself using frequently alongside the more traditional “development tools” like Visual Studio or Git. I’ve found them immensely useful over the years and have saved myself considerable time by learning how the tools in my toolbox can be used and abused in interesting ways. Admittedly, the uses I described above are some of the tamer uses for tools, but still useful nonetheless. What are some tools that you use in non-standard or unintended ways. I’m interested to see, and learn, some new tools I can add to my list.</p><p><em>Originally published at </em><a href="https://dev.to/dealeron/what-is-a-development-tool-46g"><em>https://dev.to</em></a><em> on July 5, 2019.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=83b588dd387c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dealeron-dev/what-is-a-development-tool-83b588dd387c">What is a Development tool?</a> was originally published in <a href="https://medium.com/dealeron-dev">DealerOn Dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mercurial Matters]]></title>
            <link>https://medium.com/dealeron-dev/mercurial-matters-21e2ff80189d?source=rss----c3eae8609d01---4</link>
            <guid isPermaLink="false">https://medium.com/p/21e2ff80189d</guid>
            <category><![CDATA[keyvault]]></category>
            <category><![CDATA[powershell]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[DealerOn Dev Team]]></dc:creator>
            <pubDate>Fri, 12 Jul 2019 13:52:37 GMT</pubDate>
            <atom:updated>2019-07-12T13:47:56.468Z</atom:updated>
            <content:encoded><![CDATA[<p>So, you want to hear another story, eh? One filled with DevOps and DevOps-ey things? Ha! I’ve got a story for you. This is a tale of key vaults, automation, and getting things done.</p><h3>The Vault</h3><p>It starts with an <a href="https://docs.microsoft.com/en-us/azure/key-vault/key-vault-whatis">Azure Key Vault</a>. This is a native service that stores application secrets. Traditionally the application.config or web.config, for a service or website respectively, contains connection strings that your code requires in order to run. This is fine, however doing this is equivalent to writing your passwords on a post-it note stuck somewhere underneath your keyboard (I&#39;m looking at you, Jerry!). If anyone gets to your desk they&#39;ll know where to look for it, and once they grab your connection strings it&#39;s game over.</p><p>To combat this, folks will often encrypt it. The <em>drawback</em> to this though is that the encryption key is often on the machine, which isn’t much better. If the Nuget package or whatever mechanism you are using to decrypt it at runtime isn’t kept updated, your application is likely to break because it can’t read the config file, and it leaves you with what looks like <a href="https://en.wikipedia.org/wiki/Matrix_digital_rain">Matrix code</a> in your files (this has happened to me, and it’s terrifying). The best place to go then is Azure Key Vaults (AKV) to store them in a specially encrypted external database which allows for not only credential-based authentication, but use of a unique-to-the-individual SSL certificate for authentication to avoid having to write your password somewhere and remember it.</p><h3>Empowering Mercury</h3><p>One of our development teams(Mercury) had recently switched to using AKV for something new that they were creating. They needed to add a lot of secrets to their new vaults and it’s quite honestly very tedious. The portal generally allows you to upload 1 at a time, and it’s a lot of clicking around. Since you’re likely copy-pasting all the values in, it’s easy to copy the wrong one in. So I gave them a workaround I had used on previous projects:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d132295363ba8268a764de2f1db7a59e/href">https://medium.com/media/d132295363ba8268a764de2f1db7a59e/href</a></iframe><blockquote>The PowerShell script that allows upload of multiple secrets.</blockquote><p>Since it’s possible to use special characters in keys and secrets, and secrets can be very long, such as a JSON object, it’s not a great idea to have them be paired in a 2D array, or to try and split a string based on a unique characters.</p><p>The general guidance that I give my coworkers is to make sure you verify the secrets beforehand for validity to ensure that every key has a secret, as secrets are not allowed to be blank (rule of Azure). If there was a mistake they could easily fix the value and re-run this, and if there was a scenario where a secret was given the wrong value, it would just be given a new one and only the new version would be active. They now had one of my favorite scripts, and things were fine for a time.</p><h3>Bad Moon On the Rise</h3><p>Happily armed with their new tool, the Devs got to work. Over the weeks that followed I received requests during the day to upload new secrets to production, as our Devs are not allowed direct change access to those resources. Once I even came in at night after hours to help with a deploy. It was about this time that all of us began to notice the issue: <em>Me</em>.</p><p>It wasn’t that I was a problem, or intentionally holding them back, but rather I was inadvertently holding them back from deploying more often than not because I would usually be in a meeting or otherwise predisposed with something else. Sometimes we realized that the key vault values needed to be changed because they weren’t what we were expecting a few hours later, and I’d need to step in. Every minute I wasn’t available to them was a minute they had to wait to fix the issue.</p><p>Since this was a brand-new process, we didn’t have a lot of existing guidelines in place because we didn’t know how frequently Devs would ask us to make the updates.</p><p>The entire point of DevOps is to be empowering and hands-free, and this was turning into something akin to what large companies have with <a href="https://en.wikipedia.org/wiki/Change-advisory_board">CAB meetings</a>, and the like. None of us expected this simple process to turn out to be this complicated. It had become clear to everyone involved that we needed to implement a better workflow for this, pronto.</p><h3>Enter the Octopus</h3><p>The suggestion came up that we automate this to avoid direct DevOps intercession. Agreeing, I did what I should have done at the start — added the script from above as an executable step within Octopus Deploy to allow updating the AKV. It fit directly into their other deploy procedures, and now Dev is able to deploy key vault updates as they need without worrying about who on DevOps is there to assist. This ended a cycle of what was becoming a 3x-a-week-request-with-the-occasional-wait pain point and turned it into a no waiting, self serve request submission.</p><h3>What are the morals of this story?</h3><h4>Automation does not solve all of your problems.</h4><p><em>It sometimes is not enough to script out the task to make it less tedious. Just because we can does not mean that we should.</em></p><p>There are times when a process still needs to have automation driving it forward so that it doesn’t hold up production, and there are times we are better off not automating things. This is a nuanced process that requires a formula with non-static variables to get close to right: (saved_cost_of_task - time_spent_troubleshooting) &gt; cost_of_task. The amount of time saved by having the automated task combined with the time spent troubleshooting should be greater than the cost of not automating the task itself. If a task saves you a lot of time but you waste more time troubleshooting it than you do having it run, because it&#39;s a complicated process that requires human thought (and assuming you did this in an optimal manner) you&#39;re likely wasting more time than you&#39;d be saving by automating it.</p><p>As an example, I could automate Team City and Octopus to deploy every single SQL script to run on all databases after it successfully goes to production. While this saves time, it wastes a lot of effort troubleshooting: There’s a lot of permutations of scenarios I would have to capture with a deploy process for SQL where the order that I deploy one more more apps in a specific order. The amount of knowledge of the unique scenarios places an unfair burden on Dev, and becomes a detrimental necessity for DevOps to be available to assist. I could write an entirely separate post about this, but I think you get my point.</p><h4>Be prepared to redefine the process.</h4><p><em>We can’t always foresee where or when we will need automation. We need to be willing to periodically take a step back and re-assess our processes and re-align our thinking so that we can make the right decisions.</em></p><p>As time progresses and you grow as a team, the willingness to change needs to exist. Before we started this journey down Key Vault Lane, updates to existing keyvaults were rare and infrequent. As we built more of the application, it became apparent that we had outgrown the process, and like an old pair of pants that no longer fits, we had to go get a new one that fits our needs and still make us look good.</p><p><em>Originally published by Giman Val at </em><a href="https://dev.to/dealeron/mercurial-matters-l7k"><em>https://dev.to</em></a><em> on June 7, 2019.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=21e2ff80189d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dealeron-dev/mercurial-matters-21e2ff80189d">Mercurial Matters</a> was originally published in <a href="https://medium.com/dealeron-dev">DealerOn Dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Integrating Azure AppInsights with NancyFX]]></title>
            <link>https://medium.com/dealeron-dev/integrating-azure-appinsights-with-nancyfx-3af40f2d4ef3?source=rss----c3eae8609d01---4</link>
            <guid isPermaLink="false">https://medium.com/p/3af40f2d4ef3</guid>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[nancyfx]]></category>
            <category><![CDATA[deep-dives]]></category>
            <category><![CDATA[csharp]]></category>
            <category><![CDATA[azure-app-insights]]></category>
            <dc:creator><![CDATA[Andy McKenna]]></dc:creator>
            <pubDate>Fri, 21 Jun 2019 13:01:01 GMT</pubDate>
            <atom:updated>2019-06-21T13:01:01.531Z</atom:updated>
            <content:encoded><![CDATA[<h3>Integrating Azure App Insights with NancyFX</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OEI0h0SVZFRNnQK3jMdjhA.jpeg" /><figcaption>Let’s go right!</figcaption></figure><p>Telemetry fever is sweeping the DealerOn Dev department and the reporting team is riddled with it. We’re starting to integrate <a href="https://docs.microsoft.com/en-us/azure/azure-monitor/app/app-insights-overview">Azure App Insights</a> (referred to as simply “AI” now for brevity) into a number of our products so that the team can identify areas that need improvement as well as let management know what pages are most popular with our users. Our application uses <a href="https://github.com/NancyFx/Nancy/wiki/Documentation">NancyFX</a> for our API framework and when I started researching how to integrate Azure App Insights, I began to look like Homer in the image above. Every article I read assumed you were using ASP.NET Core and talked about how plug-n-play it all was. There was usually some throwaway line about “if you’re using another framework, you’ll have to do a lot of this manually”. This article will show you how to do a lot of that manually.</p><h3>Getting Started</h3><p>The first thing you’ll need is an AI account. This is a <a href="https://docs.microsoft.com/en-us/azure/azure-monitor/app/app-insights-overview#get-started">well covered</a> area so I won’t dwell on it but once you’re done you should have an <strong>Instrumentation Key</strong> that you can save with your other user secrets. Azure <a href="https://docs.microsoft.com/en-us/azure/key-vault/key-vault-whatis">KeyVault</a> is a great solution for that but anything that isn’t hard-coded into your source control will do.</p><p>Secondly, you’ll want to add the <a href="https://www.nuget.org/packages/Microsoft.ApplicationInsights/">Microsoft Application Insights</a> Nuget package to your solution. This will also create an ApplicationInsights.config file in that project. You can either store your <strong>Instrumentation Key </strong>here or load it in code and set it at runtime, depending on your preferences. I chose to wrap the TelemetryClient in another class so that we could mock it out when not in production and handle some of the boilerplate properties we’ll pass each time.</p><h3>Logging Requests</h3><p>When used with ASP.NET Core, the AI library can automatically track incoming requests because it already knows where to find them. We don’t have that luxury here so we need to wire that up ourselves. NancyFX has a few <a href="https://github.com/NancyFx/Nancy/wiki/The-Application-Before%2C-After-and-OnError-pipelines">pipelines</a> that you can add hooks to that will run at a certain time in the request life cycle. We’ll use a base class to add these so we don’t have to remember to include them in every class:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9da4a24f9ae7c28d3d4e6230474f4f19/href">https://medium.com/media/9da4a24f9ae7c28d3d4e6230474f4f19/href</a></iframe><p>The hook methods themselves are not very interesting, they are just grabbing the URL and route information from the NancyContext <strong>ctx </strong>variable and passing them on to our AI client. The start and stop request methods are actually using the StartOperation and StopOperation methods of TelemetryClient because you can tie the request to any sub-telemetry and present them together within the AI portal. This will be explained further in the <a href="#7f39"><strong>Correlation</strong></a><strong> </strong>section</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9f430534d1543f5557b11553a8de1c2f/href">https://medium.com/media/9f430534d1543f5557b11553a8de1c2f/href</a></iframe><p>These are pretty straightforward except for the RequestionOperations object. That’s a dictionary of IOperationHolder&lt;RequestTelemetry&gt; we hold on to so that we have it later to give to StopOperation. Stopping the operation will automatically calculate the duration and send the telemetry to the AI portal.</p><h3>Database Calls</h3><p>If you just dropped the AI client in to your app and let it run, you’d notice that you have a number of Events called <strong>SQL </strong>showing up in the AI portal with nothing else except a processing time. This isn’t terribly helpful because you have no idea what query this is and what parameters it’s using. Good luck optimizing that! Even the ASP.NET Core version of this is a little rough because it requires a secondary program installed on your server that will monitor the IIS process to extract the command text and parameters. The first thing we want to do is throw these right out, they just add clutter and waste bandwidth. A custom ITelemetryProcessor can be used to modify or remove telemetry before it’s sent to the AI portal. Here is a simple one I’m using to remove these SQL events:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/57b0be3cc6d516472cc893460ef1d3f2/href">https://medium.com/media/57b0be3cc6d516472cc893460ef1d3f2/href</a></iframe><p>Now comes the fun part. All of our database queries ultimately end up at a single class that handles the SqlConnections and Dapper. We’ll wrap the database call with an object that we create in a using block so that we know the query is completed when the object is disposed. The method to actually format the parameters object isn’t included but you can implement that however you want.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9f5307e8986384182339f420f576fc75/href">https://medium.com/media/9f5307e8986384182339f420f576fc75/href</a></iframe><p>With this class and your repository call wrapped in it, you’re now logging every query and all the information you need to need to drop right into SSMS and test it or view execution plans.</p><p><strong>Note:</strong> It’s important to point out here that the parameters are viewable by anyone with access to your AI portal. If there’s anything sensitive in the query text or parameters you’ll need to think of a way to exclude or otherwise <a href="https://medium.com/dealeron-dev/-7546d0a69e52?source=friends_link&amp;sk=9e97b05b1997a51e63a7664d4a89cf7e">censor it</a>.</p><h3>Correlation</h3><p>Our AI portal has a list of Requests and Events now but we don’t know which Events were spawned by which Requests. We need a way to tell the Events to tie themselves to a specific Request. You might have noticed that we returned telemetry.Id from our AI client’s StartRequest method. The BeforeHook method that gets that Id is putting it into a special class that stores it for the life of the request. Our AI client’s RecordEvent get’s that RequestId and uses it as it’s ParentId to establish the relationship within the AI portal.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d8e6a5c69e4ef2308ea695cc8996c04a/href">https://medium.com/media/d8e6a5c69e4ef2308ea695cc8996c04a/href</a></iframe><p>This is possible because of the <a href="https://docs.microsoft.com/en-us/dotnet/api/system.threading.asynclocal-1?view=netframework-4.8">AsyncLocal</a>&lt;T&gt; property. All of our endpoints are called with async handlers which means each time BeforeHook sets the request id, it’s in the context of only that request. When our AI client asks for the request id, it’s still within that same original async method for the request and therefore gets the correct one. When you view a request in the AI portal, you should be able to click “View All Telemetry” and see all of the children associated to it like in the screenshot below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/779/1*DkbhHfUUpOCXw6-UpmdcPA.jpeg" /><figcaption>A sample Request and the SQL query it used</figcaption></figure><h3>Errors</h3><p>We’re using our ErrorHook to catch anything that bubbles up and would cause a 500 response. We send the exception to our standard logging library, tell our AI client to send an exception telemetry to the AI portal, and sanitize the response that is returned to the user. NancyFX ships with a slightly strange default error response and sometimes the full stack trace so you’ll want to substitute it with almost anything else.</p><p>Sending the exception to both our normal logger and the AI portal might seem redundant but allows us to see our traffic and errors in one place which will come in handy when we pipe all this data to a dashboard like Grafana.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7588e0c45f0ac55cceb99d220e88b6ea/href">https://medium.com/media/7588e0c45f0ac55cceb99d220e88b6ea/href</a></iframe><h3>Final Results</h3><p>Once you get everything up and running you’ll discover you have a ton of raw data in the AI portal that is great for analyzing individual requests but is hard to see the 30,000 foot view. The other half of this coin is creating a dashboard you can use to visualize the overall trends of your app. My colleague Alex Johnston has some excellent Grafana starting points in his article <a href="https://medium.com/dealeron-dev/exception-handling-and-telemetry-with-postsharp-application-insights-and-grafana-b15809f0f1fb?source=friends_link&amp;sk=89496c56d58ec13b740c8f1d6cd71e73"><em>Exception Handling and Telemetry with PostSharp, Application Insights, and Grafana</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3af40f2d4ef3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dealeron-dev/integrating-azure-appinsights-with-nancyfx-3af40f2d4ef3">Integrating Azure AppInsights with NancyFX</a> was originally published in <a href="https://medium.com/dealeron-dev">DealerOn Dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Write Readable Code]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/dealeron-dev/how-to-write-readable-code-8434c58748a1?source=rss----c3eae8609d01---4"><img src="https://cdn-images-1.medium.com/max/2600/0*Jy3heMl_yP_fQwMO" width="5760"></a></p><p class="medium-feed-snippet">One of the best classic pieces of advice for developers is to write your code as if the next person to maintain it is a violent psychopath&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/dealeron-dev/how-to-write-readable-code-8434c58748a1?source=rss----c3eae8609d01---4">Continue reading on DealerOn Dev »</a></p></div>]]></description>
            <link>https://medium.com/dealeron-dev/how-to-write-readable-code-8434c58748a1?source=rss----c3eae8609d01---4</link>
            <guid isPermaLink="false">https://medium.com/p/8434c58748a1</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[csharp]]></category>
            <category><![CDATA[code]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Eric Damtoft]]></dc:creator>
            <pubDate>Fri, 14 Jun 2019 13:01:01 GMT</pubDate>
            <atom:updated>2019-06-14T13:01:01.203Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Exception Handling and Telemetry with PostSharp, Application Insights, and Grafana]]></title>
            <link>https://medium.com/dealeron-dev/exception-handling-and-telemetry-with-postsharp-application-insights-and-grafana-b15809f0f1fb?source=rss----c3eae8609d01---4</link>
            <guid isPermaLink="false">https://medium.com/p/b15809f0f1fb</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[logging]]></category>
            <category><![CDATA[postsharp]]></category>
            <category><![CDATA[deep-dives]]></category>
            <category><![CDATA[debugging]]></category>
            <dc:creator><![CDATA[Alexander Johnston]]></dc:creator>
            <pubDate>Fri, 07 Jun 2019 13:01:01 GMT</pubDate>
            <atom:updated>2019-06-07T13:01:01.187Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*yyFmLoRUkPh4iyYesTUlKw.png" /><figcaption>PostSharp is a pattern-aware extension for C# which runs during the compilation stage.</figcaption></figure><p>Whether you’re just getting started with .NET or have been using it for its lifetime, there are concerns every project has to face eventually. <a href="https://medium.com/dealeron-dev/automating-net-core-services-with-postsharp-and-aspect-oriented-code-a8a51d8d84ec">In a previous article</a>, I discussed how PostSharp can be used to target concerns like logging and threading. Today, I will show you how we can apply these same principles to exception handling to send real-time telemetry to Application Insights.</p><h3>Remarks</h3><p>Exception handling is a topic with depth far beyond the scope of this article. The code I reference here is not designed to be as fast or as efficient as possible. This is in the interest of showcasing each of the features and creating a usable demonstration which readers can then improve upon for their own purposes. You are always welcome to get in contact with me for clarification or advice on these topics; I also welcome you to point out errors, mistakes, or even make pull-requests to the repository as you see fit.</p><p>My goal is to explore .NET Core cross-platform capabilities and show you how Exception Handling can be integrated with the following tools:</p><p>· <a href="https://docs.microsoft.com/en-us/aspnet/core/fundamentals/host/generic-host?view=aspnetcore-2.2">.NET Generic Host</a> is an all-in-one package for handling configuration, dependency injection, logging, and other app startup concerns. If you want to host async services, then you can do it out of the box now with very little setup time. For us it will simplify a lot of the boilerplate needed to prototype interesting <a href="https://en.wikipedia.org/wiki/Aspect-oriented_programming">AOP</a> use-cases.</p><p>· <a href="https://docs.microsoft.com/en-us/azure/azure-monitor/app/app-insights-overview">Azure Application Insights</a> is a big suite of services which focus on monitoring performance in real-time. You can send events, metrics, and all sorts off custom measurements up to Azure and then immediately query it through <a href="https://docs.microsoft.com/en-us/azure/azure-monitor/log-query/log-query-overview">Log Analytics</a>. The goal here will be to handle our exceptions by logging them up in the cloud where we can get regular snapshots of the application’s state.</p><p>· <a href="https://grafana.com/">Grafana</a> is a wonderful, <a href="https://github.com/grafana/grafana">open-source</a> tool for creating dashboards which track metrics or visualize data as graphs. You can host it yourself but there is also a free and paid cloud-hosted option. The free option is ideal for prototyping and has all of the features we need for now.</p><p>Using the power of a pattern-aware compiler, this cross-cutting concern can be seamlessly hooked up to an external monitoring service without adding try {} catch {} blocks everywhere in your codebase. This lack of clutter helps to keep your code clear and understandable and reduces the number of concerns placed upon your team.</p><h3>Before We Begin</h3><p>Readers who wish to follow along should take the following steps to set up their environment:</p><ul><li>Download the <a href="https://dotnet.microsoft.com/download">.NET Core SDK and Runtime</a>. I will be using VS 2017 on .NET Core SDK 2.2.106</li><li>Download the latest stable PostSharp Extension <a href="https://marketplace.visualstudio.com/items?itemName=PostSharpTechnologies.PostSharp">from the VS Marketplace</a>. Version 6.1.18 is used here.</li><li>Clone the Semantic branch of <a href="https://github.com/AlexanderJohnston/SharpCrafting/tree/Semantic">my SharpCrafting repository</a> or follow my <a href="https://medium.com/dealeron-dev/automating-net-core-services-with-postsharp-and-aspect-oriented-code-a8a51d8d84ec">previous article</a> to build your own threaded Generic Host.</li></ul><h3>Understanding Pattern-Aware Exception Handling</h3><p>An exception handler typically requires you to use some form of try { } catch { } finally { } statements which require every class to know its own context well enough to either bubble up, swallow, or handle an exception which occurs from within. An incorrectly handled exception can easily cause a service interruption or similarly poor experience for an end-user. This puts a burden of documentation and knowledge on any development team to understand the overall error-handling architecture outside the scope of any specific feature.</p><p>For example, in one solution alone I have found several hundred instances of try { } blocks. This can be rough if you run distributed, remote workers because the Exception may need to cross many boundaries without losing its original caller and state. Among those hundreds of try { } blocks there will undoubtedly be one or two which fail to handle as originally intended due to the slow feature creep of business needs. If those needs ever change significantly then there is a risk that any one of the handlers will be overlooked for compatibility. This can cause swallowed exceptions or an undecipherable call stack. The possibility of incorrectly handling exceptions becomes a major obstacle against refactoring and thus a tough sell for teams and project managers.</p><p>This is where aspect-oriented designs step in to provide a solution by consolidating your logic into a common place.</p><p><a href="https://doc.postsharp.net/exception-handling?utm_source=medium&amp;utm_medium=alexander&amp;utm_campaign=4_2019">Handling Exceptions</a> is a primary feature of the PostSharp namespace and I recommend reading it before continuing. The following objects are provided to us for a basic implementation:</p><ul><li>The <a href="https://doc.postsharp.net/t_postsharp_aspects_onexceptionaspect?utm_source=medium&amp;utm_medium=alexander&amp;utm_campaign=4_2019">OnExceptionAspect</a> class which lives in <a href="https://doc.postsharp.net/n_postsharp_aspects?utm_source=medium&amp;utm_medium=alexander&amp;utm_campaign=4_2019">PostSharp.Aspects</a>. This defines an exception handler around a method which will intercept any thrown exceptions and can handle them at a higher level.</li><li>The <a href="https://doc.postsharp.net/t_postsharp_aspects_methodexecutionargs?utm_source=medium&amp;utm_medium=alexander&amp;utm_campaign=4_2019">MethodExecutionArgs</a> class which provides arguments containing advice for your handler. You can use these arguments to get the original exception, the arguments provided by the original caller to the intercepted method, and the flow behavior for execution.</li></ul><p>The official <a href="https://samples.postsharp.net/f/PostSharp.Samples.ExceptionHandling/?utm_source=medium&amp;utm_medium=alexander&amp;utm_campaign=4_2019">PostSharp samples for Exception Handling</a> are a great source to keep open alongside any documentation. I will borrow from the samples to show you an example of this implementation in action.</p><p>The first example is the “Add Context On Exception” <a href="https://samples.postsharp.net/f/PostSharp.Samples.ExceptionHandling/AddContextOnExceptionAttribute.cs.html?utm_source=medium&amp;utm_medium=alexander&amp;utm_campaign=4_2019">Attribute</a>. When an exception is intercepted by this attribute it will append the value of parameters to the exception. Having access to the argument values when reading over the exception later in the logs can save time debugging. This is an exceptional feature to have if you’re dealing with a bug that can’t be reproduced easily. In many cases it would have saved me hours of time to just know which arguments caused an exception in the first place.</p><p>This class has a few points of interest:</p><ul><li>First, it inherits the <a href="https://doc.postsharp.net/t_postsharp_aspects_onexceptionaspect?utm_source=medium&amp;utm_medium=alexander&amp;utm_campaign=4_2019">OnExceptionAspect</a> class which provides an exception handler.</li><li>Next, it intercepts exceptions thrown with OnException( MethodExecutionArgs args ) and tracks their state with the MethodExecutionArgs mentioned earlier.</li><li>Last, it builds a string containing the context including arguments, declaring type, generics, and method name. These are added to the Exception’s ”Context” index on the <a href="https://docs.microsoft.com/en-us/dotnet/api/system.exception.data?view=netcore-2.2">Data property</a>.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dc8862da32bfe011805e564ef7e4bc0f/href">https://medium.com/media/dc8862da32bfe011805e564ef7e4bc0f/href</a></iframe><p>The second example from the official samples is the “Report And Swallow Exception” Attribute. This one interacts directly with the previous attribute by reading the ”Context” added by the handling performed in the AddContextOnException attribute. A few things to note:</p><ul><li>The aspect declares an [AspectTypeDependency] which is <a href="https://doc.postsharp.net/aspect-dependencies?utm_source=medium&amp;utm_medium=alexander&amp;utm_campaign=4_2019">a way to handle aspect dependencies</a> on the same target. In this case it declares that it must come after the AddContextOnException attribute if applied to the same target.</li><li>It checks to see if there is an additionalContext by checking the Exception’s Data property for any information added earlier on via the StringBuilder.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/45d4410beba645b9cd56b201d4dc532f/href">https://medium.com/media/45d4410beba645b9cd56b201d4dc532f/href</a></iframe><h3>Applying Our Understanding With Azure</h3><p>While these samples may seem basic, this is all you need to immediately integrate your applications with third party tools. I find that Application Insights is perfectly suited for a task like this since it is designed to have a low barrier to entry with a simple API. Let’s go over the next steps to see what our goals are and how we can implement them.</p><ol><li>An Azure account will be needed for this, but <a href="https://azure.microsoft.com/en-us/free/">luckily it comes with a free trial</a> and is quick to setup. If this is your first time then <a href="https://azure.microsoft.com/en-us/resources/videos/sign-up-for-microsoft-azure/">I recommend this video</a> which shows you how to complete the entire process in just a few seconds.</li><li>Create a new Application Insights resource through Azure. Grab the “Instrumentation Key” from the Overview page.</li><li>Copy down your “Application ID” from the “API Access” menu of your Application Insights resource.</li><li>Create an API key and copy it down as well. This can be done in the same “API Access” menu. Provide it all three options [Read Telemetry, Write Annotations, and Authenticate SDK].</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*EZ8-_oCUVS-GVjhFb7vkIA.png" /><figcaption>Example of the Azure API key for Application ID.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/623/1*GSWuZfxVJxjoqRvdclFRpA.png" /><figcaption>Example of the Azure API key for Instrumentation and Subscription.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/575/1*3hfN88L46_wlp-mkY9pNnw.png" /><figcaption>Example of creating an API key in Azure.</figcaption></figure><p>We’ll use these pieces of information later to integrate our real-time metrics with Grafana. For now, store those keys in a safe place and let’s revisit our code.</p><h3>Integrating PostSharp With Azure</h3><p>The goal here will be to write custom events to Azure describing an exception every time one is handled. We can restrict this to just two classes, one for Azure and one for the Exception Handler, by utilizing the <a href="https://doc.postsharp.net/t_postsharp_aspects_onexceptionaspect?utm_source=medium&amp;utm_medium=alexander&amp;utm_campaign=4_2019">OnExceptionAspect</a> which we learned about earlier from the PostSharp samples. First, let’s write an Aspect to do the following:</p><ul><li>Catch an exception.</li><li>Read the arguments.</li><li>Read the target name.</li><li>Read the Exception type and its message.</li><li>Mark a custom event with these properties on Azure and log them locally.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/def5d5474ac47a5f9f528ed18ec0340d/href">https://medium.com/media/def5d5474ac47a5f9f528ed18ec0340d/href</a></iframe><p>Let’s break down this class to see where Azure was included specifically:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ad38274942c67e983b56048aa5588ba8/href">https://medium.com/media/ad38274942c67e983b56048aa5588ba8/href</a></iframe><p>We can see here that the Azure integration allows us to pass a dictionary of properties (similar to a JSON structure) into the custom event and all we have to do is give it a context. In this case the context is an “Exception”. That’s all there is to it! The only other configuration we need to connect to Azure is to add two files to our project. Monitor.cs and ApplicationInsights.config</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/86cf8c5c757d04548417f8593e83b9d1/href">https://medium.com/media/86cf8c5c757d04548417f8593e83b9d1/href</a></iframe><p>In the above code we just need to replace “Your Key Here” with the Instrumentation Key we pulled from Azure earlier. Then we add this ApplicationInsights.config file to the folder containing our .csproj.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ea2939488e01a9f092f389a926e4e97d/href">https://medium.com/media/ea2939488e01a9f092f389a926e4e97d/href</a></iframe><p>In the Monitor class, we set developer mode to true which will allow the telemetry to be uploaded in near real-time so that we can test it quickly.</p><p>Again, replace “Your Key Here” with the “Instrumentation Key” provided by Azure. <strong>Please note</strong>: readers should store their keys in User Secrets or somewhere more secure. This code is used for examples only so please do not commit your keys to your repository directly!</p><p>At this point the aspect is ready to send data to Application Insights. Decorate any method with [ServiceExceptionDetour] if you’re using the code provided here and then throw an exception from that decorated method. For example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/230629103a2bce42f97056db7e0c8993/href">https://medium.com/media/230629103a2bce42f97056db7e0c8993/href</a></iframe><p>Here you can see that I am using the lovely ExceptionGremlin from the <a href="https://github.com/houseofcat/Library">HouseOfCat Library</a>. <a href="https://houseofcat.io/">The author</a> provides a number of useful tools in there like basic exception fuzzing. Every time I throw from within this method, CauseException, it will be routed through the Exception Handler and have its data passed to Azure. You will also notice that it is decorated as an [EntryPoint] which means that it is safely entered from many threads in an actor model despite being private. It is important to <a href="https://doc.postsharp.net/aspect-lifetime">understand the lifetime and scope of aspects</a> when used in this way. For our purposes though we can disregard any performance issues because Exceptions are already expensive and we’re not trying to be graceful here.</p><h3>Log Analytics</h3><p>If you navigate to <a href="https://docs.microsoft.com/en-us/azure/azure-monitor/log-query/log-query-overview">Log Analytics</a> on your Application Insights resource then you’ll be able to query the customEvents table to see if everything worked. You should have customDimensions on each record which contains the data you attached to the event from the Exception when it was handled.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/623/1*kPTZ5zrO_BVYvOO8u5bKnA.png" /><figcaption>This image shows how to reach Log Analytics from an Azure resource.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/623/1*J1YSqTYm64wTmbzAi64tYQ.png" /><figcaption>An example data structure for an Application Insights custom event.</figcaption></figure><p>If you are new to Log Analytics then I recommend checking out the official <a href="https://app.pluralsight.com/library/courses/kusto-query-language-kql-from-scratch/table-of-contents">Kusto Query Language (KQL) From Scratch</a> tutorial on <a href="https://docs.microsoft.com/en-us/visualstudio/subscriptions/vs-pluralsight">Pluralsight</a>. Here is an example query for our current set of custom events:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/36578416c2b8216b8edf06954b75baee/href">https://medium.com/media/36578416c2b8216b8edf06954b75baee/href</a></iframe><h3>Grafana</h3><p>Finally, we can integrate our Log Analytics store with Grafana to produce beautiful, real-time dashboards for our exceptions. If you’re new to Grafana then you can <a href="https://grafana.com/get?signup">sign up for a free instance</a> which is hosted as a container up in the company’s cloud. You can also host an instance on your own machine if you’d like to make it a dedicated resource.</p><p>Once you have signed up then you will need to set up your dashboard to work with Azure.</p><ol><li>Install the Azure Monitor plugin on your instance of Grafana.</li><li>Open your dashboard and navigate to Configuration &gt; Data Sources. Add a data source for Azure Monitor.</li><li>Fill out the two fields “API Key” and “Application ID” for Application Insights. We retrieved these keys earlier when we set up our Azure resource.</li><li>Click “Save &amp; Test” to check if the connection is working.</li></ol><p>From here you can begin utilizing KQL queries to make new visualizations. Here are some examples of what can be constructed alongside the queries and settings I used to build them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/623/1*Q4UJEcphANrNAXoxadG1Ww.png" /><figcaption>An example of Grafana visuals showing a stable system.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/1*svdufG4P8liPGpz-IPlZvA.png" /><figcaption>An example of Grafana visuals displaying an unstable system.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*kC3BHQszozay1XZC3sfqmw.png" /><figcaption>An example image showing what a critical alert might look like.</figcaption></figure><p><strong>Bar Chart</strong>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/04ec4db063006149e9ddc76e28453404/href">https://medium.com/media/04ec4db063006149e9ddc76e28453404/href</a></iframe><p><strong>Gauge &amp; Annotation</strong>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8330ce3a0b7a68065b98549babfaec44/href">https://medium.com/media/8330ce3a0b7a68065b98549babfaec44/href</a></iframe><h3>Where Can I Go From Here?</h3><p>At this point you can watch your data flow into the Grafana dashboard in real-time! This pipeline can now be used to track any sort of metric you want. PostSharp has a comprehensive suite of tools for you to <a href="https://doc.postsharp.net/method-decorator?utm_source=medium&amp;utm_medium=alexander&amp;utm_campaign=4_2019">inject behaviors before and after execution</a> on <a href="https://doc.postsharp.net/method-interception?utm_source=medium&amp;utm_medium=alexander&amp;utm_campaign=4_2019">methods</a>, <a href="https://doc.postsharp.net/location-interception?utm_source=medium&amp;utm_medium=alexander&amp;utm_campaign=4_2019">properties / fields</a>, and <a href="https://doc.postsharp.net/event-interception?utm_source=medium&amp;utm_medium=alexander&amp;utm_campaign=4_2019">events</a>. Anywhere you want to gather metrics without re-writing your old classes is a place to consider using an Aspect to provide that advice.</p><p>Instead of writing out to Log Analytics, consider writing your events to <a href="https://eventstore.org/">EventStore</a> which allows you to build an immutable timeline to be used as a source of truth later to reason about your events. The overhead on EventStore is exceptionally low to the point where it may be easier to scale this form of Exception Handling by writing to EventStore and then reading it into Azure from a separate service.</p><p>While there are many unconventional options, the goal here is simply to automate the boring stuff. Rather than chase down exceptions you can instead intercept them and handle them a deterministic way with advice provided by Attributes. How you handle them is up to your situation and needs.</p><h3>Credit</h3><p><a href="https://www.nuget.org/packages?q=totem">Totem</a> was used in this repository. It provides a way to host your assemblies on an event-sourcing timeline and integrates with most common development scenarios. This package is still in preview right now but I recommend you add it to your favorites and keep an eye on it.</p><p><a href="https://github.com/houseofcat/Library">HouseOfCat Library</a> was used for exception generation here. I recommend checking out their Rabbit MQ library if you utilize message queues regularly.</p><h3>Final Remarks</h3><p>The entire <a href="https://github.com/AlexanderJohnston/SharpCrafting/tree/Semantic">source code</a> for this project is available on GitHub if you’d like to clone it and play around with the solution. Feel free to modify or redistribute it as needed. You can always find a copy of it on the Semantic branch.</p><p>Hopefully this article conveyed the power of Aspect Oriented Programming in the .NET Core architecture. This is a learning process for all of us and I invite you to share or collaborate any time. Thank you for taking the time to read.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b15809f0f1fb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dealeron-dev/exception-handling-and-telemetry-with-postsharp-application-insights-and-grafana-b15809f0f1fb">Exception Handling and Telemetry with PostSharp, Application Insights, and Grafana</a> was originally published in <a href="https://medium.com/dealeron-dev">DealerOn Dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Assumptions Programmers Make]]></title>
            <link>https://medium.com/dealeron-dev/the-assumptions-programmers-make-1ab552d2011f?source=rss----c3eae8609d01---4</link>
            <guid isPermaLink="false">https://medium.com/p/1ab552d2011f</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[deep-dives]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[lessons-learned]]></category>
            <dc:creator><![CDATA[Nick Rogers]]></dc:creator>
            <pubDate>Fri, 31 May 2019 13:01:01 GMT</pubDate>
            <atom:updated>2019-05-31T13:35:02.887Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C7AYcr4Vl3vveaKHZlnpXQ.jpeg" /><figcaption>“<a href="https://flic.kr/p/8mYTYf">Tractor</a>” by <a href="https://www.flickr.com/photos/leszekleszczynski/">Leszek Leszczynski</a> is licensed under <a href="https://creativecommons.org/licenses/by/2.0/">CC BY 2.0</a></figcaption></figure><p>In the summer of 2017, we at DealerOn had just flipped the switch on our spiffy new inventory management system, bringing to life an <a href="https://microservices.io/patterns/data/event-sourcing.html">event-based</a> web UI for managing and merging vehicle updates from our automotive dealers’ respective systems. These updates now could go live on the websites we hosted in near real-time, rather than the old system where you were lucky to get one update every 12 hours.</p><p>After some initial bumps, we successfully migrated all of our dealers away from the legacy system, and everyone was happy: Our customers, who could now have a vehicle up for sale the minute it arrived on their lot; our customer support staff, who could correct issues without needing to cross their fingers and wait until the next day; and especially the programmers, who put tons of work into something that looked and worked great. Or so we thought.</p><p>A key part of the inventory update process for each dealer involves downloading photos for each vehicle, either from the dealer’s management utility or from a third party, and formatting them for display on our dealer’s websites. We made the decision to store each photo on our assets server in a directory named by the vehicle’s VIN. For example, a vehicle with VIN 1C8RACDN8KW520476 would have all the photos downloaded into a directory with the name “/photos/1C8RACDN8KW520476”.</p><p>We decided a bit later on that we wouldn’t want to run out of storage space, so we wrote a quick little method to delete photos from our assets after the vehicle was sold. The code was tested and deployed without any issues.</p><p>That is, until one morning when we rolled into the office and learned our client support team was getting hammered with calls from angry customers asking us why all of their vehicles were displaying a “<strong>Vehicle Photos Unavailable</strong>” stock image instead of the photos that they had taken. (Apparently car shoppers actually want to see the car before they’d consider buying it, who knew?)</p><p>Our dev team sprang into action to figure out why the photos weren’t showing, thinking it was simply a bug in the website code. After some initial debugging, it was discovered to be a much bigger problem than first realized: nearly <strong>all </strong>the inventory photos for <strong>all </strong>of our websites had been deleted from our assets server! The “/photos” directory was nearly bare. We quickly began to restore a backup of the missing photos so they would begin showing again, but where did the photos go, and would it happen again?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*Rl7keslL48UPiQfqY3lJIQ.jpeg" /><figcaption>Ruh roh.</figcaption></figure><p>There was a scramble to find out if anyone had accidentally deleted the photos on the production assets server, or if the quick method to delete photos for sold vehicles was going rogue and deleting way more than it should have been. We weren’t having much luck, and hearing from client support about all the ticked-off dealers who wanted to know what gives wasn’t helping. By that afternoon we had ripped out every single capability of our inventory importer to delete any type of file whatsoever, but we still didn’t know the root cause of all this.</p><p>On a whim, we pulled up the exact time our assets server logs started recording a sharp increase of free disk space and we tried to figure out exactly what happened at that second. Eventually, we spotted something strange. There was a vehicle removed from a dealer’s inventory right before the photos were all deleted, and this vehicle had a VIN of a<em> single period</em>.</p><p>Even though VINs were not a national standard until 1981, our system requires <em>something </em>(i.e. not necessarily a valid VIN, but it can’t be blank) in the VIN field for each vehicle. We realized what had happened, after the vehicle with a vin of “.” was sold, we gave our system a command to delete “/photos/.”, which translates to “<strong>all </strong>files and directories contained in the directory ‘/photos’”. After we were somehow able to extract our palms from our foreheads, we deployed a fix and then manually refreshed photos for any sites still missing them, and the phone calls stopped.</p><blockquote>The trouble started when this assumption was not challenged…</blockquote><p>It turned out that this “.” vehicle was a vintage tractor which was for sale in a rural dealer’s inventory. It didn’t have a VIN, so the dealer entered only a period because our new inventory system required him to enter something. It raised an interesting question, though: could this really be called a bug? Sure, we definitely should have been checking for the path traversal vulnerability, but entering a period for a VIN was perfectly valid and well within the bounds of our expected processing behavior. At some point, one or more persons made the (wrong) assumption that “<strong>every vehicle has a valid 17 character VIN</strong>” and decided it was OK to categorize information based on it. The trouble started when this assumption was not challenged, causing the inventory system functionality based on this faulty assumption to come crashing down.</p><p>Surely if a developer had been asked point-blank, “What happens if the photo processor tries to delete a folder for a VIN with a path character in it”, they would have immediately seen the problem and put in a ticket to correct it before something like this happened. Why wasn’t that question ever asked? Especially on long-running projects, it’s tough for developers and architects to avoid getting tunnel vision. Even when there’s a spec or ticket to work off of, workers assume that the ticket is gospel truth and has been completely fleshed out. In truth, <strong>no spec will be 100% complete</strong> and oversights are bound to happen. Assumptions will be made, but regular status reports between project stakeholders can help highlight them at the outset of the project rather than at the end, when frustrated developers will need to toss out hours of work over something that could have been cleared up with a conversation.</p><p>Developers can even get caught off guard by assumptions they’ve made about societal customs, like names, gender, addresses, and calendars. Following the legalization of same-sex marriage nationwide in the United States in 2015, several <a href="https://www.wfaa.com/article/news/local/denton-county/computers-leave-denton-co-unable-to-issue-same-sex-marriage-licenses/148852913">local governments were unable to issue marriage licenses</a> because their systems were not able to properly record a marriage between two people of the same sex. Depending on when these systems were launched, the assumption of “marriage will always be between two people of the opposite sex” may have been completely valid to make at that time, but it became invalid in the years immediately prior to 2015. Because this assumption wasn’t corrected in time, whether due to inattention or lack of priority, these systems needed to undergo costly upgrades.</p><blockquote>It’s unlikely that a programmer will be able to think of every possible way that bad input can cause problems</blockquote><p>To help uncover hidden assumptions, there’s a great list of <a href="https://github.com/kdeldycke/awesome-falsehood">Falsehoods Programmers Believe</a> with common assumptions to keep in mind. Plenty of the listed assumptions seem obvious when reading them, but developers can still be blind to them. (I wish I had this list when I wrote some code that I thought was great at the time, before it folded like a lawn chair once the clocks changed for Daylight Savings Time.)</p><p>Of course, it’s unlikely that a programmer will be able to think of every possible way that bad input can cause problems. Still, it’s just as unlikely that the data a program operates on will never stray from the golden path. Sometimes it’s a good idea to take a step back and look at one’s own code from a distance and consider the unexpected. The best time to ask questions such as “<em>What happens if this variable is </em><em>null?</em>” or “<em>What if the database goes down during this call?</em>” or “<em>What if an unauthorized user tries to view this page?</em>” is while looking at the big picture. Otherwise, implicit assumptions are made, which if left for several years before being uncovered can lead to resorting to hacks or expensive redesigns.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1ab552d2011f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dealeron-dev/the-assumptions-programmers-make-1ab552d2011f">The Assumptions Programmers Make</a> was originally published in <a href="https://medium.com/dealeron-dev">DealerOn Dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Tragedy of the Jigsaw Bot]]></title>
            <link>https://medium.com/dealeron-dev/the-tragedy-of-the-jigsaw-bot-e5327704be7?source=rss----c3eae8609d01---4</link>
            <guid isPermaLink="false">https://medium.com/p/e5327704be7</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[slack]]></category>
            <category><![CDATA[lessons-learned]]></category>
            <category><![CDATA[debugging]]></category>
            <category><![CDATA[pranks]]></category>
            <dc:creator><![CDATA[Gary Asphodel]]></dc:creator>
            <pubDate>Fri, 24 May 2019 13:01:01 GMT</pubDate>
            <atom:updated>2019-05-24T13:01:01.263Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NDqnfo6EB8nqYhoG" /><figcaption>Photo of the character Jigsaw by <a href="https://unsplash.com/@franciscomorales?utm_source=medium&amp;utm_medium=referral">Jose Francisco Morales</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Our story begins on the 25th of march. I was working on a ticket that had been in front of me for a week or two regarding our build server (<a href="https://www.jetbrains.com/teamcity/">Team City</a>) not sending any emails to folks. The build server software’s official support team was taking quite a while to get back to me, and I had tried everything I could think of. Not wanting to leave this untouched for a while, I decided to come up with a plan.</p><blockquote><em>“What if instead of an email, we get the notification of a failed build sent via slack directly to the user in a private chat? Most of my teammates don’t like email anyway, and this would put me a step or two further on my goals for integrating the entire CI/CD pipeline with the chat client.”</em></blockquote><p>Over the course of the week in my free time between major tasks, I experimented with a few plugins for the build server. Nothing seemed to work correctly and the server logs didn’t overtly indicate that I had a problem or that it was attempting to use the shiny new tool that I had configured. However, with some help from support I was able to learn how to enable the logging correctly. Apparently, I was missing several <a href="https://api.slack.com/scopes">scopes</a> for the bot to talk to me in my slackbot channel.</p><p>I had been writing <a href="https://docs.microsoft.com/en-us/powershell/scripting/overview?view=powershell-6">PowerShell </a>on the side to send myself simple messages so that I could test the permissions of the bot. As it turns out, there’s a lot of documentation for <a href="https://api.slack.com/bot-users">Slackbots</a>, but I had not seen a unified guide to setting them up with all the permission scopes you’d want in one place in the manner I was seeking, namely something that explained them in a method that made it so I could understand. I knew that you could send bot chat to a channel, but private users was another thing, and that didn’t have (to me) a straightforward logic to doing so.</p><p>Typically, a public/private channel only requires an <a href="https://api.slack.com/incoming-webhooks"><strong>incoming-webhook</strong></a> for a scope, and an incoming webhook URL in order to post to a channel. However, a person’s private slackbot channel is unique to them. The scopes I ended up granting the bot are:<strong> </strong><strong>incoming-webhook, </strong><strong>channels:write, </strong><strong>chat:write:bot, </strong><strong>groups:write, </strong><strong>bot, </strong><strong>users:read:users:read:email</strong>.</p><pre><strong>$stuff</strong> = “<em>I have the shiniest meat bicycle</em>!”</pre><pre><strong>Invoke-RestMethod</strong> -Method POST -Uri “https://slack.com/api/chat.postMessage?token=xoxb-SUPER_LONG_TOKEN&amp;channel=SlackUserID&amp;text=<strong>$stuff</strong>&quot; -ContentType “application/json”</pre><p><em>“I have the shiniest meat bicycle!” — </em>was the very first thing I saw in my slackbot channel from my own bot (test messages in my opinion should be fun, so I use <a href="http://orcz.com/Category:Borderlands_2_Quotes">Borderlands 2 quotes</a>). Soon after, I was sending URLS and semi-complex text structures in urlencoding, followed by JSON objects. <em>Success!</em></p><p>However this was only the beginning. It would be a major task, and a huge spoiler of fun to ask my pals in development to go through a semi complicated procedure to get the slack token I needed and then to record it somewhere in a kind of database or file. The next logical step then was to tell my script my email address, have it figure out the rest from there, and then send a message that way. The good news for me is that Team City has a built-in variable for that, and I had been asking everyone who registered on the server to use their work email so they could actually get emails when builds failed.</p><pre><strong>$who </strong>= “%teamcity.build.triggeredBy.username%”</pre><pre><strong>$targetUser</strong> = <strong>Invoke-RestMethod</strong> -Method POST -Uri “https://slack.com/api/users.lookupByEmail?email=<strong>$who@emaildomain.com</strong>&amp;token=xoxb-super_long_token&quot; -ContentType ‘application/x-www-form-urlencoded’ | <strong>ConvertTo-Json</strong></pre><pre>(<strong>$targetUser</strong> -split “`r`n”) | <strong>ForEach-Object</strong> {<br>     <strong>$userID</strong> = <strong>Select-string</strong> -InputObject $_ -Pattern ‘“id”: ‘<br>     if(<strong>$userID</strong>){</pre><pre>     <strong>Write-Output</strong> “FOUND”<br>     <strong>$cleanID</strong> = <strong>$userID</strong> -Replace ‘“id”:’, “” -replace ‘“‘, “” -replace ‘,’, “”</pre><pre>     <strong>$cleanID</strong> = <strong>$cleanID</strong>.trim()<br>     }<br>}</pre><p><em>Above I’m doing some cleanup. The response from the API is a JSON object, and in order to lookup my string ID that comes from being in Slack I need to parse it. Once I grab a line that has </em><em>“id”: “MY_ID”, I just remove the extra stuff I don’t need and that leaves me with just my target ID as a string.</em></p><p>Within an hour I had it set up so that if i gave it my email, it would look up my userID in Slack, clean up the token it got out of the JSON that it returned, and then send it back to slack with the api call to send the private user a message. Easy, right?</p><p>It’s now Friday and I have about half an afternoon left in my work week when the realization hits me —</p><ul><li><strong><em>April 1st is a Monday this year. </em></strong>I could prank the dev team by challenging them to a game of Russian Roulette at random on each build triggered. If I took the current time, took the last digit of the minute off and used that in a switch, I’d generate a sensibly fair roulette. <em>An example of this is: Imagine it’s 1:25pm, we grab the last digit in the time, 5, and generate a result based on that. Using the logic I present below, a build triggering at 1:25 would gain the user nothing, but a build triggered at 1:29 would earn them 200 points, and a build triggered at 1:23 would cost them 100 points.</em></li></ul><pre><strong>$a</strong> = Get-Date<br><strong>$array</strong> = [int[]](($a.Minute -split ‘’) -ne ‘’)<br><strong>$yei</strong> = 0<br>switch(<strong>$array</strong>[-1]){<br>     0 {<strong>$yei</strong>=0}<br>     1 {<strong>$yei</strong>=-25}<br>     2 {<strong>$yei</strong>=50}<br>     3 {<strong>$yei</strong>=-100}<br>     4 {<strong>$yei</strong>=100}<br>     5 {<strong>$yei</strong>=0}<br>     6 {<strong>$yei</strong>=25}<br>     7 {<strong>$yei</strong>=-50}<br>     8 {<strong>$yei</strong>=0}<br>     9 {<strong>$yei</strong>=200}<br>default {<strong>$yei</strong>=”ID:10-T Error”}<br>}</pre><ul><li>It would be an ideal way to test out the build notifier as a concept and turn it into a real thing if it works out. I already had it well figured out how to look up the user in the system and verify their authority to run specific builds/execute scripts against certain servers from a previous project.</li><li>All the pieces to make this work are here, it just needs someone to assemble the jigsaw puzzle. If I doubled-down , I could give it a Jigsaw flavor and feel but not overtly pressure them into playing my game if they are not interested or do not have the time. I get to have my love of pranks and to be useful at the same time.</li></ul><p>By COB that day I had Jigsaw bot tested out and working. The whole process works like this:</p><ol><li>A user triggers a build, and at random they’re challenged to a game.</li><li>I look up the user on the whitelist and blacklist. If the user is not whitelisted or blacklisted when they’re chosen for a challenge, then they are issued a challenge by the Team City build server directly in Slack. They’d be instructed to (if they wanted) play the game by using the SAW build at the bottom of the page, in a section reserved for Utilities.</li><li>Team City Updates the whitelist by allowing that user to play.</li><li>Team City sends <strong>me</strong> a message, so I have a record that a game is coming and should be prepared to send them points.</li><li>The user plays the game. Based on another time-based roulette like the one shown above, they’re given or penalized an minuscule, arbitrary amount of points. Any user caught trying to play the game who wasn’t invited via whitelist would be blacklisted and mocked in Slack in front of everyone on their team. Once the user completes the game they’re also blacklisted from playing again in order to keep it simple and prevent everyone from winning too much. If the RNG engine was not being generous with the developers and there were not a lot of players by midweek, my plan was to clear the blacklist and let them try again, for the fun of it.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2Xo-QVFV5xS6eJb47Y4oeA.png" /><figcaption>The challenge messages here were put on a slight delay timer, so you wouldn’t get them all at once, to attempt to make the bot feel life-like. This is a sample of what the user would get in their message inbox.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/507/1*wazdVjWl4fa3lETGVJt5JA.png" /><figcaption>This is what I expected to see in my personal Slackbot channel.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LW4aG7afeP-ruBJ2p4bPCA.png" /><figcaption>This has a couple of test examples of winning and losing the game. The user gets a message saying what they win or have to do, and I get a message knowing to expect payment or have to make a payment.</figcaption></figure><p>Nothing could go wrong with this plan, right?</p><p>Riiiiiiiiiight…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/707/1*O7buCOETnv_Jdb0x4V-wlA.png" /><figcaption>Poor Jigsaw, he has no idea who he’s talking to. %teamcity.build.triggeredby% will only be a name he will get angry at and be triggered by. For the record though, I did track down the user who beat my game and gave him 100 points just for helping me fix the bugs.</figcaption></figure><p>Come Monday, hell had pretty much broken loose in my slackbot channel. It turns out that unless the user clicked the button <strong>[RUN]</strong> or <strong>[…]</strong> next to it to initiate a build, it would set the default service account name as the %teamcity.build.triggeredby.username% system variable value when it went to do a lookup. Slack would then try to lookup this invalid user and then send nothing to me. I was 100% in the dark on what was going on. It wasn’t until Tuesday of that week before I had an actual user get labeled as the trigger-er of builds. By then I already had about 100 IMs in chat saying that %teamcity.build.triggeredby.username% has been challenged to a game.Very helpful. <em>Veeeeeery </em>helpful.</p><p>Remember the whitelist/blacklist function that I mentioned earlier? Its only purpose was to be a build artifact that was a composite of all the other users who had been challenged and add their names to it as the week progressed. As a user gets challenged, they’re put on the whitelist, never to be bothered again, until they play the game. The whitelist function wasn’t working for anyone, so Matt came to me by midweek saying that he was getting challenged to a game every 5 minutes while running a series of database changes on multiple databases. Although he wasn’t upset (he was actually mildly amused), he did ask if I could turn it off while I looked for a way to make Jigsawbot not play favorites with him.</p><p>Oh, and did I mention that almost everyone found this irritating and deemed it to be some social engineering scam? Pretty much everyone I spoke to either believed that it was a social engineering scam, or just <em>me</em> goofing around, and no one reported it to me or my team either way, save for the 4 users who actively contacted me because they were just amused enough to ask. Out of that subset of developers, half of them were even remotely interested in playing along and did so (to which I rewarded as per rules of the game). At least our IT department’s anti-phishing training was not lost on my developer friends.</p><p><em>Everything was going so smoothly.</em></p><p>So I worked on it, and after some hair-pulling moments realized where my errors were, and got it to leave poor Matt alone.</p><p>Pseudo-code for what I was doing:</p><pre>If (we should challenge the user) {<br>     challenge the user;<br>     if (not on whitelist and not on blacklist) {whitelist them;}<br>}</pre><p>What I instead should have been doing:</p><pre>if (we should challenge the user){<br>     if (not on whitelist and not on blacklist){<br>     challenge the user;<br>     whitelist them;<br>     }<br>}</pre><p><em>This never came up in my tests because I’d play the game directly after being challenged. I didn’t have a test case scenario that would adequately cover the instance of “I need to run 5 different builds at once that would trigger this before playing” and the gap in my code’s behavior wasn’t readily apparent until it was out for the “world” to see.</em></p><p>With the correct logic in place, I was able to fix what my problems were, and Matt finally got some peace and quiet. I, however, wasn’t satisfied. <em>If I wanted to make this into a usable bot script for build errors, I needed to understand how the build software gets the VCS changes from Git to learn who the user was.</em></p><p>With my week of sad and failed pranks nearly over, I began efforts to grab the username from Git so I could extrapolate it into my script and the circle would be complete. With a bit of git commands piped to a file, and a sprinkle of regex later, I had cooked up something that would reliably get emails for usernames, or for users who wanted their first and last name to be signed on the commit, and can accurately report it back to the script so I can do all the fancy things that I have described above without being concerned for getting a bad username passed in because the system’s default is not valid for the entire script’s usage.</p><p>The icing of this cake is that I got the plugin working while I was doing this(you know, the one that started this whole damn journey). Ironically, this script isn’t usable for me in it’s current form without me completely redoing all of our builds and sending them back to the dark ages.</p><p>However, should I ever need to migrate to another build software where there are less plugins and the UI is less friendly and more command line driven, I have a script that will send private messages. Here it is:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e1561998a8187ef89768e894c84dcdbc/href">https://medium.com/media/e1561998a8187ef89768e894c84dcdbc/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e5327704be7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dealeron-dev/the-tragedy-of-the-jigsaw-bot-e5327704be7">The Tragedy of the Jigsaw Bot</a> was originally published in <a href="https://medium.com/dealeron-dev">DealerOn Dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Power to the Front End with GraphQL]]></title>
            <link>https://medium.com/dealeron-dev/power-to-the-front-end-with-graphql-ae9889bbc7ab?source=rss----c3eae8609d01---4</link>
            <guid isPermaLink="false">https://medium.com/p/ae9889bbc7ab</guid>
            <category><![CDATA[api]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[graphql]]></category>
            <category><![CDATA[backend]]></category>
            <category><![CDATA[collaboration]]></category>
            <dc:creator><![CDATA[Jonathan Eccker]]></dc:creator>
            <pubDate>Fri, 17 May 2019 13:01:01 GMT</pubDate>
            <atom:updated>2019-05-17T13:01:00.961Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*J7qTXRGbnxZlxUIq" /><figcaption>Photo of a sparkler held above a hand by <a href="https://unsplash.com/@mervynckw?utm_source=medium&amp;utm_medium=referral">Mervyn Chan</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>I’ve always felt like a lot of things in development get designed backwards. It’s really easy for us to get caught up in what the data is behind the scenes, and forget that the data isn’t the end goal, providing some sort of functionality to a user is the end goal. Many times I have been on a banking site and saw a table that looked like it was literally pulled straight from a SQL table in the back end, and none of the information on it served any need I would ever realistically have.</p><p>It’s design like this that made me fairly hesitant about Rest APIs when I first read about them. Don’t get me wrong, the standardization and consistency that comes with well developed Rest APIs is a wonderful thing. However the entire concept felt like it was a way for a developer to expose the data that exists, not necessarily the data that the user wants.</p><p>A common problem often occurs in these implementations of Rest APIs, and even Rest-ish APIs: a page often will need to perform several API calls to get everything it needs, many times resulting in retrieving more information than necessary. Say you need a person’s name, well you also get their date of birth, hair color, shoe size, and whatever else you have on that student resource. You end up <em>over-querying. </em>Even further, in order to get nested information you often will need to make subsequent API calls.</p><p>The easy answer for preventing this might be to drift away from by-the-books Rest APIs, and start developing APIs for specific purposes (the Rest-ish APIs mentioned earlier). For instance, say that you have an API that specifically returns a student’s name, the school they attend, their two parents names, and the name of their favorite Pokemon. You now are left with potentially many APIs referring to the same resource, and overall much more code to maintain. I’m sure there’s someone out there who enjoys making slight adjustments to API result models and rewriting SQL queries to fit the new model’s shape all day every day, but that’s just simply not my cup of tea.</p><p>So after writing these Rest-ish APIs for a few months, I started wondering, “what if we could make these Rest-ish APIs more dynamic… specify the properties that need to get returned”. Not surprisingly, I was not the first person to ever have this thought; It turned out that Facebook was way ahead of me on it.</p><p><a href="https://graphql.org/">GraphQL</a> is just a query language, not a database. Just like how “SQL” is a query language, with no implications about the actual implementation. You can build a GraphQL API in .NET (we currently utilize <a href="https://github.com/graphql-dotnet/graphql-dotnet">GraphQL.NET</a>), Java, Javascript, anything you could think of. <a href="https://neo4j.com/">Neo4J</a> is a graph database that even comes with a GraphQL API in addition to its <a href="https://neo4j.com/developer/cypher/">Cypher</a> API.</p><p>A sample of a query you would simply post to a GraphQL end point:</p><pre>{<br>  student(id:9682) {<br>    name<br>    dateOfBirth<br>    school {<br>      name<br>      address<br>    }<br>    parents { <br>      name<br>      dateOfBirth<br>    }<br>    favoritePokemon {<br>      id<br>      generation<br>      name<br>    }<br>  }<br>}</pre><p>At some point a developer defined the shape of each of those <a href="https://graphql.org/learn/schema/">Graph Types</a> (Person, School, Pokemon), and how to traverse them (person -parents-&gt; person[]), but depending on how fleshed out your GraphQL application is, they did that a long while ago for some completely different page and you don’t need to ask them to do a thing to get this information in this shape via one API call.</p><p>And suddenly we are at the point where a front end developer can focus purely on making an application for what the user wants, and not worry about designing around how the data is stored/structured. The querying API is built around what the Front End wants, and not how the Back End is designed.</p><p>Just like Rest APIs, these Graph Types can pull from any data source, not just SQL. I’ve implemented SQL, Elastic Search, Blob Storage, Redis, Neo4J, In Memory sources (application configurations, for instance), and 3rd party API calls (Salesforce APIs for instance). Anything you can think of that returns data can be put behind the GraphQL layer of abstraction. And if you design it right the Front End never needs to care. You very quickly lose concerns like “We can’t get Students and Pokemon data at the same time, Students are in SQL and Pokemon are stored in a CSV hosted on Tim’s raspberry pi”.</p><p>But back to the topic, <strong>Power to the Front End</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Dsu7QW91s6MumIOO" /><figcaption>Photo of a person raising their fist while on top of a mountain in front of clouds by <a href="https://unsplash.com/@ianstauffer?utm_source=medium&amp;utm_medium=referral">Ian Stauffer</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>GraphQL is more robust than it lets on at first glance. It provides a LOT of tools to give Front End developers the ability to get exactly what they want, when they want it.</p><p>First off, <a href="https://graphql.org/graphql-js/passing-arguments/">P<strong>arameterization</strong></a><strong>. </strong>Passing arguments via query strings gets rather frustrating. Making sure everything is URL encoded and completely validated on the back can be fairly complicated and time consuming. GraphQL has all of this pre-baked in, and depending on the implementation will automatically validate any variables you pass in.</p><pre>query($studentId:Int!) {<br>  student(id:$studentId) {<br>    name<br>  }<br>}</pre><p>You simply pass it a set of variables along side the query, like such:</p><pre>{<br>  studentId: 9682<br>}</pre><p>And it will automatically expect an integer for student id, and because it has the exclamation mark it will even validate to make sure that studentId is not null before processing the query.</p><p>Secondly, <a href="https://graphql.org/learn/introspection/"><strong>Introspection</strong></a><strong>.</strong> Any application following GraphQL’s standards will be able to explore what Graph Types are available, what properties they have, how they relate to other Graph Types, any descriptions/meta data they might have. This is MOSTLY used for autocomplete in tools like <a href="https://electronjs.org/apps/graphiql">GraphiQL</a> which are used for building/testing queries, but I have found use for it in building pages that can build themselves based on what properties are available on a node.</p><pre>{<br>  __type(name:&quot;Pokemon&quot;) {<br>    name<br>    fields {<br>      name<br>      type {<br>        name<br>        kind<br>      }<br>    }<br>  }<br>}</pre><p><a href="https://graphql.org/learn/queries/#directives"><strong>Directives</strong></a><strong> </strong>let portions of the query be conditional. This often is good when you have dynamic information showing on a page.</p><pre>query($caresAboutPokemon:Boolean!,<br>  $studentId:Int!){<br>  student(id:$studentId) {<br>    name<br>    favoritePokemon @include(if: $caresAboutPokemon) {<br>      name<br>    }<br>  }<br>}</pre><p>You still need to pass in caresAboutPokemon, but it gives a lot of control over having different data be requested without having to do awkward string building.</p><p>There’s a <a href="https://graphql.org/learn/queries/">number of other tools</a> native to GraphQL that (often) come pre-packed without any extra effort from the developer, I highly recommend giving them a look.</p><p>All in all, GraphQL has proven to be an extremely powerful tool, and has provided a massive amount of versatility that has made building and modifying web pages extremely simple. I’m really hoping to see this trend of making technologies be more Front End developer friendly continue.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ae9889bbc7ab" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dealeron-dev/power-to-the-front-end-with-graphql-ae9889bbc7ab">Power to the Front End with GraphQL</a> was originally published in <a href="https://medium.com/dealeron-dev">DealerOn Dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What’s Wrong With Almost Every Database Ever]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/dealeron-dev/whats-wrong-with-almost-every-database-ever-9134c30fedc3?source=rss----c3eae8609d01---4"><img src="https://cdn-images-1.medium.com/max/2600/0*j-YhWM_6qwm3P-jN" width="5184"></a></p><p class="medium-feed-snippet">A first step for choosing a database is to select a general paradigm to use. There are a variety out there: relational, full-text&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/dealeron-dev/whats-wrong-with-almost-every-database-ever-9134c30fedc3?source=rss----c3eae8609d01---4">Continue reading on DealerOn Dev »</a></p></div>]]></description>
            <link>https://medium.com/dealeron-dev/whats-wrong-with-almost-every-database-ever-9134c30fedc3?source=rss----c3eae8609d01---4</link>
            <guid isPermaLink="false">https://medium.com/p/9134c30fedc3</guid>
            <category><![CDATA[nosql]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[database]]></category>
            <dc:creator><![CDATA[Eric Damtoft]]></dc:creator>
            <pubDate>Fri, 10 May 2019 13:01:01 GMT</pubDate>
            <atom:updated>2019-05-10T13:01:01.028Z</atom:updated>
        </item>
    </channel>
</rss>