Overview
The Intent.OpenTelemetry module provides a comprehensive framework for integrating observability into your ASP.NET Core applications. With OpenTelemetry, you can collect and export telemetry data — including traces, metrics, and logs — to various observability backends, enhancing your ability to monitor application performance and diagnose issues.What is OpenTelemetry?
OpenTelemetry is an open-source initiative for creating universal standards for telemetry data collection, including distributed tracing, metrics, and logging. By implementing OpenTelemetry, you gain valuable insights into how your system behaves in real time.Why Use OpenTelemetry?
Applying OpenTelemetry in your applications allows you to:Improve Performance Monitoring
Track and visualize request paths, system performance, and infrastructure health across distributed services.
Support Error Diagnosis
Identify where errors occur and understand the context in which they happen, including full request traces.
Visualize Metrics
Gain insights into application performance metrics over time, such as request latency, error rates, and throughput.
Vendor-Neutral
Use open standards to avoid vendor lock-in. Switch between observability platforms without code changes.
What Gets Generated
OpenTelemetry Configuration Class
A complete configuration class that sets up telemetry collection:Infrastructure/Configuration/OpenTelemetryConfiguration.cs
Application Settings Configuration
Configuration entries inappsettings.json:
appsettings.json
Startup Integration
Automatic registration inProgram.cs:
Program.cs
Installation
Prerequisites
- An ASP.NET Core application in Intent Architect
- An observability backend (Azure Application Insights, Aspire Dashboard, Jaeger, etc.)
Installation Steps
Install the module
In Intent Architect, right-click on your application and select Manage Modules. Search for
Intent.OpenTelemetry and install it.Configure export options
In Application Settings, navigate to OpenTelemetry and select your export destination.
Configuration
Export Options
The module supports multiple export destinations:Azure Application Insights
Directly send telemetry to Azure Application Insights with native integration and Live Metrics support.
Azure Monitor Distro
Use the Azure-specific OpenTelemetry distribution for enhanced compatibility and Azure-native features.
OpenTelemetry Protocol (OTLP)
Export to any OTLP-compatible backend (Jaeger, Prometheus, Grafana, Aspire Dashboard, etc.).
Console
Log telemetry to the console for debugging or local development.
Telemetry Types
Configure what telemetry to capture:- Capture Traces: Monitor the journey of requests through your application with distributed tracing
- Capture Metrics: Collect performance metrics like request counts, error rates, and latencies
- Capture Logs: Integrate logs as part of your telemetry data, linking them to traces
Application Settings Configuration
Navigate to Application Settings → OpenTelemetry to configure:- Export Method - Choose your observability backend
- Capture Traces - Enable/disable distributed tracing
- Capture Metrics - Enable/disable metrics collection
- Capture Logs - Enable/disable log integration
- Instrumentation Options:
- ASP.NET Core (HTTP requests, middleware)
- HTTP Client (outbound HTTP calls)
- SQL Client (database queries)
- Process metrics (CPU, memory)
- .NET Runtime metrics (GC, threading)
Usage Examples
Azure Application Insights
Configuration:appsettings.json
- Application Map: Visual representation of service dependencies
- Transaction details: End-to-end request traces across microservices
- Live Metrics: Real-time performance monitoring
- Logs correlation: Logs linked to specific traces via Trace ID
Aspire Dashboard (Local Development)
Trace ID in Error Responses
When errors occur, the Trace ID is returned in the response for easy lookup:HTTP 500 Response
Distributed Tracing Example
Consider a microservices architecture with three services:- API Gateway receives the request
- Order Service processes the order
- Inventory Service checks stock availability
Advanced Scenarios
Custom Spans
Add custom instrumentation to your code:Custom Metrics
Create application-specific metrics:Best Practices
Use Semantic Conventions
Follow OpenTelemetry semantic conventions for span names and attributes for consistency.
Sample in Production
Use sampling strategies to reduce telemetry volume in high-traffic production environments.
Correlate Logs and Traces
Always include Trace ID in logs to correlate log messages with distributed traces.
Monitor APM Costs
Be aware of telemetry ingestion costs, especially with cloud-based APM solutions.
Performance Considerations
- Instrumentation overhead is typically < 5% for most applications
- Use head-based sampling for high-throughput APIs
- Export asynchronously to avoid blocking request processing
- Batch telemetry data to reduce network overhead
Integration with Other Modules
Serilog
Logs are automatically included in traces when using Serilog with OpenTelemetry.
Entity Framework Core
SQL queries are traced automatically with the SQL Client instrumentation.
MassTransit
Message processing is traced across service boundaries in event-driven architectures.
HTTP Clients
Outbound HTTP calls are traced automatically with context propagation.
Troubleshooting
No Telemetry Appearing
Check configuration:- Verify the endpoint URL is correct and accessible
- Ensure the export protocol matches your backend (Grpc vs. HttpProtobuf)
- Check that the service name is configured
High Memory Usage
Reduce instrumentation:- Disable unused instrumentations (Process, Runtime if not needed)
- Implement sampling for traces
- Reduce metric collection interval
Missing Database Queries
Enable SQL instrumentation: Ensure “SQL Instrumentation” is enabled in Application Settings → OpenTelemetry configuration.Related Resources
Next Steps
Serilog
Add structured logging to your application
Health Checks
Monitor application health endpoints
Azure Pipelines
Monitor deployments with telemetry

