<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Instana</title>
    <description>The latest articles on DEV Community by Instana (@instanahq).</description>
    <link>https://dev.to/instanahq</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F441724%2F2ff21e8f-c22b-49f1-a1bd-4d0dc16102ea.jpg</url>
      <title>DEV Community: Instana</title>
      <link>https://dev.to/instanahq</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/instanahq"/>
    <language>en</language>
    <item>
      <title>GitHub CoPilot, Code Automation, and Software Health</title>
      <dc:creator>Instana</dc:creator>
      <pubDate>Mon, 15 Aug 2022 13:39:28 +0000</pubDate>
      <link>https://dev.to/instanahq/github-copilot-code-automation-and-software-health-2e0b</link>
      <guid>https://dev.to/instanahq/github-copilot-code-automation-and-software-health-2e0b</guid>
      <description>&lt;p&gt;At Instana, we naturally talk a lot about strategies for automating operations, but this is just one part of the picture. Developers can also benefit from increasingly intelligent forms of automation.&lt;/p&gt;

&lt;p&gt;By now you’ve likely heard of GitHub Copilot, which is the most popular in a growing field of automated code assistance tools for developers.&lt;/p&gt;

&lt;p&gt;In our eBook &lt;a href="https://www.instana.com/resources/achieving-software-health-in-the-microservices-age/"&gt;Achieving Software Health&lt;/a&gt;, we discuss how code assistance tools can improve maintenance and repair of services and applications. Let’s take a closer look at some of those tools…&lt;/p&gt;

&lt;h2&gt;
  
  
  Commercial Code Assistance Tools
&lt;/h2&gt;

&lt;p&gt;GitHub released the first iteration of CoPilot in October 2021. Since then they have steadily added extensions for many popular editors. Amazon announced CodeWhisperer, which is currently in a preview program, on June 23rd this year.&lt;/p&gt;

&lt;p&gt;GitHub Copilot is currently the easiest to get started with — if you don’t mind paying for it — as the only requirements are a GitHub account and a compatible editor. CodeWhisperer requires interested developers to apply for the preview program, although being approved within a few days is common.&lt;/p&gt;

&lt;p&gt;Both of these tools offer a very similar feature set. The core feature is the ability to complete entire functions or even modules based on a code comment describing the developer’s intent. CodeWhisperer depends more on these comments, while CoPilot is more integrated into the editor’s typeahead autocompletion.&lt;/p&gt;

&lt;p&gt;CoPilot is almost aggressive in how quickly it will attempt to complete a line or definition, but you quickly adapt to the code hints. It is uncanny how well CoPilot can guess the name of a new function or variable based on context as soon as you begin the declaration.&lt;/p&gt;

&lt;p&gt;With either tool, you have the option to reject a suggestion or open a context menu to choose from a selection of alternative suggestions, which provides more experienced developers with the ability to choose their preferred solutions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Things Code Automation Tools Do Well
&lt;/h2&gt;

&lt;p&gt;So what can we do with this super-powered autocomplete? While it’s possible to have these tools build almost an entire (small) program from just a few comments, that is not how most developers will want to use them.&lt;/p&gt;

&lt;p&gt;If basic autocomplete as we’re familiar with in IDEs is like an autopilot — capable of maintaining a straight course and heading — then the CoPilot name is spot on (although “CodeWhisperer” just sounds cool, doesn’t it?). It is a helpful aide, almost like having an always-available junior pair programmer.&lt;/p&gt;

&lt;p&gt;In this role, the code completion tools can look up documentation and combine that with the context of your program to create the exact suggestion you need.&lt;/p&gt;

&lt;p&gt;For junior developers, or even experienced developers working in an unfamiliar language, there is a didactic nature to the experience that informs and educates through assistance and suggestion.&lt;/p&gt;

&lt;p&gt;Another excellent use for AI-assisted code completion is in writing boilerplate code. You, the developer, provide the intent and the architecture, and the code completion tool handles the bulk of the typing. In fact, according to Microsoft, CoPilot now writes 40% of the code on files where it has been enabled.&lt;/p&gt;

&lt;h2&gt;
  
  
  Open Source Options
&lt;/h2&gt;

&lt;p&gt;In addition to the commercial tools, a number of open source ML-driven code completion tools are in active development. The most general purpose of these is &lt;a href="https://github.com/CodedotAl/gpt-code-clippy"&gt;GPT Code Clippy&lt;/a&gt;, which has the aim of being a complete open source alternative to one of the commercial code assistance tools. It is based on the &lt;a href="https://arxiv.org/abs/2005.14165"&gt;GPT-3&lt;/a&gt; model and has an extension available for VSCode.&lt;/p&gt;

&lt;p&gt;Other tools exist for specific editors:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/HJLebbink/asm-dude"&gt;ASM Dude&lt;/a&gt;&lt;br&gt;&lt;br&gt;
A Visual Studio extension for Assembly&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/ycm-core/YouCompleteMe"&gt;YouCompleteMe&lt;/a&gt;&lt;br&gt;&lt;br&gt;
A code-completion plugin for Vim&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/samrawal/emacs-secondmate"&gt;SecondMate&lt;/a&gt;&lt;br&gt;&lt;br&gt;
A mini-copilot for Emacs&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Code Completion for Software Health
&lt;/h2&gt;

&lt;p&gt;You may be asking, “won’t these tools just enable garbage code to be generated that will increase our technical debt?”&lt;/p&gt;

&lt;p&gt;No.&lt;/p&gt;

&lt;p&gt;Unlike the boilerplate generators built into many popular frameworks, these code completion tools provide a conversational interface that leaves the developer in the driver’s seat at all times.&lt;/p&gt;

&lt;p&gt;This is the best kind of automation — the kind that reduces tedium for developers and operators and leaves them free to focus on the higher order solutions.&lt;/p&gt;

&lt;p&gt;The post &lt;a href="https://www.instana.com/blog/github-copilot-code-automation-and-software-health/"&gt;GitHub CoPilot, Code Automation, and Software Health&lt;/a&gt; appeared first on &lt;a href="https://www.instana.com"&gt;Instana&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>githubcopilot</category>
      <category>automation</category>
      <category>ai</category>
    </item>
    <item>
      <title>Shift Left Testing: What Is It and Why Does It Matter?</title>
      <dc:creator>Instana</dc:creator>
      <pubDate>Fri, 29 Jul 2022 14:27:34 +0000</pubDate>
      <link>https://dev.to/instanahq/shift-left-testing-what-is-it-and-why-does-it-matter-47cb</link>
      <guid>https://dev.to/instanahq/shift-left-testing-what-is-it-and-why-does-it-matter-47cb</guid>
      <description>&lt;p&gt;Have you been involved in a software project that ran over budget and blew past every deadline? Of course, you have – we all have. In fact, if you haven’t, you are a unicorn and I would like to hear from you.&lt;/p&gt;

&lt;p&gt;Early in my software development career, I learned the importance of working backwards from a deadline. If a project must be done by a certain date and testing will take a certain amount of time, then we can use that information to work backwards and choose a due date for our project. Perfect, right?&lt;/p&gt;

&lt;p&gt;Well, not quite. While building in time for testing reduced some stress in the final days of projects, there were still too many surprises.&lt;/p&gt;

&lt;p&gt;Building in time for QA testing is great in theory but quickly falls apart in practice once the first bug or defect is identified.&lt;/p&gt;

&lt;p&gt;How long will this defect take to fix? How much will it impact the timeline? Will new bugs be introduced? How will we ensure each fix is verified with time to fix anything we broke while we were fixing the first thing?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://xkcd.com/1739/"&gt;relevant xkcd&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Ultimately, I was never able to find the correct amount of time to allocate for QA. Inevitably, rushed fixes were merged at the last minute; I learned to keep my calendar clear for a couple of weeks after big launches so that I could triage all of the issues we missed (or introduced) in our mad dashes to the finish.&lt;/p&gt;

&lt;p&gt;The problem, at the end of the day, was not the &lt;strong&gt;time&lt;/strong&gt; available for testing but rather the &lt;strong&gt;timing&lt;/strong&gt; of the testing. I needed testing sooner and more often. I needed shift left testing.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is Shift Left Testing?
&lt;/h2&gt;

&lt;p&gt;If we imagine our software development process as a timeline flowing from left to right, then “shift left testing” becomes somewhat self-explanatory. Simply put, it is the practice of testing earlier and more often in the development life cycle.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Vvd5yVa6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.instana.com/media/shift-left-testing-model-1024x281.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Vvd5yVa6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.instana.com/media/shift-left-testing-model-1024x281.png" alt='Two area graphs overlayed. One, labeled "shift left testing" has a peak on the left side. Traditional software development has a peak on the right side of the graph.' width="880" height="241"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;What is Shift Left Testing?&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The V-Model of Software Development
&lt;/h2&gt;

&lt;p&gt;The V-model is a useful way to conceptualize software development cycles. If we take the traditional waterfall flow and “flip” the Y-axis at the implementation phase, we get the V-model.&lt;/p&gt;

&lt;p&gt;A development cycle begins with high-level requirements. These requirements are narrowed down with each successive step down the “V” until we reach the code-level implementation itself. We then verify the implementation, starting with the most granular unit tests and working our way up the “V” to more abstract user acceptance testing.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--z_S1kc6k--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.instana.com/media/software-development-v-model-1024x403.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--z_S1kc6k--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.instana.com/media/software-development-v-model-1024x403.png" alt="V model of software development" width="880" height="346"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In a waterfall process, the entire project is made up of a single “V.” As an industry, we have learned that when you leave all of your validation to the very end of a complex project, you are basically setting yourself up to fail.&lt;/p&gt;

&lt;p&gt;In an iterative process, we can think of each sprint or iteration as a smaller “V.” We have theoretically achieved our goals of shift left: testing sooner and more often. Problem solved, right? Well… not quite.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OoVNb36y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.instana.com/media/agile-software-development-1024x82.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OoVNb36y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.instana.com/media/agile-software-development-1024x82.png" alt="banner of the V model of software development in shift left testing" width="880" height="70"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Types of Shift Left Testing
&lt;/h2&gt;

&lt;p&gt;You may have noticed that there are two labels on the feedback channel built into the V-model: verification and validation. These are both important.&lt;/p&gt;

&lt;p&gt;We need to validate that our user requirements actually solve the problems we set out to solve. We also need to verify that our implementation matches the specifications we get from those user requirements.&lt;/p&gt;

&lt;p&gt;Automated testing can be applied to both validations and verifications. BDD (Behavior Driven Design) has led to the creation of technologies such as Cucumber that can automate some parts of the validation process. For the purposes of this article, we will focus on automated testing for verification.&lt;/p&gt;

&lt;h3&gt;
  
  
  Unit Testing
&lt;/h3&gt;

&lt;p&gt;Unit tests verify the functionality of a specific module within a larger application. The module is tested in isolation, and any communication with other external processes is simulated or mocked. Unit testing and TDD represent the first phase in shift left testing.&lt;/p&gt;

&lt;h3&gt;
  
  
  Integration Testing
&lt;/h3&gt;

&lt;p&gt;Integration tests attempt to verify the overall functionality of a service or application, including side effects. This is an anti-pattern for reasons we will discuss later.&lt;/p&gt;

&lt;h3&gt;
  
  
  API Testing / Contract Testing
&lt;/h3&gt;

&lt;p&gt;API tests verify the external endpoints of a single service. The scope of API tests is similar to the scope of integration tests; However, in an SOA or Microservices context, we can think of API tests as the new unit tests.&lt;/p&gt;

&lt;h3&gt;
  
  
  UI Testing
&lt;/h3&gt;

&lt;p&gt;UI tests verify the complete functionality of an application from the user interface layer. Tools like Selenium make automated UI testing widely accessible.&lt;/p&gt;

&lt;h3&gt;
  
  
  More Than Just Automation
&lt;/h3&gt;

&lt;p&gt;Shift left isn’t just about automation. Another way to test earlier and more often is to make sure that your QA specialists are involved in every step of your process, beginning with discovery and requirements gathering. Test engineers can do better when they have a greater understanding of the overall implementation, and their insights can help make the architecture more transparent and resilient.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Benefits of Shift Left Testing
&lt;/h2&gt;

&lt;p&gt;The shorter feedback loops built into shift left processes empower us in several ways. Defects can be found faster, fixes can be applied more efficiently, and lessons learned in one iteration can be applied in the next, to name a few.&lt;/p&gt;

&lt;p&gt;Whatever project management methodology or release cadence your team has, you can benefit from the shorter verification feedback loops from shift left testing.&lt;/p&gt;

&lt;h3&gt;
  
  
  Cost Savings
&lt;/h3&gt;

&lt;p&gt;A defect found by an automated unit test on a developer’s local machine is orders of magnitude cheaper to identify and fix than a defect that has made it all the way to a customer-facing environment.&lt;/p&gt;

