Skip to content

feat: Add observability examples to .NET examples repo#8

Draft
jsonbailey wants to merge 1 commit into
mainfrom
jb/sdk-2665/observability-examples
Draft

feat: Add observability examples to .NET examples repo#8
jsonbailey wants to merge 1 commit into
mainfrom
jb/sdk-2665/observability-examples

Conversation

@jsonbailey

@jsonbailey jsonbailey commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Adds examples demonstrating the LaunchDarkly.Observability plugin. Resolves SDK-2665.

What's included

New console example — server-sdk/features/plugins/observability

Based on the getting-started HelloDotNet example, with the observability plugin added:

  • Registers ObservabilityPlugin on the SDK configuration via PluginConfigurationBuilder.
  • Hosts the plugin's OpenTelemetry exporters in a console app with Host.CreateApplicationBuilder, blocking on WaitForShutdown so Ctrl+C shuts down cleanly and flushes telemetry.
  • Creates spans manually with Observe.StartActivity — a console app has no framework auto-instrumentation, so spans must be created explicitly.
  • Records a custom metric (Observe.RecordIncr) and a structured log (Observe.RecordLog) per evaluation and flag change.

OpenAI chat-completions example — server-sdk-ai/frameworks/openai/chat-completions

  • Registers the observability plugin alongside the existing AI SDK usage.
  • Sets OPENAI_EXPERIMENTAL_ENABLE_OPEN_TELEMETRY=true so the OpenAI SDK emits OpenTelemetry.
  • Registers the OpenAI SDK's OpenAI.ChatClient activity source and meter with the plugin so the model call's spans and gen_ai.* token-usage metrics export to LaunchDarkly.

Also updates server-sdk/README.md with a Features table entry for the new example.

Verification

  • Both projects build cleanly (dotnet build).
  • Telemetry (traces, logs, and metrics — including OpenAI gen_ai.* spans/metrics) confirmed exporting to a local OTLP sink.
  • The console example exits cleanly on Ctrl+C / SIGTERM.

Add a standalone console example under server-sdk/features/plugins/observability
demonstrating the LaunchDarkly.Observability plugin (custom spans, metrics, and
logs), and add the observability plugin to the OpenAI chat-completions AI
framework example with OpenAI's experimental OpenTelemetry enabled.

SDK-2665
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant