Learn how OpenTelemetry-compatible events flow into Axiom and explore Axiom comprehensive observability through browsing, querying, dashboards, and alerting of OpenTelemetry data.
OpenTelemetry (OTel) is a set of APIs, libraries, and agents to capture distributed traces and metrics from your app. It’s a Cloud Native Computing Foundation (CNCF) project that was started to create a unified solution for service and app performance monitoring.
The OpenTelemetry project has published strong specifications for the three main pillars of observability: logs, traces, and metrics. These schemas are supported by all tools and services that support interacting with OpenTelemetry. Axiom supports OpenTelemetry natively on an API level, allowing you to connect any existing OpenTelemetry shipper, library, or tool to Axiom for sending data.
OpenTelemetry-compatible events flow into Axiom, where they’re organized into datasets for easy segmentation. Users can create a dataset to receive OpenTelemetry data and obtain an API token for ingestion. Axiom provides comprehensive observability through browsing, querying, dashboards, and alerting of OpenTelemetry data.
Configuring the OpenTelemetry collector is as simple as creating an HTTP exporter that sends data to the Axiom API together with headers to set the dataset and API token.
To send traces to an OpenTelemetry Collector using the OTLP over HTTP in Ruby, use the opentelemetry-exporter-otlp-http gem provided by the OpenTelemetry project.
shell
require 'opentelemetry/sdk'require 'opentelemetry/exporter/otlp'require 'opentelemetry/instrumentation/all'OpenTelemetry::SDK.configure do |c| c.service_name = 'ruby-traces' # Set your service name c.use_all # or specify individual instrumentation you need c.add_span_processor( OpenTelemetry::SDK::Trace::Export::BatchSpanProcessor.new( OpenTelemetry::Exporter::OTLP::Exporter.new( endpoint: 'https://AXIOM_DOMAIN/v1/traces', headers: { 'Authorization' => 'Bearer API_TOKEN', 'X-AXIOM-DATASET' => 'DATASET_NAME' } ) ) )end
You can send traces to Axiom using the OpenTelemetry .NET SDK by configuring an OTLP HTTP exporter in your .NET app. Here is a simple example:
csharp
using OpenTelemetry;using OpenTelemetry.Resources;using OpenTelemetry.Trace;using System;using System.Diagnostics;using System.Reflection;// Class to configure OpenTelemetry tracingpublic static class TracingConfiguration{ // Declares an ActivitySource for creating tracing activities private static readonly ActivitySource ActivitySource = new("MyCustomActivitySource"); // Configures OpenTelemetry with custom settings and instrumentation public static void ConfigureOpenTelemetry() { // Retrieve the service name and version from the executing assembly metadata var serviceName = Assembly.GetExecutingAssembly().GetName().Name ?? "UnknownService"; var serviceVersion = Assembly.GetExecutingAssembly().GetName().Version?.ToString() ?? "UnknownVersion"; // Setting up the tracer provider with various configurations Sdk.CreateTracerProviderBuilder() .SetResourceBuilder( // Set resource attributes including service name and version ResourceBuilder.CreateDefault().AddService(serviceName, serviceVersion: serviceVersion) .AddAttributes(new[] { new KeyValuePair<string, object>("environment", "development") }) // Additional attributes .AddTelemetrySdk() // Add telemetry SDK information to the traces .AddEnvironmentVariableDetector()) // Detect resource attributes from environment variables .AddSource(ActivitySource.Name) // Add the ActivitySource defined above .AddAspNetCoreInstrumentation() // Add automatic instrumentation for ASP.NET Core .AddHttpClientInstrumentation() // Add automatic instrumentation for HttpClient requests .AddOtlpExporter(options => // Configure the OTLP exporter { options.Endpoint = new Uri("https://AXIOM_DOMAIN/v1/traces"); // Set the endpoint for the exporter options.Protocol = OpenTelemetry.Exporter.OtlpExportProtocol.HttpProtobuf; // Set the protocol options.Headers = "Authorization=Bearer API_TOKEN, X-Axiom-Dataset=DATASET_NAME"; // Update API token and dataset }) .Build(); // Build the tracer provider } // Method to start a new tracing activity with an optional activity kind public static Activity? StartActivity(string activityName, ActivityKind kind = ActivityKind.Internal) { // Starts and returns a new activity if sampling allows it, otherwise returns null return ActivitySource.StartActivity(activityName, kind); }}
You can send traces to Axiom using the OpenTelemetry Python SDK by configuring an OTLP HTTP exporter in your Python app. Here is a simple example:
python
from opentelemetry import tracefrom opentelemetry.sdk.trace import TracerProviderfrom opentelemetry.sdk.trace.export import BatchSpanProcessorfrom opentelemetry.sdk.resources import Resource, SERVICE_NAMEfrom opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter# Define the service name resource for the tracer.resource = Resource(attributes={ SERVICE_NAME: "NAME_OF_SERVICE" # Replace `NAME_OF_SERVICE` with the name of the service you want to trace.})# Create a TracerProvider with the defined resource for creating tracers.provider = TracerProvider(resource=resource)# Configure the OTLP/HTTP Span Exporter with Axiom headers and endpoint. Replace `API_TOKEN` with your Axiom API key, and replace `DATASET_NAME` with the name of the Axiom dataset where you want to send data.otlp_exporter = OTLPSpanExporter( endpoint="https://AXIOM_DOMAIN/v1/traces", headers={ "Authorization": "Bearer API_TOKEN", "X-Axiom-Dataset": "DATASET_NAME" })# Create a BatchSpanProcessor with the OTLP exporter to batch and send trace spans.processor = BatchSpanProcessor(otlp_exporter)provider.add_span_processor(processor)# Set the TracerProvider as the global tracer provider.trace.set_tracer_provider(provider)# Define a tracer for external use in different parts of the app.service1_tracer = trace.get_tracer("service1")
You can send traces to Axiom using the OpenTelemetry Node SDK by configuring an OTLP HTTP exporter in your Node app. Here is a simple example:
javascript
const opentelemetry = require('@opentelemetry/sdk-node');const { getNodeAutoInstrumentations } = require('@opentelemetry/auto-instrumentations-node');const { OTLPTraceExporter } = require('@opentelemetry/exporter-trace-otlp-proto');const { BatchSpanProcessor } = require('@opentelemetry/sdk-trace-base');const { Resource } = require('@opentelemetry/resources');const { SemanticResourceAttributes } = require('@opentelemetry/semantic-conventions');// Initialize OTLP trace exporter with the URL and headers for the Axiom APIconst traceExporter = new OTLPTraceExporter({ url: 'https://AXIOM_DOMAIN/v1/traces', // Axiom API endpoint for trace data headers: { 'Authorization': 'Bearer API_TOKEN', // Replace API_TOKEN with your actual API token 'X-Axiom-Dataset': 'DATASET_NAME' // Replace DATASET_NAME with your dataset },});// Define the resource attributes, in this case, setting the service name for the tracesconst resource = new Resource({ [SemanticResourceAttributes.SERVICE_NAME]: 'node traces', // Name for the tracing service});// Create a NodeSDK instance with the configured span processor, resource, and auto-instrumentationsconst sdk = new opentelemetry.NodeSDK({ spanProcessor: new BatchSpanProcessor(traceExporter), // Use BatchSpanProcessor for batching and sending traces resource: resource, // Attach the defined resource to provide additional context instrumentations: [getNodeAutoInstrumentations()], // Automatically instrument common Node.js modules});// Start the OpenTelemetry SDKsdk.start();
Configure OpenTelemetry in Cloudflare Workers to send telemetry data to Axiom using the OTel CF Worker package. Here is an example exporter configuration:
The Stream and Query tabs allow you to easily detect warnings and errors in your logs by highlighting the severity of log entries in different colors. As a prerequisite, specify the log level in the data you send to Axiom. For Open Telemetry logs, specify the log level in the following fields: