Get deep insight into your applications on your local development environment.
Full support for OpenTelemetry across a wide range of programming languages and frameworks including Python, Java, JavaScript, Ruby, Rust, .NET, Swift, and so much more!
Install and setup OpenTelemetry in your app.
// Getting Started Doc: https://opentelemetry.io/docs/languages/python/getting-started/
// Use gRPC OTEL Exporter: https://opentelemetry.io/docs/languages/python/exporters/#otlp-dependencies
# 1. Update requirements.txt
opentelemetry-distro
opentelemetry-exporter-otlp-proto-grpc
# 2. Use gRPC exporter for OTLP
from opentelemetry.sdk.resources import SERVICE_NAME, Resource
from opentelemetry import trace
from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor
from opentelemetry import metrics
from opentelemetry.exporter.otlp.proto.grpc.metric_exporter import OTLPMetricExporter
from opentelemetry.sdk.metrics import MeterProvider
from opentelemetry.sdk.metrics.export import PeriodicExportingMetricReader
from opentelemetry._logs import set_logger_provider
from opentelemetry.exporter.otlp.proto.grpc._log_exporter import (
OTLPLogExporter,
)
from opentelemetry.sdk._logs import LoggerProvider, LoggingHandler
from opentelemetry.sdk._logs.export import BatchLogRecordProcessor
from opentelemetry.sdk.resources import Resource
def configure_otel_otlp(service_name: str = "my-python-app", endpoint: str = "http://localhost:4317", insecure=True):
# Service name is required for most backends
resource = Resource(attributes={
SERVICE_NAME: service_name
})
# Configure Tracing
traceProvider = TracerProvider(resource=resource)
processor = BatchSpanProcessor(OTLPSpanExporter(endpoint=endpoint, insecure=insecure))
traceProvider.add_span_processor(processor)
trace.set_tracer_provider(traceProvider)
# Configure Metrics
reader = PeriodicExportingMetricReader(
OTLPMetricExporter(endpoint=endpoint, insecure=insecure)
)
meterProvider = MeterProvider(resource=resource, metric_readers=[reader])
metrics.set_meter_provider(meterProvider)
# Configure Logging
logger_provider = LoggerProvider(
resource=resource
)
set_logger_provider(logger_provider)
exporter = OTLPLogExporter(insecure=insecure)
logger_provider.add_log_record_processor(BatchLogRecordProcessor(exporter))
handler = LoggingHandler(level=logging.NOTSET, logger_provider=logger_provider)
# Attach OTLP handler to root logger
logging.getLogger().addHandler(handler)
# 3. Update application entry
from flask import Flask
from opentelemetry.instrumentation.flask import FlaskInstrumentor
from otel_grpc import configure_otel_otlp
app = Flask(__name__)
configure_otel_otlp()
FlaskInstrumentor().instrument_app(app)
Install and setup OpenTelemetry in your app.
// Getting Started Doc: https://opentelemetry.io/docs/languages/js/getting-started/nodejs/
// Use gRPC OTEL Exporter: https://opentelemetry.io/docs/languages/js/exporters/#otlp-dependencies
// 1. Install following dependencies
npm install @opentelemetry/sdk-node \
@opentelemetry/api \
@opentelemetry/auto-instrumentations-node \
@opentelemetry/sdk-metrics \
@opentelemetry/sdk-trace-node \
@opentelemetry/exporter-trace-otlp-grpc \
@opentelemetry/exporter-metrics-otlp-grpc
// create instrumentation.js
/*instrumentation.js*/
const opentelemetry = require('@opentelemetry/sdk-node');
const { getNodeAutoInstrumentations,} = require('@opentelemetry/auto-instrumentations-node');
const { OTLPTraceExporter } = require('@opentelemetry/exporter-trace-otlp-grpc');
const { OTLPMetricExporter} = require('@opentelemetry/exporter-metrics-otlp-grpc');
const { PeriodicExportingMetricReader } = require('@opentelemetry/sdk-metrics');
const { Resource } = require('@opentelemetry/resources');
const { SEMRESATTRS_SERVICE_NAME, SEMRESATTRS_SERVICE_VERSION } = require('@opentelemetry/semantic-conventions');
const sdk = new opentelemetry.NodeSDK({
traceExporter: new OTLPTraceExporter(),
metricReader: new PeriodicExportingMetricReader({
exporter: new OTLPMetricExporter(),
}),
instrumentations: [getNodeAutoInstrumentations()],
resource: new Resource({
[SEMRESATTRS_SERVICE_NAME]: 'my-nodejs-app',
[SEMRESATTRS_SERVICE_VERSION]: '0.1.0',
}),
});
sdk.start();
// start app: node --require ./instrumentation.js app.js
// sample code: https://github.com/aspire-dashboard/express-sample
Install and setup OpenTelemetry in your app.
// Getting Started Doc: https://opentelemetry.io/docs/languages/java/getting-started/
// Use gRPC OTEL Exporter: https://opentelemetry.io/docs/languages/java/exporters/#otlp-dependencies
// 1. Insall dependencies
//Gradle:
dependencies {
implementation 'io.opentelemetry:opentelemetry-exporter-otlp:1.39.0'
}
// 2. Configure exporter
env OTEL_EXPORTER_OTLP_ENDPOINT=http://example:4317 java -jar ./build/libs/java-simple.jar
// 3. Integrate with your application
package otel;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.Banner;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.trace.propagation.W3CTraceContextPropagator;
import io.opentelemetry.context.propagation.ContextPropagators;
import io.opentelemetry.exporter.otlp.metrics.OtlpGrpcMetricExporter;
import io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporter;
import io.opentelemetry.exporter.otlp.logs.OtlpGrpcLogRecordExporter;
import io.opentelemetry.sdk.OpenTelemetrySdk;
import io.opentelemetry.sdk.metrics.SdkMeterProvider;
import io.opentelemetry.sdk.metrics.export.PeriodicMetricReader;
import io.opentelemetry.sdk.resources.Resource;
import io.opentelemetry.sdk.trace.SdkTracerProvider;
import io.opentelemetry.sdk.trace.export.BatchSpanProcessor;
import io.opentelemetry.sdk.logs.export.BatchLogRecordProcessor;
import io.opentelemetry.sdk.logs.SdkLoggerProvider;
import io.opentelemetry.sdk.logs.export.LogRecordExporter;
import io.opentelemetry.semconv.resource.attributes.ResourceAttributes;
@SpringBootApplication
public class DiceApplication {
public static void main(String[] args) {
SpringApplication app = new SpringApplication(DiceApplication.class);
app.setBannerMode(Banner.Mode.OFF);
app.run(args);
}
@Bean
public OpenTelemetry openTelemetry() {
Resource resource = Resource.getDefault().toBuilder().put(SERVICE_NAME, "dice-server").put(SERVICE_VERSION, "0.1.0").build();
SdkTracerProvider sdkTracerProvider = SdkTracerProvider.builder()
.addSpanProcessor(BatchSpanProcessor.builder(OtlpGrpcSpanExporter.builder().build()).build())
.setResource(resource)
.build();
SdkMeterProvider sdkMeterProvider = SdkMeterProvider.builder()
.registerMetricReader(PeriodicMetricReader.builder(OtlpGrpcMetricExporter.builder().build()).build())
.setResource(resource)
.build();
SdkLoggerProvider sdkLoggerProvider = SdkLoggerProvider.builder()
.addLogRecordProcessor(
BatchLogRecordProcessor.builder(OtlpGrpcLogRecordExporter.builder().build()).build())
.setResource(resource)
.build();
OpenTelemetry openTelemetry = OpenTelemetrySdk.builder()
.setTracerProvider(sdkTracerProvider)
.setMeterProvider(sdkMeterProvider)
.setLoggerProvider(sdkLoggerProvider)
.setPropagators(ContextPropagators.create(W3CTraceContextPropagator.getInstance()))
.buildAndRegisterGlobal();
return openTelemetry;
}
}
Install and setup OpenTelemetry in your app.
// Getting Started Doc: https://opentelemetry.io/docs/languages/net/getting-started/
// Use gRPC OTEL Exporter: https://opentelemetry.io/docs/languages/net/exporters/#otlp-dependencies
// 1. Install OpenTelemetry NuGet Packages
dotnet add package OpenTelemetry.Exporter.OpenTelemetryProtocol
dotnet add package OpenTelemetry.Extensions.Hosting
dotnet add package OpenTelemetry.Instrumentation.Http
dotnet add package OpenTelemetry.Instrumentation.Runtime
// 2. Optional Hosting Extensions
dotnet add package Microsoft.Extensions.Hosting
// 3. Add configuration endpoint in environment variables
"OTEL_EXPORTER_OTLP_ENDPOINT": "http://localhost:4317"
// 4. Configure open telemetry in your app
using ConsoleApp;
using OpenTelemetry;
using OpenTelemetry.Metrics;
using OpenTelemetry.Resources;
using OpenTelemetry.Trace;
var builder = Host.CreateApplicationBuilder(args);
ConfigureOpenTelemetry(builder);
var host = builder.Build();
host.Run();
static IHostApplicationBuilder ConfigureOpenTelemetry(IHostApplicationBuilder builder)
{
builder.Logging.AddOpenTelemetry(logging =>
{
logging.IncludeFormattedMessage = true;
logging.IncludeScopes = true;
});
builder.Services.AddOpenTelemetry()
.ConfigureResource(c => c.AddService("MyApp"))
.WithMetrics(metrics =>
{
metrics.AddHttpClientInstrumentation()
.AddRuntimeInstrumentation();
})
.WithTracing(tracing =>
{
tracing.AddHttpClientInstrumentation();
});
// Use the OTLP exporter if the endpoint is configured.
var useOtlpExporter = !string.IsNullOrWhiteSpace(builder.Configuration["OTEL_EXPORTER_OTLP_ENDPOINT"]);
if (useOtlpExporter)
{
builder.Services.AddOpenTelemetry().UseOtlpExporter();
}
return builder;
}
// Sample: https://github.com/aspire-dashboard/dotnet-sample
Developers across the globe trust the Aspire Dashboard to get mission critical information while they are developing their applications. The Aspire Dashboard is free, open-source, and constantly adding new features based on your feedback.
Container Pulls
Forks
Clones (monthly)
GitHub Stars