Interlace 1.0.0

dotnet add package Interlace --version 1.0.0
                    
NuGet\Install-Package Interlace -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Interlace" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Interlace" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Interlace" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Interlace --version 1.0.0
                    
#r "nuget: Interlace, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Interlace@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Interlace&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Interlace&version=1.0.0
                    
Install as a Cake Tool

Interlace

Interlace is a .NET library that eliminates hand-written observability code. You annotate your service interfaces with attributes, and at compile time Interlace generates the spans, metrics, wide events, and audit trails that would otherwise take dozens of lines per method.

[Observed(Layer = ObservabilityLayer.Service)]
public interface IOrderService
{
    [Metric(Name = "orders_placed", Type = MetricType.Counter)]
    [Audited(EventType = "OrderPlaced", CaptureResult = true)]
    Task<Order> PlaceOrderAsync(
        [CorrelationId] string orderId,
        [SpanAttribute(Name = "order.sku")] string sku,
        int quantity,
        [Sensitive] string paymentToken,
        CancellationToken ct = default);
}

Your implementation stays pure business logic:

public sealed class OrderService(IOrderRepository repository, IPricingService pricing) : IOrderService
{
    public async Task<Order> PlaceOrderAsync(string orderId, string sku, int quantity, string paymentToken, CancellationToken ct)
    {
        decimal unitPrice = await pricing.GetPriceAsync(sku, ct);
        Order order = new(orderId, sku, quantity, unitPrice);
        return await repository.InsertAsync(order, ct);
    }
}

From this single interface, Interlace generates interceptors that emit spans, operation/success/failure counters, a duration histogram, the custom orders_placed counter, an OrderPlaced audit event, wide event logs, and correlation context — with paymentToken excluded from every signal.

<details> <summary>Table of Contents</summary>

</details>

Requirements

  • .NET 10 SDK or later (C# 14 required for interceptor support)
  • An OpenTelemetry exporter package (e.g. OpenTelemetry.Exporter.Console for local development)

Getting Started

1. Add package references:

<ItemGroup>
  <PackageReference Include="Interlace" Version="1.0.0" />
  <PackageReference Include="Interlace.Analyzers" Version="1.0.0" PrivateAssets="all" />

  
  
  
</ItemGroup>

2. Add this to your .csproj or Directory.Build.props:

<PropertyGroup>
  <TelemetryAutoConfigureNamespace>true</TelemetryAutoConfigureNamespace>
</PropertyGroup>

This lets Interlace wire up the generated code automatically. See configuration for additional MSBuild properties.

3. Register runtime services in Program.cs:

using Interlace.Registration;

// Initializes the ActivitySource and Meter that generated interceptors use to emit spans and metrics.
// The names you choose here are how OpenTelemetry identifies which signals to collect —
// they must match what you pass to AddSource/AddMeter on the OTel side.
builder.Services.AddInterlace(options =>
{
    options.ActivitySourceName = "MyApp.Telemetry";
    options.MeterName = "MyApp.Telemetry";
});

// Optional: wire up OpenTelemetry exporters (uncomment the packages in step 1 first)
// builder.Services.AddOpenTelemetry()
//     .WithTracing(t => t.AddSource("MyApp.Telemetry").AddConsoleExporter())
//     .WithMetrics(m => m.AddMeter("MyApp.Telemetry").AddConsoleExporter());

4. Annotate your interfaces:

using Interlace.Annotations.Attributes;

[Observed(Layer = ObservabilityLayer.Service)]
public interface IOrderService
{
    Task PlaceOrderAsync(
        string orderId,
        [SpanAttribute(Name = "order.sku")] string sku,
        int quantity,
        CancellationToken ct = default);
}

Every call to IOrderService.PlaceOrderAsync through DI now gets a span, metrics, and wide events — regardless of which class implements it.

For a complete walkthrough see the getting started guide.

Packages

Package Purpose
Interlace Runtime services + telemetry attributes ([Observed], [Audited], [Metric], etc.)
Interlace.Analyzers Source generator + Roslyn analyzer + code fixes (compile-time only)

Attributes

Attribute Target Purpose
[Observed] Interface / Class Enable telemetry interception for a type
[ObservedEndpoint] Method HTTP endpoint instrumentation with route template
[ObservedJob] Class Background job instrumentation with max duration tracking
[Audited] Method Generate audit trail records
[AuditEntityId] Parameter Bind audit entity identifier
[Metric] Method Custom counter, histogram, or up-down counter
[MetricTag] Parameter Bind metric dimension from parameter
[MetricValue] Parameter Bind metric value from parameter
[SpanAttribute] Parameter Add span tag from parameter
[CorrelationId] Parameter Propagate correlation context
[Sensitive] Parameter Exclude from all telemetry capture
[NoTelemetry] Method Opt out of interception (requires reason)
[TelemetryOptions] Interface / Class / Method Toggle individual signal channels
[WideEvent] Method Configure wide event emission

Documentation

Getting Started Install, configure, and instrument your first service
Core Concepts How interface-first interception works
Attributes Reference All available telemetry attributes
Usage Guides Configuration, patterns, and troubleshooting
Diagnostics Analyzer rules (TEL001–TEL009) and fixes
Samples Runnable examples for each feature

Contributing

See CONTRIBUTING.md for development setup, build commands, and testing instructions.

License

See LICENSE for details.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
1.0.0 104 2/16/2026