&lt;h3&gt;
  
  
  Developer Wellbeing
&lt;/h3&gt;

&lt;p&gt;When done properly, &lt;a href="https://www.instana.com/blog/making-the-case-for-complete-ci-cd-automation/"&gt;automated testing and CI&lt;/a&gt; can provide the confidence that software engineers need to deploy often — even on Fridays. Finding defects sooner means fewer panicked all-hands moments. Since releases are so painless, fixing the few errors that do make it through is faster and easier too.&lt;/p&gt;

&lt;h3&gt;
  
  
  Resilient Architecture
&lt;/h3&gt;

&lt;p&gt;Just as more accessible software is usually easier to use for all of us, more testable software can be easier to reason about and maintain. Thinking about testing early can lead to better separation of concern and a more resilient overall architecture.&lt;/p&gt;

&lt;h3&gt;
  
  
  Greater Overall Quality
&lt;/h3&gt;

&lt;p&gt;Improving the customer experience is our ultimate goal. Shift left can eliminate some incidents that end users might experience and reduce the impact of other incidents. We can use observability to complete this feedback loop and improve our overall software health.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Dangers of Shift Left Testing
&lt;/h2&gt;

&lt;p&gt;With powerful automation tools at our disposal, it can be tempting to implement every kind of testing on every line of code. This is a dangerous path.&lt;/p&gt;

&lt;p&gt;Testing side effects — did that record actually get saved to the database? — is an attractive idea. But testing implementation details is an anti-pattern because these types of tests are extremely brittle. They might need to be changed every time your application is changed. The user interface is also an implementation detail, so UI tests land in this same boat.&lt;/p&gt;

&lt;p&gt;Verification tests just care about the “what,” not the “how” or the “why.” Ideally, the user requirements have been designed to validate “why.” To answer “how” we can rely on a more powerful automation in the form of an observability platform.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Get Started with Shift Left Testing
&lt;/h2&gt;

&lt;p&gt;When we think of testing “sooner and more often” a certain word comes to mind: continuous. Many (most) software development teams are practicing some form of continuous integration and &lt;a href="https://www.instana.com/blog/making-continuous-delivery-work-instanas-continuous-discovery-technology/"&gt;continuous delivery&lt;/a&gt;. Continuous testing is a vital feedback loop in this DevOps cycle.&lt;/p&gt;

&lt;h3&gt;
  
  
  Continuous Testing
&lt;/h3&gt;

&lt;p&gt;If we think of TDD as “Shift left for monoliths,” then continuous testing is “shift left for distributed architectures.”&lt;/p&gt;

&lt;p&gt;TDD had us focus on unit testing. For continuous testing we should focus on API and contract tests. API tests have a number of benefits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;API tests can prevent one of the most common ways to introduce errors in a &lt;a href="https://www.instana.com/blog/scaling-microservices-understanding-performance-and-observability/"&gt;microservices&lt;/a&gt; application: changing a dependency out of sync with its upstream or downstream services.&lt;/li&gt;
&lt;li&gt;API tests can be owned by the same team that owns the tested service.&lt;/li&gt;
&lt;li&gt;API tests avoid the brittleness of testing side effects and implementation details.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Ideally, these API tests will be run continuously against both production and pre-production environments. Contract testing tools can help automate this process, but that requires additional infrastructure.&lt;/p&gt;

&lt;p&gt;What if we could use continuous API testing built into our observability tool? The upcoming &lt;a href="https://www.instana.com/blog/synthetic-monitoring-is-coming-to-instana/"&gt;synthetic API testing&lt;/a&gt; feature from Instana will let you continuously run API tests against all of your environments with minimal effort.&lt;/p&gt;

&lt;h2&gt;
  
  
  Shift Left vs Shift Right
&lt;/h2&gt;

&lt;p&gt;Shift right testing is the practice of testing &lt;em&gt;later&lt;/em&gt; in the development process, usually in production environments. While it may seem strange, shift left and shift right testing are complimentary.&lt;/p&gt;

&lt;p&gt;Shift right testing allows us to identify production issues before our customers do. The shorter feedback loops from shift left testing give us the ability to respond to and remediate these production issues rapidly.&lt;/p&gt;

&lt;p&gt;Synthetic API testing as a part of your observability platform is the perfect way to combine the benefits of shift left and shift right practices.&lt;/p&gt;

&lt;p&gt;The post &lt;a href="https://www.instana.com/blog/what-is-shift-left-testing/"&gt;Shift Left Testing: What Is It and Why Does It Matter?&lt;/a&gt; appeared first on &lt;a href="https://www.instana.com"&gt;Instana&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>testing</category>
      <category>qa</category>
      <category>devops</category>
    </item>
    <item>
      <title>Instana Introduces OpenTelemetry Exporter for .NET</title>
      <dc:creator>Instana</dc:creator>
      <pubDate>Wed, 20 Jul 2022 13:39:39 +0000</pubDate>
      <link>https://dev.to/instanahq/instana-introduces-opentelemetry-exporter-for-net-32pe</link>
      <guid>https://dev.to/instanahq/instana-introduces-opentelemetry-exporter-for-net-32pe</guid>
      <description>&lt;h3&gt;
  
  
  What is OpenTelemetry?
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://opentelemetry.io/"&gt;&lt;strong&gt;OpenTelemetry&lt;/strong&gt;&lt;/a&gt; is an open-source project hosted by the &lt;a href="https://www.cncf.io/"&gt;&lt;strong&gt;CNCF&lt;/strong&gt;&lt;/a&gt; that provides APIs and SDKs for a variety of programming languages to instrument and collect observability data from applications. OpenTelemetry gives a framework for instrumenting, generating, collecting, and exporting telemetry data for analysis and understanding of software performance and behavior.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.instana.com/blog/the-rise-of-distributed-tracing-with-opentelemetry/"&gt;&lt;strong&gt;OpenTelemetry&lt;/strong&gt;&lt;/a&gt; offers a vendor-neutral data format that can be integrated with any data processing backend. This is possible thanks to a concept called “exporters.” An exporter allows you to configure which backend(s) you want it sent to. The exporter decouples the instrumentation from the backend configuration. This makes it easy to switch backends without the pain of re-instrumenting your code.&lt;/p&gt;

&lt;h3&gt;
  
  
  OpenTelemetry and .NET
&lt;/h3&gt;

&lt;p&gt;.NET is one of many languages supported by OpenTelemetry.&lt;/p&gt;

&lt;p&gt;To instrument the .NET application, you have to add a corresponding &lt;a href="https://www.nuget.org/packages?q=opentelemetry.instrumentation"&gt;NuGet package&lt;/a&gt; for the targeting runtime.&lt;/p&gt;

&lt;p&gt;From there on, every collected trace will be exported by the .NET Instana exporter and directly sent to Instana’s backend.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Span Exporter
&lt;/h3&gt;

&lt;p&gt;Once the OpenTelemetry instrumentation package is added, it will trace appropriate library, generating spans for every time that an instrumented library is called.&lt;/p&gt;

&lt;p&gt;But you have to tell the tracer what to do with these spans. That’s where the exporter comes in.&lt;/p&gt;

&lt;p&gt;The  &lt;strong&gt;exporter&lt;/strong&gt; understands the vendor-neutral span format, converts it to a specific format, and sends this data to a backend to be processed and displayed later.&lt;/p&gt;

&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;

&lt;p&gt;Let’s say we have one simple ASP .NET Core application which uses MSSQL database as storage. The Application exposes two endpoints to interact with database. The first endpoint named &lt;code&gt;/init&lt;/code&gt; is used for initialize database and insert one random integer value. Second endpoint &lt;code&gt;/read&lt;/code&gt; is used to read previously generated and inserted random integer value. &lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4pbWL0Z0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://ibm.ent.box.com/file/image-20220603115251508.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4pbWL0Z0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://ibm.ent.box.com/file/image-20220603115251508.png" alt="" width="" height=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--m_MLqsh---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.instana.com/media/image-20220603115251508-1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--m_MLqsh---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.instana.com/media/image-20220603115251508-1.png" alt="" width="880" height="196"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If we want to instrument this application using OpenTelemetry we have to add appropriate OpenTelemetry instrumentation packages. For this ASP .Net Core app we have to add &lt;code&gt;OpenTelemetry.Instrumentation.AspNetCore&lt;/code&gt; and because we are using MsSQL we have to add &lt;code&gt;OpenTelemetry.Instrumentation.SqlClient&lt;/code&gt; packages to generate spans every time those two libraries are called.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--O3x3bKOT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.instana.com/media/image-20220603115454335-1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--O3x3bKOT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.instana.com/media/image-20220603115454335-1.png" alt="" width="880" height="196"&gt;&lt;/a&gt;&lt;br&gt;&lt;br&gt;
 &lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uT_TeGWo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://ibm.ent.box.com/file/image-20220603115454335.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uT_TeGWo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://ibm.ent.box.com/file/image-20220603115454335.png" alt="" width="" height=""&gt;&lt;/a&gt;&lt;br&gt;&lt;br&gt;
At the end, we want to report it somewhere, so we need OTel exporter. In order to export traces from serverless environment to Instana backend we choose &lt;a href="https://www.nuget.org/packages/OpenTelemetry.Exporter.Instana/"&gt;OpenTelemetry.Exporter.Instana&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The crucial thing, in OTel .Net world everything starts with &lt;code&gt;TraceProvider&lt;/code&gt;so during initialization of this object we have to list all instrumentations and exporters. In our case that is &lt;code&gt;SqlClientInstrumentation&lt;/code&gt;, &lt;code&gt;AspNetCoreInstrumentation&lt;/code&gt; and because we want to report to Instana backend we have to add &lt;code&gt;InstanaExporter&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--x9KV60aU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.instana.com/media/image-20220603115523444.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--x9KV60aU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.instana.com/media/image-20220603115523444.png" alt="Adding InstanaExporter" width="880" height="253"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Also we have to provide two environment variables to the application before or during application starts. These variables are mandatory because exporter needs to know were to report generated spans:&lt;br&gt;&lt;br&gt;
&lt;code&gt;ENV INSTANA_ENDPOINT_URL=endpoint_url&lt;/code&gt;&lt;br&gt;&lt;br&gt;
&lt;code&gt;ENV INSTANA_AGENT_KEY=the_agent_key&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Each HTTP call which results with database call will be captured in this case and immediately reported to Instana’s backend. Here we can see HTTP entry call &lt;code&gt;/init&lt;/code&gt; with all following DB calls that are reported to Instana’s backend.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FQ2mL0D6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.instana.com/media/InitCall-1024x485.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FQ2mL0D6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.instana.com/media/InitCall-1024x485.png" alt="Instana injesting Open Telemetry Distrubuted Traces" width="880" height="417"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Same for &lt;code&gt;/read&lt;/code&gt;:&lt;br&gt;&lt;br&gt;
 &lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--q8pIkVk5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.instana.com/media/readCall-1024x488.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--q8pIkVk5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.instana.com/media/readCall-1024x488.png" alt="Instana and OpenTelemetry" width="880" height="419"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can see the converted and processed span data from OpenTelemetry in the Stan dashboard.&lt;/p&gt;

&lt;p&gt;In conclusion, OpenTelemetry is rapidly gaining popularity in the observability world, especially with the flexibility to be exported, consumed and processed by a vendor specific backend.&lt;/p&gt;

&lt;p&gt;Instana offers a convenient way to convert OpenTelemetry traces to the Instana platform for customers hosting the Instana Agent. But also for Node.js applications running in a serverless environment through the InstanaExporter.&lt;/p&gt;

&lt;p&gt;Instana is wherever our customers are. By introducing an OpenTelemetry exporter for span data, we continue supporting use cases of our customers and continue with our integration of OpenTelemetry as a first class citizen into our observability platform.&lt;/p&gt;

&lt;h3&gt;
  
  
  Check our solution on OpenTelemetry Github repository
&lt;/h3&gt;

&lt;p&gt;Let us know what you think! Check our OTel solution on &lt;a href="https://github.com/open-telemetry/opentelemetry-dotnet-contrib/tree/main/src/OpenTelemetry.Exporter.Instana"&gt;&lt;strong&gt;OTel Github repository&lt;/strong&gt;&lt;/a&gt; and leave us some feedback there or with &lt;a href="//mailto:support@instana.com"&gt;&lt;strong&gt;support@instana.com&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Come back to see how we work with and support the OpenTelemetry project.&lt;/p&gt;

