Install Modules
In your terminal, run the commands below to install the packages required to auto-instrument a Node.js application:
npm install --save \
@opentelemetry/sdk-node@0.27.0 \
@opentelemetry/exporter-trace-otlp-proto@0.27.0 \
@opentelemetry/auto-instrumentations-node@0.28.0
auto-instrumentations-node
is a meta package that provides a way to initialize multiple Node.js instrumentations like express
, dns
, http
, and more.
Alternatively, you can install individual instrumentation packages.
Initialize
Create an initialization file, commonly known as the tracing.js
file, and import it as the first step in your application lifecycle.
Alternatively, include this initialization file with the -r
, --require
Node.js CLI option.
// tracing.js
'use strict';
const { NodeSDK } = require('@opentelemetry/sdk-node');
const { getNodeAutoInstrumentations } = require('@opentelemetry/auto-instrumentations-node');
const { OTLPTraceExporter } = require("@opentelemetry/exporter-trace-otlp-proto");
// The Trace Exporter exports the data to Honeycomb and uses
// the environment variables for endpoint, service name, and API Key.
const traceExporter = new OTLPTraceExporter();
const sdk = new NodeSDK({
traceExporter,
instrumentations: [getNodeAutoInstrumentations()]
});
sdk.start()
Configure and Run
Configure OpenTelemetry to send events to Honeycomb using environment variables.
The header x-honeycomb-team
is your API key.
Your service name will be used as the Service Dataset in Honeycomb, which is where data is stored.
The service name is specified by OTEL_SERVICE_NAME
.
export OTEL_EXPORTER_OTLP_ENDPOINT="https://api.honeycomb.io"
export OTEL_EXPORTER_OTLP_HEADERS="x-honeycomb-team=your-api-key"
export OTEL_SERVICE_NAME="your-service-name"
Run the Node.js app with the OpenTelemetry initialization file to generate data:
node -r ./tracing.js APPLICATION_MAIN_FILE.js
Install Packages
This is a quick start guide for Python with Flask.
Install these packages to instrument a Flask app with OpenTelemetry:
pip install opentelemetry-api
pip install opentelemetry-sdk
pip install opentelemetry-exporter-otlp-proto-http
pip install opentelemetry-instrumentation-flask
pip install opentelemetry-instrumentation-requests
Initialize
Create a new file, tracing.py
.
This file will create and initialize a tracer and Flask instrumentation to send data to Honeycomb:
# tracing.py
from opentelemetry import trace
from opentelemetry.instrumentation.flask import FlaskInstrumentor
from opentelemetry.instrumentation.requests import RequestsInstrumentor
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor
# Initialize tracing and an exporter that can send data to Honeycomb
provider = TracerProvider()
processor = BatchSpanProcessor(OTLPSpanExporter())
provider.add_span_processor(processor)
trace.set_tracer_provider(provider)
tracer = trace.get_tracer(__name__)
# Initialize automatic instrumentation with Flask
app = flask.Flask(__name__)
FlaskInstrumentor().instrument_app(app)
RequestsInstrumentor().instrument()
Configure and Run
Configure OpenTelemetry to send events to Honeycomb using environment variables.
The header x-honeycomb-team
is your API key.
Your service name will be used as the Service Dataset in Honeycomb, which is where data is stored. The service name is specified by OTEL_SERVICE_NAME
.
export OTEL_EXPORTER_OTLP_ENDPOINT="https://api.honeycomb.io/"
export OTEL_EXPORTER_OTLP_HEADERS="x-honeycomb-team=your-api-key"
export OTEL_SERVICE_NAME="your-service-name"
python app.py tracing.py
Acquire Dependencies
The auto-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 auto-instrumentation agent, you must first download it:
curl -LO https://github.com/honeycombio/honeycomb-opentelemetry-java/releases/download/v1.1.0/honeycomb-opentelemetry-javaagent-1.1.0.jar
Configure
Choose from one of the following configuration options:
Use environment variables:
SERVICE_NAME=my-favorite-service
HONEYCOMB_API_KEY=my-api-key
HONEYCOMB_METRICS_DATASET=my-metrics
Or, use system properties:
sample.rate=2
service.name=my-favorite-service
honeycomb.api.key=my-api-key
honeycomb.metrics.dataset=my-metrics
and set an environment variable with a path to your properties file:
HONEYCOMB_CONFIG_FILE=/path/to/properties/file
Run
Run your app with the auto-instrumentation agent as a sidecar:
java -javaagent:honeycomb-opentelemetry-javaagent-1.1.0.jar -jar /path/to/myapp.jar
You can also include configuration values with an invocation of your app, like so:
java \
-Dhoneycomb.config.file=/path/to/properties/file \
-javaagent:honeycomb-opentelemetry-javaagent-1.1.0.jar -jar /path/to/myapp.jar
Refer to our Java documentation for more configuration options.
Acquire Dependencies
Install the Honeycomb.OpenTelemetry NuGet package.
For example, with the .NET CLI, use:
dotnet add package Honeycomb.OpenTelemetry --prerelease
Initialize
Initialize your ASP.NET
Core app to use the Honeycomb OpenTelemetry Distribution for .NET:
In your appsettings.json
file, add a Honeycomb section like so:
{
...
"Honeycomb": {
"ServiceName": "my-app",
"ApiKey": "{apikey}"
}
}
Then pass the IConfiguration
object to configure the OpenTelemetry SDK in your application startup code:
using Honeycomb.OpenTelemetry;
// ...
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
// configure OpenTelemetry SDK to send data to Honeycomb
services.AddHoneycomb(Configuration);
}
You can find additional configuration options in our .NET documentation.
Run
You can now run your app, and you will see the incoming requests and outgoing HTTP calls generate traces.
dotnet run
Refer to our .NET documentation for all configuration options and ways to run your application.
Acquire Dependencies
Fetch OpenTelemetry packages so you can configure an HTTP server to automatically generate trace data:
go get go.opentelemetry.io/otel \
go.opentelemetry.io/otel/trace \
go.opentelemetry.io/otel/sdk \
go.opentelemetry.io/otel/exporters/otlp/otlptrace \
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp \
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp
Initialize
Configure an exporter to send spans to Honeycomb.
Open or create a file called main.go
:
package main
import (
"context"
"fmt"
"log"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/exporters/otlp/otlptrace"
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp"
"go.opentelemetry.io/otel/propagation"
sdktrace "go.opentelemetry.io/otel/sdk/trace"
"net/http"
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
)
func newExporter(ctx context.Context) (*otlptrace.Exporter, error) {
client := otlptracehttp.NewClient()
return otlptrace.New(ctx, client)
}
func newTraceProvider(exp *otlptrace.Exporter) *sdktrace.TracerProvider {
return sdktrace.NewTracerProvider(
sdktrace.WithBatcher(exp),
)
}
// Implement an HTTP Handler func to be instrumented
func httpHandler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello, World")
}
// Wrap the HTTP handler func with OTel HTTP instrumentation
func wrapHandler() {
handler := http.HandlerFunc(httpHandler)
wrappedHandler := otelhttp.NewHandler(handler, "hello")
http.Handle("/hello", wrappedHandler)
}
func main() {
ctx := context.Background()
// Configure a new exporter using environment variables for sending data to Honeycomb over gRPC.
exp, err := newExporter(ctx)
if err != nil {
log.Fatalf("failed to initialize exporter: %v", err)
}
// Create a new tracer provider with a batch span processor and the otlp exporter.
tp := newTraceProvider(exp)
// Handle this error in a sensible manner where possible
defer func() { _ = tp.Shutdown(ctx) }()
// Set the Tracer Provider and the W3C Trace Context propagator as globals
otel.SetTracerProvider(tp)
// Register the trace context and baggage propagators so data is propagated across services/processes.
otel.SetTextMapPropagator(
propagation.NewCompositeTextMapPropagator(
propagation.TraceContext{},
propagation.Baggage{},
),
)
// Initialize HTTP handler instrumentation
wrapHandler()
log.Fatal(http.ListenAndServe(":3030", nil))
}
Note: Any Baggage attributes that you set in your application will be attached to outgoing network requests as a header. If your service communicates to a third party API, be sure not to put sensitive information in the Baggage attributes.
Configure and Run
Configure OpenTelemetry to send events to Honeycomb using environment variables.
The header x-honeycomb-team
is your API key.
Your service name will be used as the Service Dataset in Honeycomb, which is where data is stored.
The service name is specified by OTEL_SERVICE_NAME
.
export OTEL_EXPORTER_OTLP_ENDPOINT="https://api.honeycomb.io"
export OTEL_EXPORTER_OTLP_HEADERS="x-honeycomb-team=your-api-key"
export OTEL_SERVICE_NAME="your-service-name"
Now you can run your application and see traces created for each incoming HTTP request:
go run main.go
Acquire Dependencies
Add these gems to your Gemfile:
gem 'opentelemetry-sdk'
gem 'opentelemetry-exporter-otlp'
gem 'opentelemetry-instrumentation-all'
The inclusion of opentelemetry-instrumentation-all
above provides instrumentation for Rails, Sinatra, several HTTP libraries, and more.
Initialize
OpenTelemetry initialization must occur early in your application lifecycle. For Rails applications, the usual way to initialize OpenTelemetry is in a Rails initializer. For other Ruby services, perform this initialization as early as possible in the start-up process.
# config/initializers/opentelemetry.rb
require 'opentelemetry/sdk'
require 'opentelemetry/exporter/otlp'
require 'opentelemetry/instrumentation/all'
OpenTelemetry::SDK.configure do |c|
c.use_all() # enables all instrumentation!
end
Configure and Run
Configure OpenTelemetry to send events to Honeycomb using environment variables.
The header x-honeycomb-team
is your API key.
Your service name will be used as the Service Dataset in Honeycomb, which is where data is stored. The service name is specified by OTEL_SERVICE_NAME
.
export OTEL_EXPORTER_OTLP_ENDPOINT="https://api.honeycomb.io"
export OTEL_EXPORTER_OTLP_HEADERS="x-honeycomb-team=your-api-key"
export OTEL_SERVICE_NAME="your-service-name"
You can now run your Ruby app to automatically generate traces.
If your preferred language is not covered here, use the OpenTelemetry community documentation to find relevant instrumentation details.
In general, any OpenTelemetry integration should carry out these two steps:
- Set the endpoint:
- If using OTLP/gRPC, set
OTEL_EXPORTER_OTLP_ENDPOINT
to:api.honeycomb.io:443
- If using OTLP/HTTPS, set
OTEL_EXPORTER_OTLP_ENDPOINT
to:https://api.honeycomb.io
- If using OTLP/gRPC, set
- Configure:
- Set the
x-honeycomb-team
header with your API key - Set the name of your service specified as the
service.name
resource attribute
- Set the