Search by

lakedrops / drupal-environment

jurgenhaas

Composer Plugin for Drupal Environments

Package info

gitlab.lakedrops.com/composer/plugin/drupal-environment

Issues

Documentation

Type:composer-plugin

pkg:composer/lakedrops/drupal-environment

Statistics

Installs: 46 941

Dependents: 4

Suggesters: 0

v3.2.269 2026-12-05 09:45 UTC

This package is auto-updated.

Last update: 2026-12-05 09:46:11 UTC


README

Composer plugin that creates the directory structure and the settings files (settings.php, settings.local.php, services.yml, development.services.yml) of LakeDrops Drupal projects at composer install and with composer lakedrops:config. General documentation: https://devops-tools.docs.lakedrops.com/composer/plugin/drupal-environment/.

OpenTelemetry

When OPENTELEMETRY_ENDPOINT is set while the settings are rendered, settings.local.php configures the drupal/opentelemetry module:

SettingSource
endpointOPENTELEMETRY_ENDPOINT
authorizationOPENTELEMETRY_AUTH
service_nameDrupal: <CI_PROJECT_NAME> (<CI_COMMIT_BRANCH>) in CI, Drupal: <COMPOSE_PROJECT_NAME> (<USER>@<host>) locally

It also sets OTEL_RESOURCE_ATTRIBUTES, so that the OpenTelemetry SDK puts these resource attributes on every log record, span and metric the module and its submodules opentelemetry_logs and opentelemetry_metrics export:

AttributeValueMissing when
service.versionCI_COMMIT_SHA, the commit the site was built fromoutside CI
deployment.environment.nameCI_COMMIT_BRANCH, local outside CIa CI build without a branch, e.g. of a tag
vcs.repository.url.fullCI_PROJECT_URL, the GitLab projectoutside CI
host.namethe physical host the site runs on, see belowthe host is unknown; the SDK then reports the container ID
container.idthe container ID, at runtimehost.name is missing
drupal.core.version\Drupal::VERSION, at runtimenever

The values are percent-encoded as the OpenTelemetry specification requires. OpenObserve stores the attributes with underscores instead of dots, e.g. service_version on logs and service_service_version on traces.

host.name comes from the first of these that is set:

  1. OPENTELEMETRY_HOST_NAME, an explicit override.
  2. The project topic runner_<host> in CI_PROJECT_TOPICS: the deploy runners of a host take the jobs of the projects with that topic. Only exactly one runner_* topic counts.

The settings are rendered in the build job, which does not run on the host the site is deployed to, so the plugin does not read the host name of the machine it runs on. The variable HOST_NAME of some projects' CI configuration is not used either: deployments do not read it, and it is not always the host the site runs on.

Export timeout

settings.local.php also sets OTEL_EXPORTER_OTLP_TIMEOUT, the time in milliseconds that one attempt to export traces, logs or metrics may take: 1500 ms by default instead of the SDK's 10 000 ms. The module exports when the request terminates, after the response is sent, but the PHP-FPM worker stays busy until the export ends, and the exporter tries up to 4 times. With the collector unreachable, an export then holds the worker for about 7 s instead of 40 s.

Override the default with the variable OPENTELEMETRY_TIMEOUT while the settings are rendered, or in the project's .lakedrops.yml, which takes precedence:

lakedrops:
  opentelemetry:
    timeout: 3000

The variable is set with putenv() because PHP-FPM clears the environment of its workers, so a variable of the container does not reach PHP.

Tests

Install the dependencies without activating Composer plugins in this plugin's own checkout, then run the integration test:

composer install --no-interaction --no-scripts --no-plugins
composer --no-plugins test

On an L3D host, run these commands through l3d .. The test renders the real settings.local.php template with the real configuration class, includes the result and decodes OTEL_RESOURCE_ATTRIBUTES and OTEL_EXPORTER_OTLP_TIMEOUT the way the SDK does, for CI builds with one, two and no runner topics, with OPENTELEMETRY_HOST_NAME, without a branch, for local development, for values that need encoding, without an endpoint, and for the default export timeout and its overrides by OPENTELEMETRY_TIMEOUT and the project config.