&lt;p&gt;For more on Instana’s support of OpenTelemetry, here’s some additional reading material:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.instana.com/blog/dissecting-the-opentelemetry-collector-overview/"&gt;&lt;strong&gt;Dissecting the OpenTelemetry Collector: An&lt;br&gt;
Overview&lt;/strong&gt; &lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.instana.com/docs/ecosystem/opentelemetry/#main"&gt;&lt;strong&gt;OpenTelemetry&lt;br&gt;
documentation&lt;/strong&gt; &lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.instana.com/blog/instana-autotrace-fully-embracing-opentelemetry/"&gt;&lt;strong&gt;Instana AutoTrace: Fully Embracing&lt;br&gt;
OpenTelemetry&lt;/strong&gt; &lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.instana.com/blog/the-rise-of-distributed-tracing-with-opentelemetry/"&gt;&lt;strong&gt;The Rise of Distributed Tracing with&lt;br&gt;
OpenTelemetry&lt;/strong&gt; &lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.instana.com/blog/latest-instana-openshift-operator-automatically-collects-opentelemetry-on-red-hat-openshift/"&gt;&lt;strong&gt;Latest Instana OpenShift Operator Automatically Collects&lt;br&gt;
OpenTelemetry on Red Hat&lt;br&gt;
OpenShift&lt;/strong&gt; &lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The post &lt;a href="https://www.instana.com/blog/instana-introduces-opentelemetry-exporter-for-net/"&gt;Instana Introduces OpenTelemetry Exporter for .NET&lt;/a&gt; appeared first on &lt;a href="https://www.instana.com"&gt;Instana&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>announcement</category>
      <category>engineering</category>
    </item>
    <item>
      <title>What is OpenTelemetry?</title>
      <dc:creator>Instana</dc:creator>
      <pubDate>Thu, 14 Jul 2022 19:57:43 +0000</pubDate>
      <link>https://dev.to/instanahq/what-is-opentelemetry-3a33</link>
      <guid>https://dev.to/instanahq/what-is-opentelemetry-3a33</guid>
      <description>&lt;p&gt;You’ve probably heard of OpenCensus and OpenTracing, but what about OpenTelemetry? &lt;/p&gt;

&lt;p&gt;Distributed and cloud-native environments make it challenging to monitor application performance. The bottom line is if you’re looking to understand your system’s behavior, it’s crucial to collect telemetry data. The problem is that no product on the market has a single instrument for collecting this data across all of an organization’s applications and systems. That is until OpenTelemetry hit the market. &lt;/p&gt;

&lt;p&gt;OpenTelemetry has finally standardized a way for DevOps and IT professionals to collect and transmit telemetry data to your observability backend. In this guide, we’ll deep dive into what OpenTelemetry is, how it’s used, the benefits, and everything else you’d need to know to get started with this framework. &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;What Is OpenTelemetry?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--sSuurWDn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.instana.com/media/OpenTelemetry-03.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sSuurWDn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.instana.com/media/OpenTelemetry-03.jpg" alt="What is opentelemetry definition with Opentelemetry Symbol" width="880" height="284"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;OpenTelemetry is an open-source observability framework with a collection of software development kits (SDKs), vendor-neutral or vendor-agnostic APIs, and tools for instrumentation. This technology can generate, collect, export, and instrument telemetry data to analyze your platform’s behavior and performance. Opentelemetry is also known as OTel. &lt;/p&gt;

&lt;p&gt;IT groups and DevOps professionals must use instrumentation to create an observable system in &lt;a href="https://www.instana.com/blog/the-evolution-of-apm-and-cloud-native-applications/"&gt;cloud-native applications&lt;/a&gt;. Instrumentation code used to be varied, making it difficult for companies to change backends. It was hard to switch tools because they would need to reinstrument their code and reconfigure new agents to send telemetry data to their new devices.&lt;/p&gt;

&lt;p&gt;After seeing the need for a standardized system, &lt;a href="https://www.cncf.io/"&gt;Cloud Native Computing Foundation&lt;/a&gt; (CNCF) sponsored the OpenTelemetry project to create a standardized way to send, collect, and transfer telemetry data to backend observability platforms. OpenTelemetry was born from combining the distributed tracing technology of &lt;a href="https://opencensus.io/"&gt;OpenCensus&lt;/a&gt; and &lt;a href="https://opentracing.io/"&gt;OpenTracing&lt;/a&gt; into one tool.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;What Is Telemetry Data?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;To gain a deeper understanding of OpenTelemetry, let’s deep dive into what telemetry data is and how your organization can utilize it. &lt;/p&gt;

&lt;p&gt;A key part of successful application performance is having observability through access to data.  IT professionals use telemetry data to determine the health and performance of your application. &lt;/p&gt;

&lt;p&gt;OpenTelemetry creates a standard for collecting and transferring telemetry data in cloud-native applications. These metrics can then be analyzed and monitored by your organization to improve your platforms. &lt;/p&gt;

&lt;p&gt;Telemetry data is composed primarily of outputs collected from logs, metrics, and traces. These are often referred to as the three pillars of observability. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Logs:&lt;/strong&gt; Logs are a timestamp or record of events in your application. The important events identified using logs show errors or unpredictable behaviors within your system. This information will signal to your internal teams that a problem has occurred so you can fix it before more users experience the error. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Metrics:&lt;/strong&gt; Metrics are typically where you’ll see the first sign of an issue occurring in your system. These give you numerical values or sets of measurements that show your resource utilization and application performance. The three main types of metrics are delta, gauge, and cumulative. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Traces:&lt;/strong&gt; Traces evaluate how requests move through a server in distributed cloud environments. It looks at this by monitoring how an operation transfers from node to node. Traces can only provide limited visibility into application health because it is solely focused on application layers. To get a complete picture of what is going on in your system, it’s also essential to monitor your metrics and logs.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Collecting telemetry data is an important step in the OpenTelemetry and observability process. Next, we’ll discuss how OpenTelemetry is used in a dispersed cloud environment.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;How Does OpenTelemetry Work?&lt;/strong&gt;   &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5ScxrxI6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.instana.com/media/OpenTelemetry-04-1.jpg" alt="Showing how does Opentelemetry work with an explanation of each of its components" width="880" height="462"&gt;
&lt;/h2&gt;

&lt;p&gt;In a nutshell, OpenTelemetry works by combining an API, SDK, Collector, and automatic instrumentation to pull data and send it to its target system. In order to make your system more agnostic, there are several steps it needs to take using these components.&lt;/p&gt;

&lt;p&gt;An API will create traces by instrumenting your code and dictating which metrics need to be collected. Your SDK will then gather, translate, and sends that data to the next stage. The OpenTelemetry Collector processes the data, filters it, and exports it to a supported backend. &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Components of OpenTelemetry&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;There are many moving pieces when it comes to making OTel’s data collection successful. Here is an in-depth explanation of the &lt;strong&gt;four major components of OpenTelemetry&lt;/strong&gt; : &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;API:&lt;/strong&gt; Application Performance Interface (API) enables different software components to communicate with each other. It defines data operations for logging, metrics, and tracing data. Essentially, OpenTelemetry APIs decouple an application from the infrastructure, allowing developers to have the flexibility to switch servers that run your cloud. APIs are language-specific (Java, Ruby, JavaScript, Python, etc.).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SDK:&lt;/strong&gt; DevOps professionals can use language SDKs to allow OTel APIs to generate telemetry data in the language of their choice. After they have generated this data, you can export the information to your desired backend. OpenTelemetry SDKs make it possible to connect common libraries’ manual instrumentation with applications’ manual instrumentation. SDKs are the bridge between APIs and collectors. It stands for software development kit.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Collector:&lt;/strong&gt; The OpenTelemetry Collector exports, processes, and receives telemetry data. It can support Prometheus, OTLP, Jaeger, and other proprietary tools. It can take telemetry data and send it to multiple observability backends. Lastly, it can assist your organization in filtering and processing your data before exporting.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each of these components makes up the framework for why OTel is a winning addition to monitoring your application. &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;What Are The Benefits of OpenTelemetry?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;There are many benefits to using OpenTelemetry for your open source projects. Each of these benefits will help improve &lt;a href="https://www.instana.com/blog/observability-vs-monitoring/"&gt;observability and monitoring&lt;/a&gt;. These benefits explain why OTel is the future of application performance monitoring (APM).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Consistency:&lt;/strong&gt; The main benefit of OpenTelemetry is the consistency of collecting OpenTelemetry data across different applications. A lack of a unified standard creates problems for Dev Ops professionals and SREs. OTel now saves you time, gives you more observability, and collects telemetry data without changing your code. The broad adoption of this technology across organizations has made it easier to implement container deployment. This is similar to the mass embracement of Kubernetes as the standard for container orchestration. &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Simplified Observability:&lt;/strong&gt; OTel simplifies observability because it can collect telemetry data without changing code. Now developers don’t have to stick to specific backends or vendors. &lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  - &lt;strong&gt;Flexibility:&lt;/strong&gt; Developers can monitor performance metrics and usage from any web browser or device. The convenience of observing your application from any location makes it easier to track your analytics in real-time. 
&lt;/h2&gt;

&lt;p&gt;Overall, OpenTelemetry’s primary benefit is that it can help you achieve your optimal business goals. This software enables your organization to understand and fix issues that could negatively impact your customer experience. OpenTelemetry gives you the data needed to stop a problem in its tracks before your service is interrupted.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;What is OpenTelemetry Used For?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--aPuq5_s3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.instana.com/media/OpenTelemetry-05.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--aPuq5_s3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.instana.com/media/OpenTelemetry-05.jpg" alt="Symbols showing that combining OpenTracing and OpenCensus created OpenTelemetry" width="880" height="329"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;OpenTelemetry’s primary goal is to collect and export telemetry data. OTel assists DevOps professionals in debugging and managing applications. Once they have this data, they can make informed coding decisions and adjust as their organization continues to change and grow. &lt;/p&gt;

&lt;p&gt;There are three main ways OpenTelemetry is used in DevOps to solve application problems:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Prioritizes Requests:&lt;/strong&gt; OpenTelemetry has the unique ability to create a tier system for requests within your system. This is important because competing requests will be correctly prioritized. &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Track Resource Usage:&lt;/strong&gt; Capture requests between microservers to attribute resource usage by groups. IT professionals can track this resource usage between shared systems.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Observability of Microservices:&lt;/strong&gt; Monitor the health of your application by recording telemetry data from applications in distributed systems. Having this information will help your team optimize and run your application correctly. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each of these features helps organizations solve common errors when running applications across cloud-native systems. &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;OpenTelemetry vs OpenTracing&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;OpenTracing is an open-source project that assists developers in instrumenting code for distributed tracing through vendor-neutral APIs. This is beneficial because it doesn’t force you to stick with one particular vendor or product.&lt;/p&gt;

&lt;p&gt;This project is available in nine different languages, including Ruby, Java, and Python. DevOps and IT professionals can use distributed tracing to optimize and debug software architecture code. It is especially useful when dealing with &lt;a href="https://www.instana.com/blog/scaling-microservices-understanding-performance-and-observability/"&gt;microservices&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;The CNCF created OpenTelemetry by merging OpenTracing and OpenCensus into one platform. There have been over 10,000 contributions from 300 companies since the project was deployed. The encouragement of broad collaboration and additions has created access to a large set of instrumentation that is unmatched in the industry. &lt;/p&gt;

&lt;p&gt;If you were going to choose between the two open source platforms, it would be smart to go with OpenTelemetry since it has more capabilities. &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Is OpenTelemetry The Future of Instrumentation?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;OpenTelemetry is changing the landscape of observability. Similar to Kubernetes becoming the standard for container orchestration, OpenTelemetry is becoming widely adopted for observability.  Opentelemetry’s adoption and popularity will continue to soar because of the OpenTelemetry benefits we stated above.  &lt;/p&gt;

&lt;p&gt;The OpenTelemetry project teams continue to work on stabilizing the software’s core components and creating automated instrumentation. Once it is out of the beta stage, it’s projected to take over the observability framework in cloud-native ecosystems. &lt;/p&gt;

&lt;h2&gt;
  
  
  *&lt;em&gt;Achieve Your Business Goals With Instana and OpenTelemetry *&lt;/em&gt;
&lt;/h2&gt;

&lt;p&gt;The bottom line is that OpenTelemetry is not an observability backend but a tool that makes collecting and sending telemetry data more streamlined. Instana is the final piece of this equation as the observability backend. OpenTelemetry formats and SDKs can be a migration path for legacy systems and unsupported technologies. &lt;/p&gt;

&lt;p&gt;Our organization is committed to fully embracing OTel to help you achieve business goals through simplified data collection. We are working on giving users the same visibility that they get with Instana’s AutoTrace through our integration with OpenTelemetry.&lt;/p&gt;

&lt;p&gt;The post &lt;a href="https://www.instana.com/blog/what-is-opentelemetry/"&gt;What is OpenTelemetry?&lt;/a&gt; appeared first on &lt;a href="https://www.instana.com"&gt;Instana&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>observability</category>
      <category>opentelemetry</category>
      <category>apm</category>
    </item>
    <item>
      <title>How We Optimize Complex Queries at Processing Time</title>
      <dc:creator>Instana</dc:creator>
      <pubDate>Mon, 27 Jun 2022 19:09:33 +0000</pubDate>
      <link>https://dev.to/instanahq/how-we-optimize-complex-queries-at-processing-time-1531</link>
      <guid>https://dev.to/instanahq/how-we-optimize-complex-queries-at-processing-time-1531</guid>
      <description>&lt;h2&gt;
  
  
  Context
