.NET SDK

Semantic Kernel

One call flips Semantic Kernel's GenAI diagnostics, subscribes a TracerProvider to every SK activity source, and attaches the axonpush exporter.

Install

dotnet add package AxonPush.SemanticKernel

Add the telemetry layer

using Microsoft.Extensions.DependencyInjection;
using Microsoft.SemanticKernel;
using OpenTelemetry.Trace;
using AxonPush.SemanticKernel;

var builder = Kernel.CreateBuilder();
builder.AddAzureOpenAIChatCompletion("gpt-4o-mini", endpoint, apiKey);

builder.AddAxonPushTelemetry(
    client => { client.ApiKey = "ak_..."; client.TenantId = "..."; client.Environment = "production"; },
    exporter => { exporter.ChannelId = "..."; });

var kernel = builder.Build();
using var tracerProvider = kernel.Services.GetRequiredService<TracerProvider>();

The TracerProvider is registered as a lazy singleton, so resolve it once after building, otherwise nothing subscribes to the Semantic Kernel sources. Disposing it on shutdown flushes buffered spans. With Host.CreateApplicationBuilder, call builder.Services.AddAxonPushTelemetryForSemanticKernel(...) instead and resolve TracerProvider from host.Services.

Set the environment on the client options (sent as the X-Axonpush-Environment header). The exporter’s own Environment option is written into the event body, which the current API rejects.

Run it

Traces appear while the run is still going.

What that one call does

  1. Flips Semantic Kernel’s GenAI diagnostic switch, so the kernel emits OpenTelemetry spans for chat completions, function calls and prompt rendering. Off by default in SK.
  2. Registers a TracerProvider subscribed to every Microsoft.SemanticKernel* activity source.
  3. Attaches the axonpush span exporter, batched in the background.

Prompts and completions

Off unless you ask for it

Prompt and completion text is not forwarded by default. Pass enableSensitiveData: true to include them as span events:

builder.AddAxonPushTelemetry(
    client => { /* … */ },
    exporter => { /* … */ },
    enableSensitiveData: true);

The default is off so that PII does not leave the process without an explicit decision to send it.

Which spans you get

With the GenAI switch on, Semantic Kernel emits spans on:

  • Microsoft.SemanticKernel, kernel function invocations
  • Microsoft.SemanticKernel.Connectors.OpenAI and …Connectors.AzureOpenAI, chat completion calls
  • Connector-specific sources for embeddings, image generation and other AI services as they ship

Spans carry the OpenTelemetry GenAI semantic-convention attributes, gen_ai.system, gen_ai.request.model, gen_ai.usage.input_tokens, gen_ai.usage.output_tokens, gen_ai.response.finish_reasons and the rest. axonpush stores them verbatim, so a dashboard built against Python LangChain runs applies to Semantic Kernel runs without changes.

A working sample

samples/SemanticKernelChat in the SDK repository is an end-to-end console REPL against Azure OpenAI, with an inline GetTime kernel function so you get function-call spans as well as completions.