DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Because the DevOps movement has redefined engineering responsibilities, SREs now have to become stewards of observability strategy.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Related

  • How to Document Your AWS Cloud Infrastructure Using Multicloud-Diagrams Framework
  • Unleashing the Power of AWS: Revolutionizing Cloud Management Through Infrastructure as Code (IaC)
  • Top 9 Role-Based Cloud Certifications for Solution Architects in 2024
  • How To Understand and Choose Your First EC2 Instance on AWS

Trending

  • Navigating Change Management: A Guide for Engineers
  • Analyzing Techniques to Provision Access via IDAM Models During Emergency and Disaster Response
  • Introducing Graph Concepts in Java With Eclipse JNoSQL, Part 2: Understanding Neo4j
  • How to Merge HTML Documents in Java

Building Observable Applications With OpenTelemetry

In this article, learn how to start instrumenting your applications for observability and gain insights into how they operate.

By 
Mohammed Fazalullah Qudrath user avatar
Mohammed Fazalullah Qudrath
·
Jun. 27, 23 · Tutorial
Likes (3)
Comment
Save
Tweet
Share
2.9K Views

Join the DZone community and get the full member experience.

Join For Free

In the ever-evolving landscape of software development, complexity is a constant companion. As applications grow and evolve, they become increasingly intricate, making it more challenging to monitor, understand, and optimize their behavior. Developers are increasingly responsible for adding instrumentation into their code so the inner workings of their applications can be observed externally. That data then provides valuable insights to stakeholders across the business. 

This is where the concept of observability comes into play. Observability, in the context of software, refers to the ability to understand the internal state of a system by examining its outputs. It's like being able to understand what's happening inside a machine by just looking at the dials and gauges on its control panel. 

In this blog, we explain why instrumentation is important and demonstrate easy ways to make your projects observable.

Why Observability Is Important

The process of building business applications has evolved dramatically over the past 20 years. We’ve evolved from using large and complex monolithic applications located in data centers to designing solutions with smaller interconnected services and components. These methods may produce a similar result from a user’s point of view, but they are far more efficient and cost-effective for businesses, and easier to troubleshoot for IT teams.

As a developer, many years ago you might have had access to a dashboard that monitored how a business application was performing. If a server started flashing red on the dashboard, someone would be sent to inspect the hardware and find out if its hard drive was full, or if it had an issue with its power supply. But times have changed. Now software is extremely complex and relies on a diverse range of interconnected components that all need to work in order for the business to function. 

Today’s applications have so many components that it’s impossible to display all of them on a single dashboard. Organizations have also become more complex, with multiple teams such as DevOps and product management wanting to know how the application or solution works.

So how can developers continue to innovate in this environment? We’ve all seen how, as software becomes more complicated, and codebases interconnect, unexpected behavior—and bugs—emerge. This means that developers spend more time fixing bugs and less on developing new features and functionality that add competitive advantages to a product.

Using Metrics, Logs, and Traces

The way to solve these issues is to develop software that is instrumented, which makes it observable. This means that the software sends out signals that can help developers and product managers determine how it’s functioning. It’s important for developers to create strict and well-defined boundaries between different services and microservices so they can identify where problems are occurring, and stop them from propagating to connected resources.

Metrics provide numeric value measurements of events, such as the time taken for a transaction to complete, or how many customers viewed a video. Metrics make it possible to identify trends and understand performance over time.

Logs list the events that occur in the application. Developers need to build their applications to produce a log entry whenever there is a significant action, for example, when a transaction fails or a resource is accessed.

Traces provide the end-to-end lifecycle of a request as it passes through multiple parts of a system. If you can understand the full journey of a request, you can identify bottlenecks that might affect system performance.

Developers are responsible for instrumenting their code and making observability a characteristic of their applications. If an application is properly instrumented, it’s much easier to troubleshoot and manage. Observability can alert developers of problems before they happen, such as potential scaling issues if load increases. It can even answer non-technical questions, such as how long it takes for a customer to complete a transaction, or search for a specific product.