&lt;/h2&gt;

&lt;p&gt;Instana aims to provide accurate and instant application monitoring metrics on dashboards and in &lt;a href="https://www.ibm.com/docs/en/obi/current?topic=capabilities-unbounded-analytics"&gt;Unbounded Analytics&lt;/a&gt;. These metrics are calculated based on millions of &lt;a href="https://www.ibm.com/docs/en/obi/current?topic=monitoring-traces#call"&gt;calls&lt;/a&gt; collected from the systems under monitoring. Calls are stored in &lt;a href="https://clickhouse.com/docs/en/intro/"&gt;Clickhouse&lt;/a&gt; which is a columnar database and each call has hundreds of tags stored in columns.&lt;/p&gt;

&lt;p&gt;We use various techniques to speed up the querying of this data. The most important one is the use of &lt;a href="https://altinity.com/blog/clickhouse-materialized-views-illuminated-part-1"&gt;materialized views&lt;/a&gt;. The idea is to select a couple of most frequently used tags such as &lt;code&gt;service.name&lt;/code&gt;, &lt;code&gt;endpoint.name&lt;/code&gt;, &lt;code&gt;http.status&lt;/code&gt; etc., and pre-aggregate metrics (call count, latency, error rate etc.) over these tags into buckets of different sizes (1min, 1h). The materialized view contains much fewer data than the original table so it is much faster to read, filter and aggregate from the view. You can also check out another technique in one of my previous &lt;a href="https://www.instana.com/blog/improve-query-performance-with-clickhouse-data-skipping-index/"&gt;blog posts on the data skipping index&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;However, this approach has a limitation. There are 2 types of tags that cannot be included into the materialized view. Therefore, queries filtering or grouping by these tags cannot be optimized:&lt;/p&gt;

&lt;h4&gt;
  
  
  Tag that has very high cardinality
&lt;/h4&gt;

&lt;p&gt;Including tags like &lt;code&gt;http.url&lt;/code&gt; into the materialized view will increase the number of rows in the view. For example, if we only include &lt;code&gt;endpoint.name&lt;/code&gt; in the view, endpoint &lt;code&gt;/api/users/{id}&lt;/code&gt; will have only 1 row per minute if the bucket size is 1 minute. However, if we include &lt;code&gt;http.path&lt;/code&gt; in addition and the endpoint receives requests with hundreds of different paths such as &lt;code&gt;/api/users/123&lt;/code&gt;, each unique path would generate a new row in the view.&lt;/p&gt;

&lt;h4&gt;
  
  
  Custom key value pair tag defined by the user
&lt;/h4&gt;

&lt;p&gt;Users could add custom tags to an agent (&lt;code&gt;agent.tag&lt;/code&gt;), to a call through SDK (&lt;code&gt;call.tag&lt;/code&gt;), to a docker container (&lt;code&gt;docker.label&lt;/code&gt;) or define a custom HTTP header (&lt;code&gt;call.http.header&lt;/code&gt;). Each tag has a custom key and value, e.g. &lt;code&gt;agent.tag.env=prod&lt;/code&gt;, &lt;code&gt;docker.label.version=1.0&lt;/code&gt;. The keys are dynamic and unknown to Instana, so we cannot create a static materialized view on top of these columns.&lt;/p&gt;

&lt;p&gt;We need to figure out a solution to optimize the latency of queries using these tags.&lt;/p&gt;

&lt;h2&gt;
  
  
  Solution
&lt;/h2&gt;

&lt;p&gt;The solution we came up with is to automatically detect complex queries that cannot be optimized by the materialized views, register them as &lt;em&gt;precomputed filters&lt;/em&gt; and tag calls matching these filters during processing time. The idea is to move the complexity from query time to the processing time. This allows to better distribute the filtering and aggregation work load over time during call processing. When the load increases, it’s easier and less costly to scale out the processing component than the database.&lt;/p&gt;

&lt;p&gt;The general architecture looks as following:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4F38kRT7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.instana.com/media/complex-query-optimization-architecture-1024x657.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4F38kRT7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.instana.com/media/complex-query-optimization-architecture-1024x657.png" alt="" width="880" height="565"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Step 1: The reading component detects and registers the complex queries as a &lt;em&gt;precomputed filter&lt;/em&gt; and pushes them to a shared database. A &lt;em&gt;precomputed filter&lt;/em&gt; is basically mapping between a key and a complex filtering with tags on the calls, e.g. &lt;code&gt;filter1: endpoint.name=foo AND call.http.header.version=88 AND call.tag.os=android AND call.erroneous=true&lt;/code&gt;, plus some metadata such as creation time or last hit time.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Step 2: The processing component reads the &lt;em&gt;precomputed filters&lt;/em&gt; from the shared database. Each incoming call will be matched against all the registered &lt;em&gt;precomputed filters&lt;/em&gt;. If there’s a match, the call will be tagged with the filter id. A call can be tagged with multiple ids if it matches multiple filters.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Step 3: Calls are stored in Clickhouse with an additional column &lt;code&gt;precomputed_filter_ids Array(String)&lt;/code&gt;. We then create a materialized view which groups calls by each precomputed filter id. The id will be the primary key and sorting key of the view table, followed by the bucket timestamp, so querying the view filtered by id is extremely fast.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--LznGQmB2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.instana.com/media/complex-query-table-layout-1024x399.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LznGQmB2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.instana.com/media/complex-query-table-layout-1024x399.png" alt="" width="880" height="343"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Step 4: The reading component can transform a complex query into &lt;code&gt;precomputed_filter.id = xxx&lt;/code&gt;, and query the materialized view to return the metrics for calls matching the complex query.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Sample pseudo query:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;SELECT SUM(call_count)&lt;br&gt;
&lt;/code&gt;&lt;code&gt;FROM precomputed_filter_view&lt;br&gt;
WHERE time &amp;gt; toDateTime(‘2022-06-01 00:00:00’)&lt;br&gt;
AND time &amp;lt; toDateTime(‘2022-06-01 12:00:00’)&lt;br&gt;
AND precomputed_filter_id = ‘1’&lt;/code&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  How do we handle grouping?
&lt;/h4&gt;

&lt;p&gt;&lt;code&gt;precomputed_filter.id = xxx&lt;/code&gt; only handles the filtering part, if the query requests for metrics grouped by a tag such as &lt;code&gt;endpoint.name&lt;/code&gt;, we need to handle this with additional steps:&lt;/p&gt;

&lt;p&gt;During the processing, if a call matches the filter, we need to extract the value of the grouping tag &lt;code&gt;endpoint.name&lt;/code&gt; from the call, and also store this tag in an additional column. The column will also be included in the materialized view, placed after the &lt;code&gt;precomputed_filter_id&lt;/code&gt; and &lt;code&gt;time&lt;/code&gt; columns in the sorting key.&lt;/p&gt;

&lt;p&gt;Sample pseudo query:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;SELECT precomputed_filter_group, SUM(call_count)&lt;br&gt;
FROM precomputed_filter_view&lt;br&gt;
WHERE time &amp;gt; toDateTime(‘2022-06-01 00:00:00’)&lt;br&gt;
AND time &amp;lt; toDateTime(‘2022-06-01 12:00:00’)&lt;br&gt;
AND precomputed_filter_id = ‘1’&lt;br&gt;
GROUP BY precomputed_filter_group&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Result
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5P4nmA0u--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.instana.com/media/query_analysis-1024x390.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5P4nmA0u--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.instana.com/media/query_analysis-1024x390.png" alt="" width="880" height="335"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Above is a very coarse-grained analysis of queries customers did during a day in our EU region, broken down by different tables and views. We can see that the queries to the precomputed filter materialized view is almost 10 times faster than those to the original calls table, and 3 times faster than a query optimized by the materialized view of the same bucket size (1min).&lt;/p&gt;

&lt;h2&gt;
  
  
  Limitations and future improvements
&lt;/h2&gt;

&lt;p&gt;The major limitation is that a query can only be optimized after it’s first registered as a precomputed filter. It works well for recurrent queries that users do on a regular basis. However, if a user runs an ad-hoc query in Unbounded Analytics for the first time over the last day or so, the optimization can not kick in immediately. To limit the load on the processing pipeline, we also disable a precomputed filter if it’s not used over a certain period of time.&lt;/p&gt;

&lt;p&gt;Some complex queries are predictable if they are configured in a custom dashboard or alerting configuration. In these cases, we can use the configuration to create &lt;em&gt;precomputed filters&lt;/em&gt; so that even users can see the metrics and charts quickly even if they open the custom dashboard or jump from an alert to Unbounded Analytics for the first time.&lt;/p&gt;

&lt;p&gt;The post &lt;a href="https://www.instana.com/blog/optimize-complex-columnar-queries/"&gt;How We Optimize Complex Queries at Processing Time&lt;/a&gt; appeared first on &lt;a href="https://www.instana.com"&gt;Instana&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>clickhouse</category>
      <category>programming</category>
      <category>observability</category>
      <category>database</category>
    </item>
    <item>
      <title>Full-Cycle Observability With Instana and Lightrun</title>
      <dc:creator>Instana</dc:creator>
      <pubDate>Fri, 25 Mar 2022 07:00:38 +0000</pubDate>
      <link>https://dev.to/instanahq/full-cycle-observability-with-instana-and-lightrun-12ec</link>
      <guid>https://dev.to/instanahq/full-cycle-observability-with-instana-and-lightrun-12ec</guid>
      <description>&lt;p&gt;We are excited to announce that Lightrun had partnered with Instana to enrich existing telemetry with real-time, code-level observability data and provide full-cycle Observability.&lt;/p&gt;

&lt;p&gt;Understanding everything that happens inside a production environment is a notoriously difficult task.&lt;/p&gt;

&lt;p&gt;Instana’s solution helps developers and DevOps become aware of problems quickly – problems that are rooted in both infrastructure-level information and application-level information. Lightrun, on the other hand, enables practitioners to drill deeper into line-by-line, debugger-grade information from your production systems – enriching the existing information Instana delivers.&lt;/p&gt;

&lt;p&gt;When application problems occur in production, it’s important to gain immediate access to information regarding the “full lay of the land”, including all the relevant components that could have been the root cause. There’s a term that refers to that level of comprehension of an application: Observability.&lt;/p&gt;

&lt;p&gt;Observability is a property of an application system. An observable system enables DevOps to answer any question about it from outside the system. Observability is a great determining factor in whether we can troubleshoot tough bugs quickly and whether our system is considered reliable. Fast issue resolution (usually measured as MTTR – mean time to resolve) is a great indicator for reliability.&lt;/p&gt;

&lt;p&gt;However, Observability is not just “one thing” – there isn’t a single button you can push to get all the information you want. In fact, when tackling tough issues we often rely on various types of telemetry data to clarify what is actually happening under the hood. We can divide this data, broadly, into two levels of granularity: Infrastructure-level information and application-level information.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--umrVru_R--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.instana.com/media/LR1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--umrVru_R--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.instana.com/media/LR1.png" alt="" width="468" height="273"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The integration between Instana and Lightrun allows us to create full-cycle observability, which in practice looks like this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;We’ll first use Instana to understand how the machine running our application or our application itself is feeling, and identify various issues (like performance degradations).&lt;/li&gt;
&lt;li&gt;Then, Developers and DevOps can use Lightrun from the IDE (Integrated Development Environment) to add real-time, on-demand logs, metrics and traces to the running application – without stopping the application or shipping new code.&lt;/li&gt;
&lt;li&gt;The information provided by Lightrun automatically makes its way to Instana and can be consumed right next to information provided by Instana – closing the aforementioned cycle.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;These capabilities are important for Development, DevOps, and SRE practitioners for maintaining application performance and reliability.&lt;/p&gt;

&lt;p&gt;For DevOps teams, it helps them instantly review live application environment problems that require triage and optimize the procedures for delivering issue remediation.&lt;/p&gt;

&lt;p&gt;For SRE teams, it helps them rapidly identify and repair issues that impact application operations, scaling and reliability.&lt;/p&gt;

&lt;p&gt;Developers can debug application code, from their IDE, in production, test, and development without stopping the application or installing updates. This can significantly reduce issue MTTR.&lt;/p&gt;

&lt;p&gt;Combining these two tools to effectively tag-team the problem is a good idea, and will provide enough visibility into the running application to solve many critical production issues.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.lightrun.com/integrations/instana/"&gt;Check out this information&lt;/a&gt; about how to use Instana with Lightrun.&lt;/p&gt;

