Getting started with any new technology can be daunting, but oftentimes, that’s only because we don’t have the proper tools. OpenTelemetry isn’t quite new any more, having officially been incepted in 2019; however, there can be a steep learning curve when it comes to instrumenting your services with this popular open-source observability framework.
What about when you just want to try it out and see the data it generates before you invest significant time going through the documentation to learn how to instrument a service with OpenTelemetry? This blog post highlights some of the tools that are available to you for just this purpose.
Continue through this post to read about them, or use the list below to skip ahead to the one that piques your interest:
The otel-cli is a command-line interface tool that lets you send OpenTelemetry traces to a collector or New Relic from the command line. This is a good option for trying out OpenTelemetry because it:
- Enables you to get started with distributed tracing quickly
- Enables you to add tracing to shell scripts and other applications that don’t support tracing natively
- Is fairly simple
otel-cli requires a working Go environment, which may potentially add an additional layer of complexity for you. Fortunately, it’s fairly easy to install Go; follow the instructions here. Once you’ve got Go set up, have your New Relic license key handy, then follow the steps below to use otel-cli to generate a trace and send it to your New Relic account:
- Install otel-cli. The repo provides a few different ways to install otel-cli, but generally running this command will work for most platforms:
- go install github.com/equinix-labs/otel-cli@latest
- Export the following environment variables:
- Replace [YOUR_NR_LICENSE_KEY] with your account ingest license key
- If you’re located in the EU, use our EU OTLP endpoint: https://otlp.eu01.nr-data.net:4317
- Run a program inside a span:
- otel-cli exec --service my-service --name "curl google" curl https://google.com
- Head to your New Relic account and query the span:
- SELECT * FROM Span since 5 minutes ago
- You can also view your new OpenTelemetry service, called “my-service”, under All entities > Services - OpenTelemetry. From there, access Distributed tracing, click on the trace group curl google and then check out more details about the span, such as its attributes and duration:
- Note that the charts on the Summary page will be empty because the span that’s generated is of span kind “client”. The Summary charts only query for spans that are “consumer” or “server” kind.
As you’ve just seen, the span that’s generated is fairly simple. But what if you want to see some data that’s a little more interesting?
Another tool for trying out OpenTelemetry is telemetrygen, a utility that simulates a client that generates traces, metrics, and logs. It’s a quick way to see some OpenTelemetry data, and it doesn’t require your own application.
telemetrygen is primarily useful for testing and demonstration purposes, so the data it produces is pretty basic—it’s static and not particularly realistic. You’ll also need to run a collector, an OpenTelemetry component that receives, transforms, and exports telemetry.
- Use Docker to pull the OpenTelemetry Collector image and run the collector in a container:
- docker pull otel/opentelemetry-collector:0.91.0
- docker run otel/opentelemetry-collector:0.91.0
- In another terminal window or tab, install the telemetrygen utility:
- go install github.com/open-telemetry/opentelemetry-collector-contrib/cmd/telemetrygen@latest
- Generate telemetry by running this command to send some data to the collector:
- telemetrygen traces --otlp-insecure --duration 5s
- After 5 seconds, the utility will stop and you can view the traces in your terminal where the collector is running:
If you’re ready to get more hands-on and generate telemetry that’s more realistic, it may be time to check out the OpenTelemetry Community demo.
The OpenTelemetry Community demo application is made up of several microservices written in different languages that talk to each other over gRPC and HTTP, and includes a load generator that simulates traffic. It’s developed and maintained by the OpenTelemetry community, with the purpose of providing a real-world example of a distributed system instrumented by OpenTelemetry.
You can use the demo in several ways:
- View instrumentation examples in different languages, including Java, .NET, and PHP.
- Modify the instrumentation and collector config file to test and experiment.
- Understand the data generated by OpenTelemetry instrumentation libraries.
- It also includes a few problem-solving scenarios to show you how to interpret OpenTelemetry data to solve them.
The base demo app includes some backends so you can see visualizations of the generated data. To learn how to deploy it and send data to your New Relic account, follow the steps in this blog post: Hands-on OpenTelemetry: Troubleshoot issues with your instrumented apps.
If you want to get hands-on with a more simple application, we have examples available in several languages in this repository. In the Getting Started Guides directory, you’ll find sample apps with and without OpenTelemetry instrumentation, so you can see what the code looks like before and after being instrumented.
You can run the examples by following your selected language’s README file in its “instrumented” directory, or instrument the app yourself by following the README instructions in its “uninstrumented” directory.
Now that you’ve been equipped with several options for trying out OpenTelemetry, check out the following resources to learn more about getting started with OpenTelemetry and New Relic, and how to view your data in your account:
本ブログに掲載されている見解は著者に所属するものであり、必ずしも New Relic 株式会社の公式見解であるわけではありません。また、本ブログには、外部サイトにアクセスするリンクが含まれる場合があります。それらリンク先の内容について、New Relic がいかなる保証も提供することはありません。