Overview of OpenTelemetry and AWS Distro for OpenTelemetry (ADOT)

OpenTelemetry is a Cloud Native Computing Foundation (CNCF) project that provides a single set of APIs, libraries, agents, and collector services to capture distributed traces and metrics from your application. It's a vendor-neutral tool that allows you to instrument your applications once and send the telemetry data to any backend of your choice.

OTel collector flow

AWS Distro for OpenTelemetry (ADOT) is a secure, production-ready, AWS-supported distribution of the OpenTelemetry project. With ADOT, you can easily instrument your applications running on AWS and send the data to the AWS observability services. ADOT includes enhanced support for AWS services and AWS SDKs, providing you with a seamless and efficient observability solution.

How To Instrument Code Using AWS

Instrumenting your code involves adding code to your application to generate observability data.

You can manually instrument your code by adding annotations or a few lines of code to create spans, which are units of work within a trace. For example, you might create a span for a complex calculation or a call to an external service. This allows you to isolate parts of your application in the visual trace that is generated, making it easier to identify and debug issues.

For instance, if you have a Python application running on AWS Lambda, you can use the OpenTelemetry Python library to instrument your code. Here's an example of how you might create a span:

Python
 
from opentelemetry import trace



tracer = trace.get_tracer(__name__)



with tracer.start_as_current_span("my_span"):

    # Your code here


In this example, a new span named my_span is created for the code inside the with block. This span will appear in the trace visualizations in your observability tool, allowing you to see how long the code inside the span took to execute and how it relates to other spans in the trace.

AWS also provides services such as AWS X-Ray, which provides a complete view of requests as they travel through your application, and Amazon CloudWatch, which collects and visualizes real-time logs, metrics, and event data in automated dashboards. ADOT supports exports to X-Ray and CloudWatch as well.   

Apart from logs, traces, and metrics, ADOT provides a fourth instrumentation tool called Baggage. Baggage can show contextual information - for example, a Client ID - that can be passed along different race spans to provide valuable insights into the end-to-end experiences of a client’s journey through the system. 

How to Get Started With ADOT

To get started with ADOT, you need to set up the OpenTelemetry Collector, configure it to collect traces and metrics, and then send the data to AWS observability services. 

You can use the ADOT Lambda layer for AWS Lambda functions. This layer includes the OpenTelemetry Collector, which collects and exports telemetry data. You can add this layer to your Lambda function in the AWS Management Console, AWS CLI, or in your SAM or CloudFormation template.

For Amazon ECS and Amazon EKS services, you can use the ADOT container image. This image includes the OpenTelemetry Collector and can be used as a sidecar container in your ECS tasks or EKS pods. The sidecar container collects and exports telemetry data from the other containers in the task or pod.

Summary

Building observable applications is crucial in today's complex software landscape. With OpenTelemetry and AWS, you can easily instrument your applications, collect and analyze traces, logs, and metrics, and gain deep insights into your application's performance and behavior. Whether you're running a serverless application on AWS Lambda or a containerized application on Amazon ECS or EKS, ADOT makes it easy to get started with observability.

As a developer, it’s important that you build code that’s well-instrumented and observable. This is the best way to ensure your systems are secure, extensible, and maintainable. Note that these are all non-functional requirements, they have nothing to do with the actual functions of the application itself.

Remember, the key to successful observability is not just about collecting data: it's about asking the right questions, understanding the data you have, and using that data to make informed decisions. So, start instrumenting your applications today and gain the insights you need to build better applications tomorrow.

If you are interested, watch the on-demand session on this topic presented at AWS re:Invent 2022.

AWS Cloud

Opinions expressed by DZone contributors are their own.

Related

  • How to Document Your AWS Cloud Infrastructure Using Multicloud-Diagrams Framework
  • Unleashing the Power of AWS: Revolutionizing Cloud Management Through Infrastructure as Code (IaC)
  • Top 9 Role-Based Cloud Certifications for Solution Architects in 2024
  • How To Understand and Choose Your First EC2 Instance on AWS

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!