&lt;p&gt;Try out Instana with a guided tour in our &lt;a href="https://www.instana.com/apm-observability-sandbox/"&gt;Play With environment&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The post &lt;a href="https://www.instana.com/blog/full-cycle-observability-with-instana-and-lightrun/"&gt;Full-Cycle Observability With Instana and Lightrun&lt;/a&gt; appeared first on &lt;a href="https://www.instana.com"&gt;Instana&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>announcement</category>
      <category>developer</category>
      <category>devops</category>
      <category>microservices</category>
    </item>
    <item>
      <title>The SRE Guide to Hyperscale for Cloud-Native Applications</title>
      <dc:creator>Instana</dc:creator>
      <pubDate>Tue, 01 Mar 2022 15:19:25 +0000</pubDate>
      <link>https://dev.to/instanahq/the-sre-guide-to-hyperscale-for-cloud-native-applications-2231</link>
      <guid>https://dev.to/instanahq/the-sre-guide-to-hyperscale-for-cloud-native-applications-2231</guid>
      <description>&lt;p&gt;In my &lt;a href="https://www.instana.com/blog/the-sre-guide-to-hyper-resilient-hyperscale-for-cloud-native-applications/"&gt;previous post&lt;/a&gt;, I discussed the advantages of using Instana Enterprise Observability for achieving hyper-resiliency for applications, particularly cloud-native applications. Hyper-resiliency is usually defined as 99.99% system and application availability, or four 9s. Essentially, it is the ability to perform non-stop computing.&lt;/p&gt;

&lt;p&gt;In the cloud, high availability can be difficult, even with the ubiquitous use of cluster technology. Meanwhile, hyperscale for cloud-native applications occurs when infrastructure resources are properly allocated to applications as they scale. If resources are mis-allocated, especially if they’re under-allocated, application performance can degrade or even stop.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.instana.com/enterprise-observability-platform"&gt;Instana Enterprise Observability&lt;/a&gt; helps keep applications available by notifying app teams when problems begin. Granular metrics, events, and traces with context enable teams to rapidly identify issues.&lt;/p&gt;

&lt;p&gt;If the availability or performance issues are caused by under-allocated or unbalanced resources (CPU, memory, network, and storage), Instana can pass that data to Turbonomic, another IBM company. &lt;a href="https://www.turbonomic.com/"&gt;Turbonomic&lt;/a&gt; provides Application Resource Management (ARM), which automatically and dynamically manages and allocates infrastructure resources for applications.&lt;/p&gt;

&lt;p&gt;Combining Turbonomic ARM with Instana Enterprise Observability keeps application resource allocation optimized to ensure Service Level Objectives for both performance and availability. ARM procedures can be fully automated or partially automated to enable server resource adjustments that enhance application resiliency and performance, and optimize resource allocation cost.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;How ARM and observability work together&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Instana monitors application metrics, events, traces, and logs to provide a rich mosaic of application health information. It captures these measurements at unmatched one-second intervals. At this frequency, Instana can observe and identify any issues, either application or infrastructure, and match them with upstream and downstream dependencies in real time.&lt;/p&gt;

&lt;p&gt;One-second monitoring granularity is one of the most critical attributes for hyper-resiliency because longer sample times of 10 seconds or higher are not adequate for detecting anomalies. Events in microservice applications and the surrounding infrastructure take place in microseconds, meaning that they can go undetected for a long time with sampling.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.instana.com/media/turbonomic-blog-imagee.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FoBazJg9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.instana.com/media/turbonomic-blog-imagee.png" alt="Events in microservice applications and the surrounding infrastructure take place in microseconds, meaning that they can go undetected for a long time with sampling." width="880" height="588"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Instana’s Enterprise Observability powers rapid anomaly recognition so Turbonomic can apply problem remediation to provide the strongest SLO compliance. If it’s a code issue, Instana’s Auto Profiler identifies the problematic code within a few clicks.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.turbonomic.com/resources/data-sheets/instana-turbonomic-overview/"&gt;The combination of Instana + Turbonomic&lt;/a&gt; creates a seamless and automatic remediation path for any issues that are attributable to mismatched application resources.&lt;/p&gt;

&lt;p&gt;For cloud-native applications, those mismatches happen frequently. One moment your applications are starved for resources due to a sudden surge in activity; moments later, they’re over-allocated as the demand surge drops.&lt;/p&gt;

&lt;p&gt;When application infrastructure resources are low for any microservice, performance degrades – or worse, service crashes. Instana identifies the slow application response time, highlights constrained resources that may be the root cause of the disruption, and passes that data to Turbonomic.&lt;/p&gt;

&lt;p&gt;Turbonomic knows exactly why the resources are constrained and the right adjustment to remediate the disruption. These actions are illustrated in the diagram below, which highlights how Turbonomic adjusts constrained resources based on a target response time.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.instana.com/media/graphical-user-interface-website-description-aut-c.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--36362C_p--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.instana.com/media/graphical-user-interface-website-description-aut-c.png" alt="Turbonomic adjusts constrained resources based on a target response time." width="880" height="364"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Proper resource allocation is critical
&lt;/h3&gt;

&lt;p&gt;Turbonomic acts when resources are under-allocated to make sure that performance degradation (or worse) does not occur. Turbonomic automatically adjusts application resources to avoid resource contention or under-allocation that can negatively impact SLOs.&lt;/p&gt;

&lt;p&gt;Conversely, when resources are over-allocated, Turbonomic automatically makes adjustments based on thresholds you define. This helps dramatically reduce cloud overspend, which is equally problematic&lt;/p&gt;

&lt;p&gt;Instana + Turbonomic is a power combo that will rapidly become an SRE’s best friend. The combination enables hyperscale with hyper-resiliency, cost effectively. It paves the path to automated SLO compliance and continuous performance consistency, especially for your cloud-native applications.&lt;/p&gt;

&lt;p&gt;Try out Instana with a guided tour in our &lt;a href="https://www.instana.com/apm-observability-sandbox/"&gt;Play With environment&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The post &lt;a href="https://www.instana.com/blog/the-sre-guide-to-hyperscale-for-cloud-native-applications/"&gt;The SRE Guide to Hyperscale for Cloud-Native Applications&lt;/a&gt; appeared first on &lt;a href="https://www.instana.com"&gt;Instana&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>sre</category>
      <category>devops</category>
      <category>arm</category>
      <category>apm</category>
    </item>
    <item>
      <title>Dissecting the OpenTelemetry Collector: An Overview</title>
      <dc:creator>Instana</dc:creator>
      <pubDate>Thu, 04 Nov 2021 15:53:14 +0000</pubDate>
      <link>https://dev.to/instanahq/dissecting-the-opentelemetry-collector-an-overview-2pnc</link>
      <guid>https://dev.to/instanahq/dissecting-the-opentelemetry-collector-an-overview-2pnc</guid>
      <description>&lt;p&gt;The OpenTelemetry Collector is the central data collection mechanism for the OpenTelemetry project. We’re going to focus on different angles in subsequent articles, but for now let’s look at it more generally.&lt;/p&gt;

&lt;h3&gt;
  
  
  Deployment
&lt;/h3&gt;

&lt;p&gt;With single agent we refer to a scenario where the observability vendor provides a single agent that customers can deploy to their systems, that then acts as a data collection mechanism. In case of Instana, this would be the &lt;a href="https://www.instana.com/docs/setup_and_manage/host_agent"&gt;Instana Agent&lt;/a&gt;. You would deploy it to your systems via one of the supported mechanisms and basically leave it at that.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://opentelemetry.io/docs/collector/"&gt;OpenTelemetry Collector&lt;/a&gt; supports this scenario, and &lt;a href="https://opentelemetry.io/docs/collector/getting-started/"&gt;the project describes it as follows&lt;/a&gt;: “A Collector instance running with the application or on the same host as the application (e.g. binary, sidecar, or daemonset)”&lt;/p&gt;

&lt;h3&gt;
  
  
  Components &amp;amp; Pipelines
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0QU03aCM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.instana.com/media/Bildschirmfoto-2021-10-28-um-11.58.18-1024x555.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0QU03aCM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.instana.com/media/Bildschirmfoto-2021-10-28-um-11.58.18-1024x555.png" alt="The OpenTelemetry collector architecture" width="880" height="477"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;The OpenTelemetry (Otel) collector architecture – source: &lt;a href="https://opentelemetry.io/docs/collector/"&gt;https://opentelemetry.io/docs/collector/&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;OpenTelemetry recognizes four signal types. Three are explicit: spans, metrics, logs. The fourth is resource description. All three explicit signals are processed in a pipeline. That gives an opportunity to individually post-process and export them to the desired target. If you were to implement a fully open source-based approach to observability, you might be using &lt;a href="https://www.instana.com/docs/ecosystem/prometheus/#main"&gt;Prometheus&lt;/a&gt; for metrics, &lt;a href="https://www.instana.com/docs/ecosystem/jaeger/#main"&gt;Jaeger&lt;/a&gt; for traces and some &lt;a href="https://www.instana.com/docs/ecosystem/elk/#main"&gt;ELK stack&lt;/a&gt; for your logging needs. These tools all expect their signals in a dedicated format.&lt;/p&gt;

&lt;p&gt;The collector nicely separates those signals into “pipelines,” which helps in tailoring the inputs for the desired output. An example definition for pipelines might look like this:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;service:&lt;br&gt;
pipelines:&lt;br&gt;
metrics:&lt;br&gt;
receivers: [opencensus, prometheus]&lt;br&gt;
exporters: [opencensus, prometheus]&lt;br&gt;
traces:&lt;br&gt;
receivers: [jaeger]&lt;br&gt;
processors: [batch]&lt;br&gt;
exporters: [zipkin]&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This defines two pipelines: metrics and traces, where the the &lt;a href="https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/opencensusreceiver"&gt;opencensus-receiver&lt;/a&gt; is essentially opening an HTTP endpoint to receive OpenCensus data and the &lt;a href="https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/prometheusreceiver"&gt;prometheus-receiver&lt;/a&gt; can be used for scraping. The trace pipeline applies the OpenCensus receiver as well as the &lt;a href="https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/jaegerreceiver"&gt;jaeger-receiver&lt;/a&gt; for opening a Jaeger-compatible endpoint on the Collector.&lt;/p&gt;

&lt;p&gt;The trace pipeline is applying some batching logic through the &lt;a href="https://github.com/open-telemetry/opentelemetry-collector/tree/main/processor/batchprocessor"&gt;batch-processor&lt;/a&gt;, where the Collector will collect many individual signals in batches before they are dispatched to the exporter so we don’t hammer the signal receivers too much.&lt;/p&gt;

&lt;p&gt;After processing, exporters are applied – OpenCensus and Prometheus exporters forward metrics to compatible remote endpoints. Trace data is forwarded to a remote ZipKin endpoint.&lt;/p&gt;

&lt;p&gt;On a higher level, the components involved with this handling signals are the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;receivers:&lt;/strong&gt; receive data from other sources. We can consider them as inputs to the collectors. The only core receiver is the OTLP receiver that can ingest the OpenTelemetry Line Protocol (OTLP).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;extensions:&lt;/strong&gt;  can add additional functionality to the collector executable such as health checks&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;processors:&lt;/strong&gt; work on telemetry data pipelines, for example controlling batching, attribute additions, conversions necessary, etc&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;exporters:&lt;/strong&gt; take the data and make it available to outside consumers, for example an observability platform that can make the data useful by aggregating it and providing insights&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It is important to note that the core OpenTelemetry Collector only ships OTLP receivers and exporters, so the project can concentrate on being compliant with OTLP and delegate other protocols to the community.&lt;/p&gt;

&lt;p&gt;The core collector distribution is then bundling the &lt;a href="https://github.com/open-telemetry/opentelemetry-collector-contrib"&gt;opentelemetry-collector-contrib&lt;/a&gt; plugins, which are extending the vanilla collector with more vendor-specific exporters, processors, and other components.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why is the Collector important for Instana?
&lt;/h3&gt;

&lt;p&gt;OpenTelemetry is an amazing project, and it’s great to see the community of observability vendors and developers coming together and further evolving the data collection process that we all tackle individually.&lt;/p&gt;

&lt;p&gt;Instana’s high-granularity data model is currently bound to our Instana Host Agent and the in-process collectors we provide. We opened our Agent for ingress of locally produced OTLP data for tracing a while ago, and we are currently analyzing where we can provide the most value for our customers going forward as OpenTelemetry continues to gain traction.&lt;/p&gt;

&lt;p&gt;As the OpenTelemetry Collector is the central piece or collection, it is a great target for us to make a dent in the universe. It provides good mechanisms to enrich the telemetry signals with the data points we need and for transforming it to our own data model. The challenge, from a vendor perspective, is to provide the right balance between open ingress and precise output from the collector.&lt;/p&gt;

