Honeycomb is a fast analysis tool that helps you analyze your code’s performance and behavior to troubleshoot complex relationships within your system to solve problems faster.
To use Honeycomb, you first need to get your system’s observable external outputs–traces, metrics, and logs–into Honeycomb.
These instructions will guide you through the process of sending trace data from an application in your local development environment to Honeycomb, customizing your instrumentation to get additional visibility into the inner workings of your business logic, and exploring your data in Honeycomb.
Note
Not ready to instrument and deploy an application, but want to see what Honeycomb can do for you?
Check out this interactive demo that requires no setup, or learn what is possible from the guided tutorials in our Honeycomb sandbox!
Before You Begin
Before you run the code, you’ll need to do a few things.
Complete your account creation by giving us a team name.
Honeycomb uses teams to organize groups of users, grant them access to data, and create a shared work history in Honeycomb.
Tip
We recommend using your company or organization name as your Honeycomb team name.
Get Your Honeycomb API Key
To send data to Honeycomb, you’ll need your Honeycomb API Key.
Once you create your team, you will be able to view or copy your API key.
Make note of it; you will need it later!
Once you have your Honeycomb API key and have chosen an application, it’s time to send telemetry data to Honeycomb!
Note
This guide helps users who are new to observability get their trace data into Honeycomb using OpenTelemetry.
If you already have an OpenTelemetry implementation and are switching to Honeycomb, read about OpenTelemetry Collector.
Choose Your Application
Choose a single application or service that will send data to Honeycomb.
To successfully complete this Quick Start, you should have access to modify your application’s source code.
To test the application when you are finished, you must be able to run your application or service in a development environment.
Tip
Don’t have access to an application?
Follow along using one of our example applications!
Add Automatic Instrumentation to Your Code
The quickest way to start seeing your trace data in Honeycomb is to use OpenTelemetry, an open-source collection of tools, APIs, and SDKs, to automatically inject instrumentation code into your application without requiring explicit changes to your codebase.
Note
Automatic instrumentation works slightly differently within each language, but the general idea is that it attaches hooks into popular tools and frameworks and “watches” for certain functions to be called.
When they’re called, the instrumentation automatically starts and completes trace spans on behalf of your application.
When you add automatic instrumentation to your code, OpenTelemetry will inject spans, which represent units of work or operations within your application that you want to capture and analyze for observability purposes.
This Quick Start uses the npm dependency manager.
For instructions with yarn or if using TypeScript, read our OpenTelemetry Node.js documentation.
Install Dependencies
Open your terminal, navigate to the location of your project on your drive, and install OpenTelemetry’s automatic instrumentation meta package and Honeycomb’s OpenTelemetry Node.js distribution package:
OpenTelemetry’s meta package that provides a way to add automatic instrumentation to any Node application to capture telemetry data from a number of popular libraries and frameworks, like express, dns, http, and more.
opentelemetry-node
Honeycomb’s Node.js distribution package that streamlines configuration and allows you to instrument as quickly and easily as possible.
Create an initialization file, commonly known as the tracing.js file:
// Example filename: tracing.js
'use strict';const{HoneycombSDK}=require('@honeycombio/opentelemetry-node');const{getNodeAutoInstrumentations,}=require('@opentelemetry/auto-instrumentations-node');// Uses environment variables named HONEYCOMB_API_KEY and OTEL_SERVICE_NAME
constsdk=newHoneycombSDK({instrumentations:[getNodeAutoInstrumentations({// We recommend disabling fs automatic instrumentation because
// it can be noisy and expensive during startup
'@opentelemetry/instrumentation-fs':{enabled:false,},})]});sdk.start()
Configure the Honeycomb Distro
Use environment variables to configure the Honeycomb OpenTelemetry Node.js distribution package:
Install OpenTelemetry’s automatic instrumentation libraries for the packages used by your Python application.
We recommend that you use the opentelemetry-bootstrap tool that comes with the OpenTelemetry Python SDK to scan your application packages and generate the list of available libraries.
By default, the tool prints out the instrumentation libraries that are available, which you can add to your requirements.txt file:
Run your Python application using the OpenTelemetry Python automatic instrumentation tool opentelemetry-instrument, which configures the OpenTelemetry SDK:
Be sure to replace YOUR_APPLICATION_NAME with the name of your application’s main file.
In Honeycomb’s UI, you should now see your application’s incoming requests and outgoing HTTP calls generate traces.
Acquire Dependencies
The automatic instrumentation agent for Honeycomb OpenTelemetry Java will automatically generate trace data from your application.
The agent is packaged as a JAR file and is run alongside your app.
In order to use the automatic instrumentation agent, you must first download it:
In Honeycomb’s UI, you should now see your application’s incoming requests and outgoing HTTP calls generate traces.
Note
This Quick Start uses ASP.NET Core.
For other .NET configuration options, read our OpenTelemetry .NET documentation on programmatic and ASP.NET (.NET Framework) configuration.
Get HoneycombOptions from configuration and use these options to configure the OpenTelemetry SDK in your application startup code:
usingOpenTelemetry.Trace;varbuilder=WebApplication.CreateBuilder(args);builder.Services.AddControllers();varhoneycombOptions=builder.Configuration.GetHoneycombOptions();// Set up OpenTelemetry Tracing
builder.Services.AddOpenTelemetry().WithTracing(otelBuilder=>{otelBuilder.AddHoneycomb(honeycombOptions).AddCommonInstrumentations();});// Register a Tracer, so it can be injected into other components (for example, Controllers)
builder.Services.AddSingleton(TracerProvider.Default.GetTracer(honeycombOptions.ServiceName));varapp=builder.Build();app.MapGet("/",(Tracertracer)=>{usingvarspan=tracer.StartActiveSpan("app.manual-span");span.SetAttribute("app.manual-span.message","Adding custom spans is also super easy!");});awaitapp.RunAsync();
Run
Run your application. You will see the incoming requests and outgoing HTTP calls generate traces.
Prepare your application to send spans to Honeycomb.
Open or create a file called main.go:
packagemainimport("fmt""log""net/http""github.com/honeycombio/honeycomb-opentelemetry-go""github.com/honeycombio/otel-config-go/otelconfig""go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp")// Implement an HTTP Handler function to be instrumented
funchttpHandler(whttp.ResponseWriter,r*http.Request){fmt.Fprintf(w,"Hello, World")}// Wrap the HTTP handler function with OTel HTTP instrumentation
funcwrapHandler(){handler:=http.HandlerFunc(httpHandler)wrappedHandler:=otelhttp.NewHandler(handler,"hello")http.Handle("/hello",wrappedHandler)}funcmain(){// Enable multi-span attributes
bsp:=honeycomb.NewBaggageSpanProcessor()// Use the Honeycomb distro to set up the OpenTelemetry SDK
otelShutdown,err:=otelconfig.ConfigureOpenTelemetry(otelconfig.WithSpanProcessor(bsp),)iferr!=nil{log.Fatalf("error setting up OTel SDK - %e",err)}deferotelShutdown()// Initialize HTTP handler instrumentation
wrapHandler()log.Fatal(http.ListenAndServe(":3030",nil))}
Configure the Honeycomb Distro
Use environment variables to configure the Honeycomb OpenTelemetry Go distribution package:
Including opentelemetry-instrumentation-all provides instrumentation for Rails, Sinatra, several HTTP libraries, and more.
Initialize
Initialize OpenTelemetry early in your application lifecycle.
For Rails applications, we recommend that you use a Rails initializer.
For other Ruby services, initialize as early as possible in the startup process.
# config/initializers/opentelemetry.rbrequire'opentelemetry/sdk'require'opentelemetry/exporter/otlp'require'opentelemetry/instrumentation/all'OpenTelemetry::SDK.configuredo|c|c.use_all()# enables all instrumentation!end
Configure the Honeycomb Distro
Use environment variables to configure OpenTelemetry to send events to Honeycomb:
Base endpoint to which you want to send your telemetry data.
OTEL_EXPORTER_OTLP_HEADERS
List of headers to apply to all outgoing telemetry data. Place your API Key generated in Honeycomb in the x-honeycomb-team header. Learn how to find your Honeycomb API Key.
OTEL_SERVICE_NAME
Service name. When you send data, Honeycomb creates a dataset in which to store your data and uses this as the name. Can be any string.
Run Your Application
Run your Ruby application.
In Honeycomb’s UI, you should now see your application’s incoming requests and outgoing HTTP calls generate traces.
Now that you have added automatic instrumentation to your application and have it running in your development environment, interact with your application by making a few requests.
Making requests to your service will generate telemetry data and send it to Honeycomb where it will appear in the Honeycomb UI within seconds.
Tip
If you have made several service requests in your development environment and after several minutes, you still do not see any data, reach out for help in our Pollinators Community Slack.
View an Example Trace
Before you move on, take a look at the data that you have generated using automatic instrumentation by viewing an example trace, which is a visual diagram that represents the complete journey of a request or transaction as it traverses a distributed system.
Traces provide a way to visualize and understand the flow of execution and the interactions between various components involved in serving a request.
They can help you find the source of errors in a system, identify the slowest processes, and break down the user experience in great detail.
While Honeycomb helps you analyze all of your outputs, where we particularly shine is when working with traces to give you a visual representation of where requests spend time in your system.
In this example, we want to see a count of events, an average latency for those events, and a heatmap of latency.
In the heatmap results, click on a dot to get a trace.
We generated the following examples after adding automatic instrumentation to a simple greeting service application written in Node.js.
You can see the code in our GitHub repository.
Here’s our example heatmap:
And here is our example trace:
In this trace, you can see:
the spans within the trace
how long each span took
which spans contain errors (none, in this example)
All of this is useful information, but more information will allow us to dig even more deeply.
To do this, we need to enhance our automatic instrumentation by customizing it.
Customize Your Instrumentation
To get the most insight into your system, you should customize your instrumentation.
For example, if you have an application or service that handles users, you probably want to associate the user with the span created by automatic instrumentation.
Additionally, because automatic instrumentation doesn’t know your business logic–it only knows about frameworks and languages–you’ll want to explicitly add instrumentation code surrounding your business logic.
Tip
When deciding what to instrument, we recommend thinking of this as an exploratory process and part of the core analysis loop.
You don’t need to add your custom instrumentation to everything all at once.
Consider your top interests and instrument them, then analyze your results and add additional code as necessary.
Install Dependencies
Before you can customize your instrumentation, you must install any required dependencies. These will vary depending on your chosen programming language.
To continue, you must install OpenTelemetry’s API package. Once you have installed the API package, you can use it to add instrumentation for everything you care about in your application.
Note
This Quick Start uses the npm dependency manager.
For instructions with yarn or if using TypeScript, read our OpenTelemetry Node.js documentation.
npm install --save @opentelemetry/api
To continue, you must install OpenTelemetry’s API package. Once you have installed the API package, you can use it to add instrumentation for everything you care about in your application.
To continue, you must install Honeycomb’s OpenTelemetry SDK, which provides access to the OpenTelemetry APIs. Once you have installed the SDK, you can use it to add instrumentation for everything you care about in your application.
This Quick Start uses ASP.NET Core.
For other .NET configuration options, read our OpenTelemetry .NET documentation on programmatic and ASP.NET (.NET Framework) configuration.
Because you already installed all necessary dependencies when implementing automatic instrumentation, you can skip this step.
Because you already installed all necessary dependencies when implementing automatic instrumentation, you can skip this step.
Because you already installed all necessary dependencies when implementing automatic instrumentation, you can skip this step.
To enhance the understanding of your telemetry data, you can attach contextual information to the spans generated by automatic instrumentation.
Contextual information includes attributes, which are arbitrary key-value pairs that you can add to provide additional data about the span, such as a specific database query being executed or an HTTP request being made.
In this example, you will enhance your automatic instrumentation by associating a span created automatically when a user queries your service with the user’s ID, which will be saved in an attribute called user.id.
Once this attribute is added, you will be able to use it to query your data in Honeycomb.
constopentelemetry=require("@opentelemetry/api");//...
functionhandleUser(user){// Gets the active span from the context
letactiveSpan=opentelemetry.trace.getActiveSpan();// Sets an attribute that contains the user ID
activeSpan.setAttribute("user.id",user.getId());}
fromopentelemetryimporttrace#...# Gets the active span from the contextspan=trace.get_current_span()# Sets an attribute that contains the user IDspan.set_attribute("user.id",user.id())
importio.opentelemetry.api.trace.Span;//...
// Gets the active span from the context
Spanspan=Span.current();// Sets an attribute that contains the user ID
span.setAttribute("user.id",user.getId());
usingOpenTelemetry.Trace;//...
// Gets the active span from the context
varcurrentSpan=Tracer.CurrentSpan;// Sets an attribute that contains the user ID
currentSpan.SetAttribute("user.id",User.GetUserId())
This example assumes you are writing a web application with the net/http package.
import(// ...
"go.opentelemetry.io/otel/attribute""go.opentelemetry.io/otel/trace"// ...
)// ...
handler:=func(whttp.ResponseWriter,r*http.Request){// Gets the currently logged in user
user:=someServiceCall()ctx:=r.Context()// Gets the active span from the context
span:=trace.SpanFromContext(ctx)// Sets an attribute that contains the user ID
span.SetAttributes(attribute.Int("user.id",user.getID()))}// ...
# Somewhere within the service, the SDK has been required and configuredrequire'opentelemetry/sdk'OpenTelemetry::SDK.configuredo...end# ...defhandle_user(user)# Gets the active span from the contextcurrent_span=OpenTelemetry::Trace.current_span# Sets an attribute that contains the user IDcurrent_span.set_attribute("user.id",user.id)end
To further enhance the understanding of your telemetry data, you’ll want to generate custom spans.
Automatic instrumentation can show the shape of requests to your system, but only you know the truly important parts.
To get the full picture, you should manually add spans to areas of interest. In OpenTelemetry, this is called manual instrumentation.
Initialize a Tracer
Before you can create a custom span, you must initialize a tracer.
In OpenTelemetry, a tracer is used to instrument your code and generate telemetry data. The tracer provides the interface for capturing spans, which represent individual units of work in your code.
constopentelemetry=require("@opentelemetry/api");// Creates the tracer and names it.
// Choose a name that matches the appropriate scope for your trace.
// For example, if you have one tracer for each service, then use
// the service name. If you have multiple tracers that live in
// different "layers" of your application, then user the name that
// corresponds to the appropriate "layer".
consttracer=opentelemetry.trace.getTracer("your.tracer.name");
fromopentelemetryimporttrace#...# Creates the tracer and names it.# Choose a name that matches the appropriate scope for your trace. # For example, if you have one tracer for each service, then use # the service name. If you have multiple tracers that live in # different "layers" of your application, then user the name that # corresponds to the appropriate "layer".tracer=trace.get_tracer("tracer.name.here")
importio.opentelemetry.api;//...
// Creates the tracer and names it.
// Choose a name that matches the appropriate scope for your trace.
// For example, if you have one tracer for each service, then use
// the service name. If you have multiple tracers that live in
// different "layers" of your application, then user the name that
// corresponds to the appropriate "layer".
Tracertracer=openTelemetry.getTracer("tracer.name.here");
usingOpenTelemetry.Trace;//...
// Creates the tracer and names it.
// Choose a name that matches the appropriate scope for your trace.
// For example, if you have one tracer for each service, then use
// the service name. If you have multiple tracers that live in
// different "layers" of your application, then user the name that
// corresponds to the appropriate "layer".
vartracer=TracerProvider.Default.GetTracer("tracer.name.here");
Then, inject the Tracer instance with ASP.NET Core dependency injection or manage its lifecycle manually.
import(// ...
"go.opentelemetry.io/otel"// ...
)//...
// Creates the tracer and names it.
// Choose a name that matches the appropriate scope for your trace.
// For example, if you have one tracer for each service, then use
// the service name. If you have multiple tracers that live in
// different "layers" of your application, then user the name that
// corresponds to the appropriate "layer".
tracer:=otel.Tracer("tracer.name.here")
require"opentelemetry/sdk"#...# Creates the tracer and names it.# Choose a name that matches the appropriate scope for your trace. # For example, if you have one tracer for each service, then use # the service name. If you have multiple tracers that live in # different "layers" of your application, then user the name that # corresponds to the appropriate "layer".tracer=OpenTelemetry.tracer_provider.tracer("tracer.name.here")
constopentelemetry=require("@opentelemetry/api");consttracer=opentelemetry.trace.getTracer("my-service-tracer");functionrunQuery(){tracer.startActiveSpan("expensive-query",(span)=>{// Do cool stuff
span.end();});}
fromopentelemetryimporttracetracer=trace.get_tracer("tracer.name.here")withtracer.start_as_current_span("some-long-running-handler"):# Prepare to authwithtracer.start_as_current_span("what-it-takes-to-authorize-handling"):# Perform auth# Do the authorized long-running handling of cool stuff
importio.opentelemetry.api.GlobalOpenTelemetry;importio.opentelemetry.api.trace.Span;importio.opentelemetry.api.trace.Tracer;...Tracertracer=GlobalOpenTelemetry.getTracer("my-service");Spanspan=tracer.spanBuilder("expensive-query").startSpan();// ... Do cool stuff
span.end();
usingOpenTelemetry.Trace;//...
usingvarspan=TracerProvider.Default.GetTracer("my-service").StartActiveSpan("expensive-query")// ... Do cool stuff
import(// ...
"go.opentelemetry.io/otel"// ...
)// ...
tracer:=otel.Tracer("my-app")// If not already in scope
ctx,span:=tracer.Start(ctx,"expensive-operation")deferspan.End()// ...
# Somewhere within the service, the SDK has been required and configuredrequire'opentelemetry/sdk'OpenTelemetry::SDK.configuredo...end# ...defrun_querytracer=OpenTelemetry.tracer_provider.tracer('my-tracer')tracer.in_span("expensive-query")do|span|# ... Do cool stuffspan.set_attribute('coolness',100)endend
Now that you have customized your instrumentation, take a look at your trace again.
We generated the following examples after adding additional custom spans (a note to indicate where we are in the process, plus person name and message) to our simple greeting service application written in Node.js.
You can see the code in our GitHub repository.
Here’s our example trace:
In this trace, you can see the additional spans:
note indicating we are preparing the greeting
call name
call message
If you look in the Fields section of the UI, you would also see new attributes, such as the name of the person and the message that was sent.
What’s Next?
Excellent work!
If you made it this far, you should now have telemetry data from your application flowing into Honeycomb.
You can deploy to production and start gaining new insights on real traffic!
But there is so much more to explore!
To learn more about what you can do with Honeycomb, check out:
Exploring Your Data: See a quick run-through of the different ways you can explore your data in Honeycomb.