Observator 0.1.0-preview3
dotnet add package Observator --version 0.1.0-preview3
NuGet\Install-Package Observator -Version 0.1.0-preview3
<PackageReference Include="Observator" Version="0.1.0-preview3" />
<PackageVersion Include="Observator" Version="0.1.0-preview3" />
<PackageReference Include="Observator" />
paket add Observator --version 0.1.0-preview3
#r "nuget: Observator, 0.1.0-preview3"
#addin nuget:?package=Observator&version=0.1.0-preview3&prerelease
#tool nuget:?package=Observator&version=0.1.0-preview3&prerelease
Observator: Zero-Effort .NET Observability
Observator is an AOT-compatible source generator that automatically instruments .NET assemblies with OpenTelemetry tracing, logging, and metrics capabilities. It uses compile-time code generation and interceptors to provide zero-configuration, high-performance observability instrumentation that works seamlessly with modern .NET applications, including those using Native AOT compilation.
Features
- AOT-First Design: Full compatibility with Native AOT compilation by eliminating runtime reflection.
- Zero Dependencies: Only references
System.Diagnostics.DiagnosticSource
, which is built into .NET. - Zero Configuration: Works out-of-the-box with sensible defaults.
- Attribute-Driven Instrumentation: Enable selective instrumentation by decorating methods, classes, or interfaces with a simple
[ObservatorTrace]
attribute. - Cross-Assembly Compatibility: Supports instrumentation across project boundaries within a solution.
- High Performance: Generates optimized code that adds minimal overhead to instrumented methods.
- Standards Compliant: Generates code compatible with OpenTelemetry standards and .NET diagnostic conventions.
Getting Started
Installation
Add the Observator NuGet package to your project:
dotnet add package Observator
Usage
Add the
[ObservatorTrace]
attribute to any method, class, or interface you want to instrument. For classes and interfaces, all public instance methods will be traced.- Note: You cannot use
[ObservatorTrace]
on both a class and its methods at the same time. If both are present, a compile-time error will be emitted.
using Observator; namespace MyAwesomeApp; // Class-level usage (all methods instrumented) [ObservatorTrace] public class MyService { public virtual string Greet(string name) { return $"Hello, {name}!"; } } // Method-level usage (only this method instrumented) public class MyOtherService { [ObservatorTrace] public string OnlyThisIsTraced() => "Traced!"; } // Error: Do not combine class-level and method-level attributes [ObservatorTrace] public class InvalidService { [ObservatorTrace] // This will cause a compile-time error public void Conflict() { } }
- Note: You cannot use
Configure your OpenTelemetry pipeline to listen to the
ActivitySource
created by Observator.using OpenTelemetry; using OpenTelemetry.Trace; using Observator.Generated.MyAwesomeApp; // Import the generated namespace public class Program { public static void Main(string[] args) { using var tracerProvider = Sdk.CreateTracerProviderBuilder() .AddSource(ObservatorInfrastructure.ActivitySourceName) .AddConsoleExporter() // Or your preferred exporter .Build(); var myService = new MyAwesomeApp.MyService(); myService.Greet("World"); } }
Building from Source
To build the project from source, you will need the .NET 9 SDK.
- Clone the repository:
git clone https://github.com/psimsa/observator.git
- Navigate to the project directory:
cd observator
- Build the solution:
dotnet build
License
This project is licensed under the MIT License. See the LICENSE file for details.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
0.1.0-preview3 | 107 | 7/1/2025 |
0.1.0-preview2 | 102 | 6/30/2025 |