&lt;p&gt;Stay tuned as we continue to work with and support the OpenTelemetry project. For more on Instana’s support of OpenTelemetry, here’s some recreational reading material:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.instana.com/docs/ecosystem/opentelemetry/#main"&gt;OpenTelemetry documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.instana.com/blog/instana-autotrace-fully-embracing-opentelemetry/"&gt;Instana AutoTrace: Fully Embracing OpenTelemetry&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.instana.com/blog/the-rise-of-distributed-tracing-with-opentelemetry/"&gt;The Rise of Distributed Tracing with OpenTelemetry&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.instana.com/blog/latest-instana-openshift-operator-automatically-collects-opentelemetry-on-red-hat-openshift/"&gt;Latest Instana OpenShift Operator Automatically Collects OpenTelemetry on Red Hat OpenShift&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The post &lt;a href="https://www.instana.com/blog/dissecting-the-opentelemetry-collector-overview/"&gt;Dissecting the OpenTelemetry Collector: An Overview&lt;/a&gt; appeared first on &lt;a href="https://www.instana.com"&gt;Instana&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>observability</category>
      <category>monitoring</category>
      <category>opentelemetry</category>
    </item>
    <item>
      <title>DevOps Horror Stories to Slow Development and Freeze Operations</title>
      <dc:creator>Instana</dc:creator>
      <pubDate>Tue, 26 Oct 2021 21:06:04 +0000</pubDate>
      <link>https://dev.to/instanahq/devops-horror-stories-to-slow-development-and-freeze-operations-29gd</link>
      <guid>https://dev.to/instanahq/devops-horror-stories-to-slow-development-and-freeze-operations-29gd</guid>
      <description>&lt;p&gt;Halloween is a scary time to be in abandoned buildings, cemeteries, and dark forests… and DevOps teams. Developers, operations engineers, and SREs told us some DevOps horror stories that have haunted them to this day. Light some candles, gather your courage, and read the spine-chilling tales of terrifying errors, bone-chilling data loss, and nightmarish lost weekends.&lt;/p&gt;

&lt;h2&gt;
  
  
  Relax, It’s Just the Complete Loss of All Data
&lt;/h2&gt;

&lt;p&gt;During a routine attempt to gather information from our production MySQL DB, the script I was running did not have a relevant section commented out, as the script was a dual-purpose script: to gather information about the schemas in one section, and another section dedicated to database migration, with the engineer commenting out the section not needed at the time of operation.&lt;/p&gt;

&lt;p&gt;I neglected to comment out the migration portion of the script during my attempt to do discovery via the script, resulting in the immediate dropping of the entire production database.  We had a read-replica in another AZ in AW; but by the time I recognized the error, the drop of tables had already replicated, resulting in the complete loss of all data. Compounded on this, our CTO was out of town, meaning this had to be reported directly to our CEO, who promptly spent the next hour watching over my shoulder as I spun up a new RDS database and restored data from the most recent snapshot – approximately 30 minutes ago. I was still a newly promoted DevOps engineer, having just been moved up from the desktop support team, and made this colossal error.&lt;/p&gt;

&lt;p&gt;I still consider it to be the most stressful/terrifying event in my DevOps career.&lt;/p&gt;

&lt;p&gt;Petrified,&lt;/p&gt;

&lt;p&gt;Inopportune Deployment Engineer&lt;/p&gt;

&lt;h2&gt;
  
  
  These Credentials Don’t Work in Swedish
&lt;/h2&gt;

&lt;p&gt;I was responsible to set up the flow for a tourist company. The flow had one queue which was protected by simple username/password (long time ago, it was normal). The credentials were shared with me in an email. The issue was: the guy who shared them was Swedish, and they were in a format: användare lösenord.&lt;/p&gt;

&lt;p&gt;I didn’t speak Swedish at that time and just added the credentials. When we launched it on prod we started losing all the messages. After investigation we found out that actual user and password where hidden in whitespaces and became visible on select… It was the way to “secure” them in an email.&lt;/p&gt;

&lt;p&gt;And those word just mean “user” and “password” in Swedish.&lt;/p&gt;

&lt;p&gt;Terrified,&lt;/p&gt;

&lt;p&gt;Senior Developer&lt;/p&gt;

&lt;h2&gt;
  
  
  A Not-So-Hot Fix in Production
&lt;/h2&gt;

&lt;p&gt;In the heat of applying a hot fix in production. I accidentally deleted all k8s deployments that were in the non-default namespace with just one command. With collaborated efforts from development, we recovered quickly. But just a simple kubectl command can wipe almost your whole cluster without any request for confirmation.&lt;/p&gt;

&lt;p&gt;Paranoid,&lt;/p&gt;

&lt;p&gt;Senior Site Reliability Engineer&lt;/p&gt;

&lt;h2&gt;
  
  
  A Weekend Ruined By Floppy Disks
&lt;/h2&gt;

&lt;p&gt;A long time ago, when it was still a fairly common and feasible practice to put an entire app’s database on a few floppy disks, I made the mistake of fiddling with the .DBF files without first making a backup. Needless to say, I screwed something up and had to spend the rest of my weekend fixing the files using a C program I cobbled together to gather up all the old data into new tables.&lt;/p&gt;

&lt;p&gt;Luckily, I had enough information from reference materials on hand to be able to figure out the file format and where all the data was on the disks (this pre-Internet times). Still wasn’t fun and my supervisor rightfully chewed me out for not taking proper precautions.​&lt;/p&gt;

&lt;p&gt;Freaked out,&lt;/p&gt;

&lt;p&gt;Consultant&lt;/p&gt;

&lt;h2&gt;
  
  
  A Case of Bad Timing
&lt;/h2&gt;

&lt;p&gt;I once deployed an application ahead of time and scheduled a cron to restart the webserver at 8am, but instead it was every 8 minutes. #DevOoops!&lt;/p&gt;

&lt;p&gt;With curdled blood,&lt;/p&gt;

&lt;p&gt;Developer&lt;/p&gt;

&lt;h2&gt;
  
  
  The Road to Prod Is Paved with Good Intentions
&lt;/h2&gt;

&lt;p&gt;One of my developers decided to “improve” a production deployment script. He started making changes directly in the production environment, not in development, against my advice; but management didn’t seem concerned. At 5pm on the dot he left work every day. This day he left as usual. The script changes were unfinished and untested, but live in production. All production deployments failed overnight, costing the company many tens of thousands of dollars.&lt;/p&gt;

&lt;p&gt;I came into the office in the morning, was confronted by livid Operations staff (and their manager), and quickly reverted his code. This helped convince Development management to see that code changes needed to be done in dev first. The developer was “convinced to resign from the company,” and he did. Many years later I still run into developers who want to take shortcuts to production, and I tell them this story.&lt;/p&gt;

&lt;p&gt;Alarmed,&lt;/p&gt;

&lt;p&gt;Architect&lt;/p&gt;

&lt;h2&gt;
  
  
  Wedding Day Fiasco
&lt;/h2&gt;

&lt;p&gt;Years ago, one of our developers added a new feature to our web application on Friday just before our release. The application was delivered to the customer that evening and deployed overnight. On Saturday morning, application users began to report that one of the main functions of the application was not responsive – essentially preventing them from doing their job. The incident was escalated, and I was called in early Saturday afternoon to help troubleshoot the problem.&lt;/p&gt;

&lt;p&gt;It took a couple of hours to find the problem because we didn’t really have great application telemetry at the time or a great way to debug the deployed application. There was an SQL query that was inadvertently pulling hundreds of thousands of records from the customer database, triggered by every application user. The problem wasn’t seen in development because the developers were using a tiny dataset in comparison. Patching the SQL statement with a LIMIT clause restored the application to its normal speedy self.&lt;/p&gt;

&lt;p&gt;Oh, and by the way, when I was called in to troubleshoot the problem, I was called away from a friend’s wedding.&lt;/p&gt;

&lt;p&gt;Shrieking,&lt;/p&gt;

&lt;p&gt;Senior Principal Software Developer&lt;/p&gt;

&lt;p&gt;Apologies in advance for your sleepless night tonight. But if you're like us, and can't keep your eyes away, we have some more unfortunate tales where these came from, like the &lt;a href="https://www.instana.com/blog/how-a-slack-zero-width-space-character-broke-a-kubernetes-deployment/"&gt;“Zero Width Space”&lt;/a&gt;character that broke a k8s deployment, and the fact that &lt;a href="https://www.instana.com/blog/life-of-an-sre-at-instana-things-break-all-the-time-in-distributed-systems-part-2-cassandra/"&gt;things break all the time when you’re an SRE&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>devops</category>
      <category>sre</category>
    </item>
    <item>
      <title>Improve Query Performance with Clickhouse Data Skipping Index</title>
      <dc:creator>Instana</dc:creator>
      <pubDate>Thu, 07 Oct 2021 06:59:46 +0000</pubDate>
      <link>https://dev.to/instanahq/improve-query-performance-with-clickhouse-data-skipping-index-2agm</link>
      <guid>https://dev.to/instanahq/improve-query-performance-with-clickhouse-data-skipping-index-2agm</guid>
      <description>&lt;h2&gt;
  
  
  Operating a Large Clickhouse Table
&lt;/h2&gt;

&lt;p&gt;At Instana, we process and store every single call collected by Instana tracers with no sampling over the last 7 days. Instana’s &lt;a href="https://www.instana.com/docs/unbounded_analytics/"&gt;Unbounded Analytics&lt;/a&gt; feature allows filtering and grouping calls by arbitrary tags to gain insights into the unsampled, high-cardinality tracing data. We are able to provide 100% accurate metrics such as call count, latency percentiles or error rate, and display the detail of every single call.&lt;/p&gt;

&lt;p&gt;For many of our large customers, over 1 billion calls are stored every day. This number reaches 18 billion for our largest customer now and it keeps growing. Calls are stored in a single table in &lt;a href="https://www.instana.com/supported-technologies/clickhouse-monitoring/"&gt;Clickhouse&lt;/a&gt; and each call tag is stored in a column. Filtering this large number of calls, aggregating the metrics and returning the result within a reasonable time has always been a challenge.&lt;/p&gt;

&lt;p&gt;Previously we have created materialized views to pre-aggregate calls by some frequently used tags such as application/service/endpoint names or HTTP status code. However, we cannot include all tags into the view, especially those with high cardinalities because it would significantly increase the number of rows in the materialized view and therefore slow down the queries.&lt;/p&gt;

&lt;p&gt;Previously we have created materialized views to pre-aggregate calls by some frequently used tags such as &lt;a href="https://www.instana.com/docs/application_monitoring/"&gt;application/service/endpoint&lt;/a&gt; names or HTTP status code. However, we cannot include all tags into the view, especially those with high cardinalities because it would significantly increase the number of rows in the materialized view and therefore slow down the queries.&lt;/p&gt;

&lt;p&gt;Filtering on high cardinality tags not included in the materialized view still requires a full scan of the calls table within the selected time frame which could take over a minute.&lt;/p&gt;

&lt;h2&gt;
  
  
  Optimize filtering on http url
&lt;/h2&gt;

&lt;p&gt;Filtering on HTTP URL is a very frequent use case. The cardinality of HTTP URLs can be very high since we could have randomly generated URL path segments such as &lt;code&gt;/api/product/{id}.&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Choose the data skipping index
&lt;/h2&gt;

&lt;p&gt;Clickhouse &lt;a href="https://clickhouse.tech/docs/en/engines/table-engines/mergetree-family/mergetree/"&gt;MergeTree&lt;/a&gt; table engine provides a few &lt;a href="https://clickhouse.tech/docs/en/engines/table-engines/mergetree-family/mergetree/#table_engine-mergetree-data_skipping-indexes"&gt;data skipping indexes&lt;/a&gt; which makes queries faster by skipping granules of data (A granule is the smallest indivisible data set that ClickHouse reads when selecting data) and therefore reducing the amount of data to read from disk. &lt;code&gt;ngrambf_v1&lt;/code&gt; and &lt;code&gt;tokenbf_v1&lt;/code&gt; are two interesting indexes using &lt;a href="https://en.wikipedia.org/wiki/Bloom_filter"&gt;bloom filters&lt;/a&gt; for optimizing filtering of Strings. A bloom filter is a space-efficient probabilistic data structure allowing to test whether an element is a member of a set.&lt;/p&gt;

&lt;h3&gt;
  
  
  ngrambf_v1
&lt;/h3&gt;

