OpenTelemetry (OTel) Is Key to Avoiding Vendor Lock-inĀ
OpenTelemetry provides an open standard for generating, collecting and exporting application telemetry across any number of backend systems.
Feb 7th, 2022 6:20am by
Featured image via Pixabay.
Honeycomb sponsored this post. Insight Partners is an investor in Honeycomb and TNS.
How Vendor Lock-in Became a Thing
Vera Reynolds
Vera is a senior telemetry engineer at Honeycomb and has a fondness for developer quality-of-life improvements. Before Honeycomb, she built CI/CD at CircleCI and monitoring tools at Pivotal CloudFoundry, among other endeavors
OpenTelemetry Unlocks Vendor Lock-in
If you’ve ever found yourself with tools that weren’t serving you but the cost of implementing (or even evaluating) an alternative was too high to consider switching, then you understand why the vendor lock-in problem is unacceptable. OpenTelemetry aims to break that cycle by providing a standardized instrumentation framework. Out of a shared frustration with the state of proprietary telemetry affairs, standards began to emerge in the form of two parallel open source projects: OpenCensus and OpenTracing. Eventually, the communities merged and combined the two standards into the OpenTelemetry project. While it’s still a relatively new kid on the block, OpenTelemetry (or OTel) is growing up fast and was recently accepted as a CNCF incubating project. OpenTelemetry provides an open standard for generating, collecting and exporting application telemetry across any number of backend systems. It’s an open source and vendor-neutral instrumentation framework that frees you from the trap of using proprietary libraries simply to understand how your code is behaving. Now, you can instrument your applications just once and then take that instrumentation to any other backend system of your choice. Vendors should have to compete for your love based on how well they can delight you and solve your problems, not based on how annoying it is to get rid of them. With OTel, that’s finally possible. Sounds pretty good, right? Let’s take a look at how switching vendors with OTel might look in practice.How to Switch Vendors with OpenTelemetry
We’ll start with a simple Node.js Express app. We just have one route, and we fetch a todo to keep things interesting.
```js
// app.js
const express = require("express");
const https = require("https");
const app = express();
app.get("/", async (req, res) => {
https.get("https://jsonplaceholder.typicode.com/todos/1", (incoming) => {
incoming.on("data", (data) => {
console.log(JSON.parse(data))
});
incoming.on("end", () => {
res.send("OK")
});
});
});
app.listen(3000, () => {
console.log(`Listening for requests on http://localhost:3000`);
});
```
```json
"dependencies": {
"@grpc/grpc-js": "1.3.7",
"@opentelemetry/api": "1.0.3",
"@opentelemetry/auto-instrumentations-node": "0.25.0",
"@opentelemetry/exporter-collector-grpc": "0.25.0",
"@opentelemetry/sdk-node": "0.25.0",
"express": "~4.16.1"
}
```
```js
// tracing.js
const opentelemetry = require('@opentelemetry/sdk-node');
const { getNodeAutoInstrumentations } = require('@opentelemetry/auto-instrumentations-node');
const { CollectorTraceExporter } = require("@opentelemetry/exporter-collector-grpc");
const { credentials } = require("@grpc/grpc-js");
const traceExporter = new CollectorTraceExporter({
credentials: credentials.createSsl(),
});
let sdk = new opentelemetry.NodeSDK({
traceExporter,
instrumentations: [getNodeAutoInstrumentations()]
});
sdk.start()
```
```sh
export OTEL_EXPORTER_OTLP_ENDPOINT=“https://api.honeycomb.io”
export OTEL_EXPORTER_OTLP_HEADERS=“x-honeycomb-team=MY_HNY_KEY,x-honeycomb-dataset=otel-node”
export OTEL_SERVICE_NAME=“express-backend”
```
```sh
node -r tracing.js app.js
```
Of course, we don’t stop here. We want to know what kind of todo we fetched. Let’s add a span with the todo title as an attribute.
```js
// app.js
const otel = require("@opentelemetry/api");
let tracer = otel.trace.getTracer("my-tracer");
app.get("/", async (req, res) => {
https.get("https://jsonplaceholder.typicode.com/todos/1", (incoming) => {
let span = tracer.startSpan("reading-todo");
incoming.on("data", (data) => {
span.setAttribute("title", JSON.parse(data).title)
});
incoming.on("end", () => {
span.end();
res.send("OK")
});
});
});
```
Oh hey, we got another span in our trace, and it shows the todo title!
Now, let’s say that you want to send your data somewhere other than Honeycomb. Easy — just swap out your endpoint and headers. Let’s look at New Relic as an example.
```sh
export OTEL_EXPORTER_OTLP_ENDPOINT=“https://otlp.nr-data.net:4317/”
export OTEL_EXPORTER_OTLP_HEADERS=“api-key=MY_NR_KEY”
```
But what if you’re not quite ready to make the switch and want to shop your data around multiple vendors? The OpenTelemetry Collector is an OTel component that allows you to ingest, process and export telemetry by configuring data pipelines. It’s not a required component, but in this case, we can leverage it to send our traces to both Honeycomb and New Relic. We start by running the collector locally in a Docker container.
```sh
docker run -p 4317:4317 -v /collector-config.yaml:/etc/collector-config.yaml otel/opentelemetry-collector —config=/etc/collector-config.yaml
```
```yaml
receivers:
otlp:
protocols:
grpc:
exporters:
otlp/hny:
endpoint: api-dogfood.honeycomb.io:443
headers:
"x-honeycomb-team": "MY_HNY_KEY"
"x-honeycomb-dataset": "otel-node"
otlp/nr:
endpoint: otlp.nr-data.net:4317
headers:
"api-key": "MY_NR_KEY"
service:
pipelines:
traces:
receivers: [otlp]
exporters: [otlp/hny,otlp/nr]
```
```js
// tracing.js
const traceExporter = new CollectorTraceExporter({
credentials: credentials.createInsecure(),
});
```
```sh
export OTEL_EXPORTER_OTLP_ENDPOINT=localhost:4317
```
Break Yourself out of the Cycle of Vendor Lock-in
The example in this blog is a trivial one, but think of the dozens (or hundreds? Hello, microservices) of endpoints and code paths that can be left blissfully unaware of your tracing backend. With OpenTelemetry, there is no need to hardcode vendor-specific logic into your applications only to get stuck with them until the end of time. OpenTelemetry enables you to have more agency over your telemetry data and opens more doors when choosing a vendor (or multiple vendors!). At Honeycomb, we believe that the value we provide for you is evident once you start analyzing and debugging your telemetry. Observability is measured by your ability to quickly identify the correct sources of issues and to discover hidden problems that legacy tools simply can’t show you. Those metrics, logs and traces are simple table stakes, and you shouldn’t be locked into a particular solution just to get your data. We fully support the OpenTelemetry project, and we hope you’ve found this step-by-step example helpful.Try It for Yourself
Did we pique your interest in OpenTelemetry? If you’re ready to dive in, check out our quickstart docs for setting up OTel with Honeycomb, and, if you haven’t already, sign up for a free Honeycomb account. If Honeycomb doesn’t work for you, you’ll be able to take that work elsewhere. You can also learn more about the project, find documentation and join the OTel community at https://opentelemetry.io/
YOUTUBE.COM/THENEWSTACK
Tech moves fast, don't miss an episode. Subscribe to our YouTube
channel to stream all our podcasts, interviews, demos, and more.