Skip to content

ChatCompletionActivityMode

NexusLabs.Needlr.AgentFramework

NexusLabs.Needlr.AgentFramework.Diagnostics

ChatCompletionActivityMode Enum

Controls how Needlr's diagnostics middleware creates System.Diagnostics.Activity spans for chat completion calls.

public enum ChatCompletionActivityMode

Fields

Always 0

Always create a Needlr agent.chat activity, regardless of whether a parent gen_ai.* activity already exists. This is the default and is appropriate when Needlr is the only OTel instrumentation layer.

EnrichParent 1

When a parent System.Diagnostics.Activity with a gen_ai.-prefixed operation name exists (from MEAI's UseOpenTelemetry() or MAF's WithOpenTelemetry()), add Needlr-specific tags to that activity instead of creating a new one. When no such parent exists, create the activity as normal.

Remarks

Use this mode when both Needlr diagnostics and upstream OTel middleware are active to avoid duplicate spans for the same chat completion call. Metrics (counters, histograms) and in-process diagnostics recording are unaffected — only the System.Diagnostics.Activity creation is suppressed.