XiansAi.Otel.Lib 1.0.1

dotnet add package XiansAi.Otel.Lib --version 1.0.1
                    
NuGet\Install-Package XiansAi.Otel.Lib -Version 1.0.1
                    
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="XiansAi.Otel.Lib" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="XiansAi.Otel.Lib" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="XiansAi.Otel.Lib" />
                    
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 XiansAi.Otel.Lib --version 1.0.1
                    
#r "nuget: XiansAi.Otel.Lib, 1.0.1"
                    
#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 XiansAi.Otel.Lib@1.0.1
                    
#: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=XiansAi.Otel.Lib&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=XiansAi.Otel.Lib&version=1.0.1
                    
Install as a Cake Tool

XiansAi.Otel.Lib

XiansAi.Otel.Lib initializes OpenTelemetry (traces, metrics, logs) for agents/worker-style .NET processes and exports them via OTLP. Enablement is endpoint-driven (OPENTELEMETRY_ENDPOINT for traces/metrics, optional OPENTELEMETRY_LOGS_ENDPOINT for logs). It is designed to work with XiansAi agents but can be used by any .NET app that wants OTEL-compatible exports.

Install

dotnet add package XiansAi.Otel.Lib

Automatically captured (out of the box)

  • Traces: outgoing HTTP via HttpClient (spans + trace propagation)
  • Metrics: runtime + HttpClient metrics
  • Logs: Microsoft.Extensions.Logging logs via OTLP (when you use the ILoggerFactory returned by TelemetryBuilder.InitializeAgent(...))
  • Temporal traces: captured if Temporalio.Extensions.OpenTelemetry is used by the host and the Temporal interceptor is enabled (XiansAi.Lib wires this; generic apps must enable it themselves)
  • Your own spans: captured if your code emits Activity spans and you include your ActivitySource name/pattern in additionalActivitySources

GenAI sensitive content events (optional)

If you want Semantic Kernel to include prompt/response content in gen_ai.* events (e.g. gen_ai.event.content), set:

  • OPENTELEMETRY_GENAI_SENSITIVE=true

This is off by default because it can capture sensitive data.

Example 1 — Add to a XiansAi agent

In your agent’s Program.cs (after creating AgentTeam), initialize OTEL with tenant-aware service name:

using XiansAi.Flow;
using XiansAi.Otel;
using Microsoft.Extensions.Logging;

var agent = new AgentTeam("News Agent");

var loggerFactory = TelemetryBuilder.InitializeAgent(
    tenantId: AgentContext.TenantId,
    serviceName: agent.Name,
    enableLogs: true);

if (loggerFactory != null)
{
    Globals.LogFactory = loggerFactory;
}

await agent.RunAsync();

Example 2 — Add to a generic .NET app

In any console/worker app:

using XiansAi.Otel;

TelemetryBuilder.InitializeAgent(
    tenantId: "tenant-01",
    serviceName: "abcd.company01",
    additionalActivitySources: new[] { "Sample.SomePackage*" },
    additionalMeters: new[] { "Sample.SomePackage*" },
    enableLogs: true);

Example (manual spans via ActivitySource)

If you want spans for your own code (e.g. in a package like Sample.SomePackage.*), create an ActivitySource and start activities:

using System.Diagnostics;

namespace Sample.SomePackage;

public static class Telemetry
{
    public static readonly ActivitySource Source = new("Sample.SomePackage");
}

public static class Example
{
    public static void FuncB()
    {
        using var span = Telemetry.Source.StartActivity("FuncB");
        // do work...
    }

    public static void FuncA()
    {
        using var span = Telemetry.Source.StartActivity("FuncA");
        FuncB();
    }
}

To export these spans, pass your source name/pattern via additionalActivitySources to TelemetryBuilder.InitializeAgent(...).

Instrumentation sources/meters configuration

This library ships a default list via an embedded JSON: Defaults/otel-defaults.json. To add more sources/meters, pass additionalActivitySources / additionalMeters to TelemetryBuilder.InitializeAgent(...).

Package metadata

  • Package ID: XiansAi.Otel.Lib
  • Target framework: net9.0
  • NuGet package includes README.md and LICENSE

Release and publish

Publishing is automated with GitHub Actions.

  • Trigger: push a tag in the format v* (for example v1.2.3)
  • Version source: tag value without the v prefix
  • Feed: https://api.nuget.org/v3/index.json
  • Credential: repository secret NUGET_API_KEY

The resulting artifact pushed to NuGet is:

XiansAi.Otel.Lib.<version>.nupkg

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  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. 
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.1 69 3/23/2026
1.0.0 89 3/23/2026