drupal/ai_observability_opentel_recipe

Enables Drupal AI observability + OpenTelemetry and points them at an OTLP collector (pairs with the ddev-drupal-ai-observability DDEV add-on). No AI provider, no agents.

Maintainers

Package info

git.drupalcode.org/project/ai_observability_opentel_recipe.git

Type:drupal-recipe

pkg:composer/drupal/ai_observability_opentel_recipe

Transparency log

Statistics

Installs: 7

Dependents: 0

Suggesters: 0

1.0.0-alpha3 2026-07-20 13:14 UTC

This package is auto-updated.

Last update: 2026-07-28 15:57:40 UTC


README

Enables and configures the Drupal-side half of the AI observability setup:

  • Modules: ai + ai_observability, opentelemetry + opentelemetry_metrics + opentelemetry_logs.
  • Config: points opentelemetry.settings at the OTLP collector (http://grafana-alloy:4318, http/protobuf) and switches on ai_observability's OpenTelemetry export (spans + metrics).

It pairs with the ddev-drupal-ai-observability DDEV add-on, which provides the receiving Grafana/Tempo/Mimir/Loki/Alloy stack and the dashboards. Install the add-on first; then every AI request your site makes shows up in Grafana.

What it deliberately does NOT do

  • No AI provider — install and configure one yourself (e.g. drupal/ai_provider_openai) including its API key (use the Key module with an env-var provider; never commit keys).
  • No agents — the agent dashboards light up once you install drupal/ai_agents (≥ 1.4) and create agents; nothing here depends on it.
  • No prompt/response storageotel_spans_store_input/_output stay off (privacy default). The Grafana Message flow panel needs them:

    drush cset ai_observability.settings otel_spans_store_input true -y
    drush cset ai_observability.settings otel_spans_store_output true -y
    

    ⚠️ This stores prompt/response text (truncated ~1 KB) in your traces.

Zero-to-running with the one-line installer

This repo ships a .drupalaibp/ directory for the one_line_installer (drupalaibp) with two named configs that build the whole project — DDEV + Drupal + the ddev-drupal-ai-observability Grafana stack + this recipe:

--configWhat it builds
baseThe observability pipeline only. No AI provider, by design — pick your own; the first request it makes shows up traced, metered, and priced in Grafana.
demoEverything in base plus AI API Explorer + AI Agents, prompts for OpenAI / Anthropic / Gemini / Mistral / Fireworks keys (each optional — blank skips that provider entirely), and creates a demo agent + subagent so the AI Agent Sessions dashboard has a parent → subagent trace to show.
# Grab the .drupalaibp/ configs into a fresh launch directory:
git clone https://git.drupalcode.org/project/ai_observability_opentel_recipe.git
mkdir my-ai-site && cp -a ai_observability_opentel_recipe/.drupalaibp my-ai-site/
cd my-ai-site

# Build the base observability site …
bash <(curl -fsSL https://project.pages.drupalcode.org/one_line_installer/drupalaibp) --config base
# … or the full provider + demo-agent build:
bash <(curl -fsSL https://project.pages.drupalcode.org/one_line_installer/drupalaibp) --config demo

Because there is more than one config, you must name one with --config (a bare run picks interactively). After a demo build, populate the dashboard:

ddev drush agents:run observability_demo_agent   # type a topic e.g. "sea otters", Ctrl+C to exit

How the two configs are wired

  • .drupalaibp/base.json / .drupalaibp/demo.json — the named configs.
  • .drupalaibp/setup_demo.sh — a provision_from_config_done hook (demo only, runs in the web container). For each provider whose key you entered it composer requires the module, enables it, creates a Key entity (env provider — the key value stays in .ddev/.env, never in config), points <module>.settings:api_key at it, then sets a default chat model from the first configured provider. It also creates the two demo agents via drush. Providers with a blank key are skipped entirely.
ProviderQuestion env varModuleProvider id
OpenAIOPENAI_API_KEYai_provider_openaiopenai
AnthropicANTHROPIC_API_KEYai_provider_anthropicanthropic
Google GeminiGEMINI_API_KEYgemini_providergemini
MistralMISTRAL_API_KEYai_provider_mistralmistral
Fireworks AIFIREWORKSAI_API_KEYfireworksaifireworks

Apply (recipe only, on an existing site)

The modules must be present in the codebase first (recipes don't run Composer):

ddev composer require drupal/ai_observability_opentel_recipe
ddev drush recipe:apply /var/www/html/recipes/ai_observability_opentel_recipe
ddev drush cr

(Requiring the recipe via Composer pulls drupal/ai and drupal/opentelemetry in for you — its composer.json declares both.)

After applying

  1. Install + configure an AI provider and set default models at /admin/config/ai/settings.
  2. Make an AI call — then open Grafana at https://<project>.ddev.site:3000 and check the AI Requests — Overview dashboard.
  3. Optional: drupal/ai_agents for the agent-session dashboards, and ddev sync-model-prices for live cost pricing.

Customizing the endpoint

Not on DDEV / different collector? Override after applying:

drush cset opentelemetry.settings endpoint 'http://my-collector:4318' -y