&lt;p&gt;A string is split into substrings of n characters. For example, &lt;code&gt;n=3&lt;/code&gt; ngram (trigram) of &lt;code&gt;'hello world'&lt;/code&gt; is &lt;code&gt;['hel', 'ell', 'llo', lo ', 'o w' ...]&lt;/code&gt;. The ngrams of each column value will be stored in the bloom filter.&lt;/p&gt;

&lt;p&gt;When searching with a filter &lt;code&gt;column LIKE 'hello'&lt;/code&gt; the string in the filter will also be split into ngrams &lt;code&gt;['hel', 'ell', 'llo']&lt;/code&gt; and a lookup is done for each value in the bloom filter. If all the ngram values are present in the bloom filter we can consider that the searched string is present in the bloom filter.&lt;/p&gt;

&lt;p&gt;Functions with a constant argument that is less than ngram size can’t be used by &lt;code&gt;ngrambf_v1&lt;/code&gt; for query optimization. For example, searching for &lt;code&gt;‘hi’&lt;/code&gt; will not trigger a &lt;code&gt;ngrambf_v1&lt;/code&gt; index with &lt;code&gt;n=3&lt;/code&gt;. Small n allows to support more searched strings. But small n leads to more ngram values which means more hashing and eventually more false positives. False positive means reading data which do not contain any rows that match the searched string.&lt;/p&gt;

&lt;p&gt;Since false positive matches are possible in bloom filters, the index cannot be used when filtering with negative operators such as &lt;code&gt;column_name != 'value’&lt;/code&gt; or &lt;code&gt;column_name NOT LIKE ‘%hello%’&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  tokenbf_v1
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;tokenbf_v1&lt;/code&gt; splits the string into tokens separated by non-alphanumeric characters and stores tokens in the bloom filter. &lt;code&gt;‘Hello world’&lt;/code&gt; is splitted into 2 tokens &lt;code&gt;[‘hello’, ‘world’]&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;In addition to the limitation of not supporting negative operators, the searched string must contain at least a complete token. In the above example, searching for &lt;code&gt;hel&lt;/code&gt; will not trigger the index.&lt;/p&gt;

&lt;p&gt;Once we understand how each index behaves, &lt;code&gt;tokenbf_v1&lt;/code&gt; turns out to be a better fit for indexing HTTP URLs, because HTTP URLs are typically path segments separated by /. Each path segment will be stored as a token. Splitting the URls into ngrams would lead to much more sub-strings to store. The index size needs to be larger and lookup will be less efficient.&lt;/p&gt;

&lt;h2&gt;
  
  
  Configure the index
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;Tokenbf_v1&lt;/code&gt; index needs to be configured with a few parameters. First the index granularity specifies how many granules of data will be indexed together in a single block using a bloom filter. The entire block will be skipped or not depending on whether the searched value appears in the block. The number of rows in each granule is defined by the &lt;code&gt;index_granularity&lt;/code&gt; setting of the table. Increasing the granularity would make the index lookup faster, but more data might need to be read because fewer blocks will be skipped.&lt;/p&gt;

&lt;p&gt;We also need to estimate the number of tokens in each granule of data. In our case, the number of tokens corresponds to the number of distinct path segments. Then we can use a &lt;a href="https://hur.st/bloomfilter"&gt;bloom filter calculator&lt;/a&gt;. After fixing the N which is the number of token values, p which is the false positive rate and k which is the number of hash functions, it would give us the size of the bloom filter.&lt;/p&gt;

&lt;p&gt;The index can be created on a column or on an expression if we apply some functions to the column in the query. In our case searching for HTTP URLs is not case sensitive so we have created the &lt;code&gt;index on lowerUTF8(http_url)&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The final index creation statement looks something like this:&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;**ADD INDEX** IF **NOT EXISTS** tokenbf_http_url_index lowerUTF8(http_url) TYPE tokenbf_v1(10240, 3, 0) GRANULARITY 4&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Result
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Index size&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The size of the &lt;code&gt;tokenbf_v1&lt;/code&gt; index before compression can be calculated as following:&lt;/p&gt;

&lt;p&gt;Bloom_filter_size x number_of_blocks&lt;/p&gt;

&lt;p&gt;Number_of_blocks = number_of_rows / (table_index_granularity * tokenbf_index_granularity)&lt;/p&gt;

&lt;p&gt;You can check the size of the index file in the directory of the partition in the file system. The file is named as &lt;code&gt;skp_idx_{index_name}.idx&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;In our case, the size of the index on the HTTP URL column is only 0.1% of the disk size of all data in that partition.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Query speed&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The query speed depends on two factors: the index lookup and how many blocks can be skipped thanks to the index.&lt;/p&gt;

&lt;p&gt;According to our testing, the index lookup time is not negligible. It can take up to a few seconds on our dataset if the index granularity is set to 1 for example. We decided to set the index granularity to 4 to get the index lookup time down to within a second on our dataset.&lt;/p&gt;

&lt;p&gt;The number of blocks that can be skipped depends on how frequently the searched data occurs and how it’s distributed in the table. Our calls table is sorted by timestamp, so if the searched call occurs very regularly in almost every block, then we will barely see any performance improvement because no data is skipped. On the contrary, if the call matching the query only appears in a few blocks, a very small amount of data needs to be read which makes the query much faster.&lt;/p&gt;

&lt;h2&gt;
  
  
  Optimize filtering on HTTP header
&lt;/h2&gt;

&lt;p&gt;Now that we’ve looked at how to use Clickhouse data skipping index to optimize query filtering on a simple String tag with high cardinality, let’s examine how to optimize filtering on HTTP header, which is a more advanced tag consisting of both a key and a value.&lt;/p&gt;

&lt;p&gt;In Clickhouse, key value pair tags are stored in 2 &lt;code&gt;Array(LowCardinality(String))&lt;/code&gt; columns. For example, given a call with &lt;code&gt;Accept=application/json&lt;/code&gt; and &lt;code&gt;User-Agent=Chrome&lt;/code&gt; headers, we store &lt;code&gt;[Accept, User-Agent]&lt;/code&gt; in &lt;code&gt;http_headers.key column&lt;/code&gt; and &lt;code&gt;[application/json, Chrome]&lt;/code&gt; in &lt;code&gt;http_headers.value column&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;When filtering by a key value pair tag, the key must be specified and we support filtering the value with different operators such as &lt;code&gt;EQUALS, CONTAINS or STARTS_WITH&lt;/code&gt;. e.g. &lt;code&gt;call.http.headers.Accept EQUALS application/json&lt;/code&gt;. This filter is translated into Clickhouse expression&lt;/p&gt;

&lt;p&gt;arrayExists((k, v) -&amp;gt; lowerUTF8(k) = ‘accept’ AND lowerUTF8(v) = ‘application’, http_headers.key, http_headers.value)&lt;/p&gt;

&lt;h2&gt;
  
  
  Choose and configure the index
&lt;/h2&gt;

&lt;p&gt;We can add indexes to both the key and the value column. &lt;code&gt;tokenbf_v1&lt;/code&gt; and &lt;code&gt;ngrambf_v1&lt;/code&gt; indexes do not support Array columns. &lt;code&gt;bloom_filter&lt;/code&gt; index looks to be the best candidate since it supports array functions such as &lt;code&gt;IN&lt;/code&gt; or &lt;code&gt;has&lt;/code&gt;. The limitation of &lt;code&gt;bloom_filter&lt;/code&gt; index is that it only supports filtering values using &lt;code&gt;EQUALS&lt;/code&gt; operator which matches a complete String.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;bloom_filter&lt;/code&gt; index requires less configurations. The only parameter &lt;code&gt;false_positive&lt;/code&gt; is optional which defaults to 0.025. Reducing the false positive rate will increase the bloom filter size.&lt;/p&gt;

&lt;p&gt;Since the filtering on key value pair tag is also case insensitive, index is created on the lower cased value expressions:&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;```ADD INDEX bloom_filter_http_headers_key_index arrayMap(v -&amp;gt; lowerUTF8(v), http_headers.key) TYPE bloom_filter GRANULARITY 4,&lt;/p&gt;

&lt;p&gt;ADD INDEX bloom_filter_http_headers_value_index arrayMap(v -&amp;gt; lowerUTF8(v), http_headers.value) TYPE bloom_filter GRANULARITY 4,```&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;So that the indexes will be triggered when filtering using expression &lt;code&gt;has(arrayMap((v) -&amp;gt; lowerUTF8(v),http_headers.key),'accept')&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;When filtering on both key and value such as &lt;code&gt;call.http.header.accept=application/json&lt;/code&gt;, it would be more efficient to trigger the index on the value column because it has higher cardinality. The index on the key column can be used when filtering only on the key (e.g. &lt;code&gt;call.http.header.accept is present&lt;/code&gt;).&lt;/p&gt;

&lt;h2&gt;
  
  
  Our Pragmatic Clickhouse Rollout
&lt;/h2&gt;

&lt;p&gt;Adding an index can be easily done with the &lt;code&gt;ALTER TABLE ADD INDEX&lt;/code&gt; statement. After the index is added, only new incoming data will get indexed. Clickhouse provides &lt;code&gt;ALTER TABLE [db.]table MATERIALIZE INDEX name IN PARTITION partition_name&lt;/code&gt; statement to rebuild the index in an existing partition. But this would generate additional load on the cluster which may degrade the performance of writing and querying data. We decided not to do it and just wait 7 days until all our calls data gets indexed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion – Try (TRY) Index Skipping Yourself
&lt;/h2&gt;

&lt;p&gt;We have spent quite some time testing the best configuration for the data skipping indexes. But once we understand how they work and which one is more adapted to our data and use case, we can easily apply it to many other columns.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;bloom_filter index&lt;/code&gt; and its 2 variants &lt;code&gt;ngrambf_v1&lt;/code&gt; and &lt;code&gt;tokenbf_v1&lt;/code&gt; all have some limitations. They do not support filtering with all operators. The performance improvement depends on how frequently the searched data occurred and how it is spread across the whole dataset so it’s not guaranteed for all queries.&lt;/p&gt;

&lt;p&gt;Ultimately, I recommend you try the data skipping index yourself to improve the performance of your Clickhouse queries, especially since it’s relatively cheap to put in place. It only takes a bit more disk space depending on the configuration and it could speed up the query by 4-5 times depending on the amount of data that can be skipped. BUT TEST IT to make sure that it works well for your own data. If it works for you – great! If not, pull it back or adjust the configuration. We also hope Clickhouse continuously improves these indexes and provides means to get more insights into their efficiency, for example by adding index lookup time and the number granules dropped in the query log.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How We Handled Bugs in CockroachDB and JDBI</title>
      <dc:creator>Instana</dc:creator>
      <pubDate>Thu, 07 Oct 2021 06:32:33 +0000</pubDate>
      <link>https://dev.to/instanahq/how-we-handled-bugs-in-cockroachdb-and-jdbi-3e22</link>
      <guid>https://dev.to/instanahq/how-we-handled-bugs-in-cockroachdb-and-jdbi-3e22</guid>
      <description>&lt;p&gt;At Instana we appreciate, contribute, and extensively make use of open source projects like Kafka, ClickHouse, Elasticsearch, CockroachDB, and many others. In this post, I would like to share an outstanding team effort that led us to quickly detect, investigate, and remediate an issue that ended up with fixes in two different open source projects: CockroachDB and JDBI.&lt;/p&gt;

&lt;p&gt;Not surprisingly, we love metrics and logs at Instana. We also take several practices such as Automated Testing, Continuous Integration, and Continuous Delivery very seriously. As a result, we receive frequent feedback from every change in our code and infrastructure. When the issue I am writing of first happened in our test environments, the first signal we had was failing end-to-end tests due to broken login at Instana.&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Since the team I work at Instana is responsible for authentication, authorization, and other security-related topics, we kicked off an investigation and quickly found the following error in our logs when trying to update a row in a table in CockroachDB:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;org.postgresql.util.PSQLException: ERROR: integer out of range for type int4&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Our initial thought was that we were updating a field with a number greater than the column’s capacity in the database, therefore, there were two possibilities:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;The number sent from the application to CockroachDB is greater than the column capacity in the database due to a bug introduced in our code&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The number sent from the application to CockroachDB is fine but we mistakenly set a column type in the database which is not big enough in certain scenarios;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;It turns out that both assumptions were wrong. The number was correct and the column type in CockroachDB was INT8 (64 bits), big enough to store it. It was then that we realized that fixing the issue would not be so straightforward.&lt;/p&gt;

&lt;h2&gt;
  
  
  Investigation
&lt;/h2&gt;

&lt;p&gt;We noticed that the CockroachDB version was bumped to 21.1.5 the day before in our test environments and the issue did not happen in production where the old CockroachDB version was still running. That was a good starting point for our investigation, and by checking the logs, it was clear that the issue started after updating CockroachDB:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Wd0nrvHD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8bxmw6b8khq0tdzzi7j2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Wd0nrvHD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8bxmw6b8khq0tdzzi7j2.png" alt="word-image-410"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The logs also showed a pattern where the exception was being raised every 10 minutes, and that helped us understand what triggered the issue so we could eventually write a test scenario to reproduce it.&lt;/p&gt;

&lt;p&gt;After some serious debugging, we confirmed that the issue was indeed in CockroachDB. It happened because the cached query plan for a prepared statement at some point received the wrong type of a column and kept using it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reproducing the issue
&lt;/h2&gt;

&lt;p&gt;To put it simply, consider a table in CockroachDB which contains a column C of type INT8 (64 bits). The scenario below would result in the error:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Set type INT8 and insert a number to C ✅&lt;/li&gt;
&lt;li&gt;Set type INT4 and update C with another number within the 
INT4 range (from -2147483648 to +2147483647) ✅&lt;/li&gt;
&lt;li&gt;Set type INT8 and update C with a number greater than INT4 capacity (&amp;gt; +2147483647) ✖ (fail, but should work since C is of type INT8)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Since we extensively use Testcontainers, coming up with an integration test reproducing the described scenario against CockroachDB 21.1.5 was not a problem:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int rowId = 1;
long numberGreaterThanMaxInt4Capacity = (long)Integer.MAX_VALUE + 1;

try(CockroachContainer cockroachContainer = new CockroachContainer("dbName","cockroachdb/cockroach:v21.1.5")){
cockroachContainer.start();
cockroachContainer.executeSql("CREATE TABLE dbName.someNumber (id INT8, theNumber INT8);");

Connection con = getConnection(cockroachContainer.getUsername(), cockroachContainer.getPassword(), cockroachContainer.getJdbcUrl());

try (PreparedStatement firstInsert = con.prepareStatement("INSERT INTO dbName.someNumber (id, theNumber) VALUES(?, ?);")) {
firstInsert.setLong(1, rowId);
firstInsert.setLong(2, 100L);
firstInsert.execute();
}

try (PreparedStatement firstUpdate = con.prepareStatement("UPDATE dbName.someNumber SET theNumber = ? where id = ?;")) {
int myNumber = 1234;
firstUpdate.setInt(1, myNumber);
firstUpdate.setLong(2, rowId);
firstUpdate.execute();
}

try (PreparedStatement secondUpdate = con.prepareStatement("UPDATE dbName.someNumber SET theNumber = ? where id = ?;")) {
secondUpdate.setLong(1, numberGreaterThanMaxInt4Capacity);
secondUpdate.setLong(2, rowId);
secondUpdate.execute(); // throws org.postgresql.util.PSQLException: ERROR: integer out of range for type int4
}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Not surprisingly, if myNumber changed from int to short and firstUpdate.setInt(1, myNumber) to firstUpdate.setShort(1, myNumber), the second update would raise the same exception, but now complaining about INT2 (16 bits), meaning that CockroachDB reused the query plan from the first update:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;org.postgresql.util.PSQLException: ERROR: integer out of range for type int2&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;On the other hand, if myNumber changed from int to long and firstUpdate.setInt(1, myNumber) to firstUpdate.setLong(1, myNumber), this issue would never happen in CockroachDB (although the bug would still exist).&lt;/p&gt;

&lt;h2&gt;
  
  
  Fixing the issue
&lt;/h2&gt;

&lt;p&gt;With that information in hand, we reported an issue to the CockroachDB GitHub repository and the CockroachDB team promptly took it over and came up with a fix (big thanks to the CockroachDB team!). The fix is available on CockroachDB version 21.1.7.&lt;/p&gt;

&lt;p&gt;However, a question was still open: this issue would never have happened if a long type was being sent in the SQL updates. So, would that mean that the application is mistakenly sending to CockroachDB updates with type int (32 bits) where long (64 bits) is expected?&lt;/p&gt;

&lt;p&gt;To confirm that this was the case, we tracked down the network packets being sent over the wire from the application to CockroachDB and concluded that an integer type was indeed being sent where a long type was expected. Diving deep into the Postgres JDBC driver and JDBI code, we found out a bug in JDBI where long and Long types were mistakenly being mapped to int and Integer respectively, so we created a pull request in the JDBI GitHub repository fixing it. The JDBI team quickly reviewed and accepted it (big thanks to the JDBI team too!). The fix is now available on JDBI version 3.21.0.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;By detecting the issue in its early stages in our test environments, we were able to quickly fix it and prevent it from affecting our customers. The way our entire investigation was conducted highlighted the outstanding teamwork and cooperation within Instana, and once again showed that collaboration is key to achieve success – both within individual companies and within the open source community. A big thanks to everyone involved, including CockroachDB and JDBI teams!&lt;/p&gt;

&lt;p&gt;If you feel excited about how we solve problems and also love metrics and logs, we are hiring!&lt;/p&gt;

&lt;p&gt;My twitter: &lt;a href="https://twitter.com/jorgeacetozi"&gt;https://twitter.com/jorgeacetozi&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;My LinkedIn: (&lt;a href="https://www.linkedin.com/in/jorgeacetozi/"&gt;https://www.linkedin.com/in/jorgeacetozi/&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;Experience Instana for yourself in our guided demo sandbox environment: &lt;a href="https://www.instana.com/apm-observability-sandbox/"&gt;https://www.instana.com/apm-observability-sandbox/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>monitoring</category>
    </item>
    <item>
      <title>From Shipping to Scaling: How Goji Investments Masters Developer Experience Through Observability</title>
      <dc:creator>Instana</dc:creator>
      <pubDate>Wed, 09 Sep 2020 22:26:02 +0000</pubDate>
      <link>https://dev.to/instanahq/from-shipping-to-scaling-how-goji-investments-masters-developer-experience-through-observability-36l7</link>
      <guid>https://dev.to/instanahq/from-shipping-to-scaling-how-goji-investments-masters-developer-experience-through-observability-36l7</guid>
      <description>&lt;p&gt;This guest blog post was written by Dean Record, Engineer at Goji Investments.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.goji.investments/"&gt;Goji Investments&lt;/a&gt; launched in 2016. Our platform democratises access to real estate, business lending, renewables, and other alternative investments. It allows asset managers and investment firms to offer financial vehicles to global private investors seeking stability and better yields by looking beyond traditional equity markets. Our scalable modular platform is available as a white-label solution and also integrates into existing platforms using our API.&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating an Excellent Developer Experience
&lt;/h3&gt;

&lt;p&gt;In the four years since we launched, Goji Investments’ developers have worked hard to help us expand our product offering and bring in new customers. In return, we’ve done everything to keep them happy, and that means supplying them with the right tools to help them transition from building our platform to scaling it.&lt;/p&gt;

&lt;p&gt;Our DevOps pipeline is a complex machine with many moving parts. We are continuously refining it and adding or subtracting tools based on developer feedback and our changing deliverables.&lt;/p&gt;

&lt;p&gt;We realised early on that the best way to ensure a superb end-user experience is to provide an outstanding developer experience. We help our people stay focused on performing at the highest level by automating repetitive low-level tasks, thus freeing them to work on features that add value to the company. To this end, we have fine-tuned our technology stack to give our eight-member developer team everything it needs to succeed.&lt;/p&gt;

&lt;h3&gt;
  
  
  Automating Deployments Wasn’t Enough
&lt;/h3&gt;

&lt;p&gt;Our applications are written in a modern Java stack, and we are using Dropwizard as our framework. Our developers typically write code and then push it to GitHub for review. If it’s approved, the new code is merged into master, which automatically triggers a build pipeline using ThoughtWorks GoCD. We then run automated unit, integration, and acceptance tests and our developers also have the option to run manual tests to encourage exploratory testing.&lt;/p&gt;

&lt;p&gt;From there, we can promote new code into our pre-production environment, which mirrors our current production setup. Anything not covered in prior testing that makes its way into our production environment can be easily rolled back using the blue-green deployment functionality of HashiCorp Nomad, our container orchestration platform. We’re a small team, and our codebase is relatively compact, so we don’t need the complexity of Kubernetes GKE or EKS to deploy and manage our applications.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Combing through logs for application monitoring is a waste of valuable developer resources.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;One of the benefits of our technology stack is extensive automation. Although our deployment workflow was seamless, things were not as rosy when it came to monitoring. We were using New Relic to monitor our infrastructure. When an application was eating up too many CPU cycles, or an EC2 instance crashed and rebooted, it would trigger an alert. But if we wanted to troubleshoot slow response times, latency errors, and bottlenecks at the service level, we had to comb through logs manually, and that was a waste of time and human resources.&lt;/p&gt;

&lt;h3&gt;
  
  
  End-to-End Traceability
&lt;/h3&gt;

&lt;p&gt;The last thing you want to do with your day is analyse log files. You want to build the next killer feature, but if you have to dive into the weeds, you want to do it as quickly and as painlessly as possible. That’s where observability and application performance monitoring (APM) comes in. APM incorporates infrastructure monitoring, but also provides service-level metrics, including information about database calls and end-user activity. It allows us to locate bottlenecks and other performance issues without having to divert our developers from their primary duties.&lt;/p&gt;

&lt;p&gt;I’d used APM software at my previous position, and when it came to time to adopt a platform at Goji Investments, I went with what I knew. Experience had shown me that Instana is a zero-touch solution that does everything we need straight out of the box. When you run 20 different microservices that cover everything from taxes, payments, and customer notification—and when you’re scaling to add even more—you need to optimise every element of your DevOps pipeline. Instana was the final piece in our puzzle, and it allowed us to automate one of the most cumbersome parts of the development cycle.&lt;/p&gt;

&lt;p&gt;Instana gives us full traceability from our front-end to our back-end. We can track user actions on our website and trace subsequent calls across multiple services. It automates alerts and can send an alarm to our developers’ Slack channel when it encounters an issue with CPU, container memory usage, or the JVM heap size.&lt;/p&gt;

&lt;p&gt;Instana also integrates with &lt;a href="https://www.instana.com/docs/ecosystem/humio/"&gt;Humio&lt;/a&gt;, a real-time logging solution we recently adopted. When we spot an issue in Humio, we can jump into &lt;a href="//www.instana.com"&gt;Instana&lt;/a&gt; and go directly to the Docker container or host that generated the error. We can also view AWS metrics in Instana and no longer have to pull information from the AWS console. Consolidating all of these functions saves time and simplifies troubleshooting.&lt;/p&gt;

&lt;h3&gt;
  
  
  Finding Our Bottlenecks
&lt;/h3&gt;

&lt;p&gt;When we’re testing a new build or functionality, we can use Instana to view dozens of metrics in real-time, and that is a complete game-changer. Recently, we developed a feature that distributes dividends to investors and, prior to release we wanted to run performance tests to ensure it would scale to meet the demands of our growing client base. Initially, we ran a performance test of several hundred thousands of payments, and it took over 20 hours.&lt;/p&gt;

&lt;p&gt;During the performance tests as we iterated on our code, we found ourselves getting halfway through the process in five or ten minutes, hitting a bottleneck, and then taking 10 to 12 hours to complete the remainder.&lt;/p&gt;

&lt;p&gt;With Instana, we were able to see where the problem occurred. The instant Java profiling feature, &lt;a href="https://www.instana.com/blog/instana-announces-the-industrys-first-commercial-continuous-production-profiler/"&gt;AutoProfile™&lt;/a&gt;, showed us hotspots where the code was slow, and we determined that our database queries were the bottleneck. Once we knew where to look, we went back, fixed the code, and redeployed the application until we got it right.&lt;/p&gt;

&lt;p&gt;Instana allowed us to compare test runs. We could pull up a previous trial run and then compare its timeframe with the current version of the code. Using this iterative process, we streamlined the code, eliminated all the bottlenecks, and reduced the dividend processing time from 20 hours to less than 1 hour.&lt;/p&gt;

&lt;p&gt;If we didn’t have Instana, it would have easily taken us four to five times longer to get this process right.&lt;/p&gt;

&lt;h3&gt;
  
  
  Giving Our Developer the Tools to Shine
&lt;/h3&gt;

&lt;p&gt;If there’s one thing developers love, it’s rising to the occasion. The best way to keep them happy is to give them the tools to contribute to your bottom line. Treat them like internal customers by relieving their pain points. Automate repetitive tasks and eliminate tedious, time-consuming work like going through error logs. Reward them with creative work and give them every opportunity to shine.&lt;/p&gt;

&lt;p&gt;Instana is helping Goji Investments streamline the DevOps process by giving us visibility into the inner workings of our applications and microservices. We can trace calls and database queries, and we can monitor hosts, Docker containers, and Java Virtual Machines in real-time. All of this accelerates testing and deployment. We can do more and scale faster and attract the world’s most talented developers.&lt;/p&gt;

&lt;p&gt;After all, the smartest people want to work for companies that challenge them and also give them the tools to shine.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Dean Record is an Engineer at Goji Investments. You can connect with him on &lt;a href="https://www.linkedin.com/in/dean-record/"&gt;LinkedIn&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>devops</category>
      <category>observability</category>
      <category>monitoring</category>
      <category>logging</category>
    </item>
  </channel>
</rss>
