Download the PHP package launchdarkly/server-sdk-otel without Composer

On this page you can find all versions of the php package launchdarkly/server-sdk-otel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package server-sdk-otel

LaunchDarkly Server-Side SDK for PHP — OpenTelemetry integration

Run CI Packagist Documentation

LaunchDarkly overview

LaunchDarkly is a feature management platform that serves trillions of feature flags daily to help teams build better software, faster. Get started using LaunchDarkly today!

Overview

This package provides an OpenTelemetry integration for the LaunchDarkly PHP Server-Side SDK. It exposes a TracingHook that, when registered with an LDClient, enriches the active OpenTelemetry span with a feature_flag span event for every flag evaluation. The event carries the semantic-convention attributes defined by the OpenTelemetry feature-flag specification and the LaunchDarkly OTEL integration specification (see Attributes emitted).

Reach for this package when you already have OpenTelemetry instrumentation in place and want flag evaluations to show up on the traces that cover them. The hook is a pure consumer of the SDK's hooks API and adds no network or storage dependencies of its own.

Supported PHP versions

This package supports PHP 8.1, 8.2, 8.3, and 8.4. It is safe to use under any PHP SAPI (CLI, PHP-FPM, long-running worker pools); see PHP-FPM and short-lived request lifecycles for guidance on flushing spans in request-response environments.

PHP SAPI Supported Notes
CLI (scripts, workers) yes Nothing to configure.
PHP-FPM / mod_php (web requests) yes See FPM caveats below — span processors must flush before the request ends.
Long-running worker pools (RoadRunner, Swoole, etc.) yes Same rules as CLI; follow your pool's shutdown hooks to flush the tracer provider.

Dependencies

Dependency Version
launchdarkly/server-sdk >=6.8 (first release exposing the evaluation hooks API)
open-telemetry/api ^1.0
psr/log ^1.0, ^2.0, or ^3.0

open-telemetry/api is interface-only. A runtime OpenTelemetry SDK implementation is also required — typically open-telemetry/sdk plus at least one exporter (for example open-telemetry/exporter-otlp for OTLP/HTTP). This package does not pull the SDK in for you, since most applications already configure one.

If you are installing this package from source before launchdarkly/server-sdk has tagged its first hooks-ready release, you may need to track a compatible branch of the parent SDK until that tag lands.

Installation

Quick start

When $client->variation(...) runs inside the active span, the hook attaches a feature_flag event to that span. When no span is active, the hook is a no-op.

Configuring TracingHookOptions

TracingHookOptions is an immutable configuration object passed to the TracingHook constructor. All arguments are optional.

Option Type Default Purpose
includeValue bool false When true, attaches the serialized evaluated flag value as feature_flag.result.value. Be mindful of cardinality and sensitivity before enabling this in production.
addSpans bool false Experimental. When true, wraps every variation call in an LDClient.<method> child span in addition to the event. The exact span structure and naming may change in future releases.
environmentId string\|null null Emitted as feature_flag.set.id. Takes precedence over the environment ID the LaunchDarkly SDK supplies via EvaluationSeriesContext; leave null to use the SDK-supplied value when one is available. Empty or whitespace-only input is rejected and stored as null (a warning is logged if a logger is supplied).
logger Psr\Log\LoggerInterface\|null null Receives construction-time warnings from the options object (for example, an invalid environmentId). When null, no diagnostic output is produced.

Example:

Attributes emitted

The hook emits the following attributes on the feature_flag span event. Attribute names and semantics follow the LaunchDarkly OTEL integration specification.

Required attributes (always emitted when the hook emits an event):

Attribute Value
feature_flag.key The flag key being evaluated.
feature_flag.provider.name The fixed string LaunchDarkly.
feature_flag.context.id The canonical key of the LDContext the flag is being evaluated for.

Optional attributes (emitted only when the corresponding condition is met):

Attribute Emitted when
feature_flag.result.value TracingHookOptions::$includeValue is true. Always serialized to a string; bool becomes "true"/"false", null becomes "null", and arrays/objects are JSON-encoded.
feature_flag.result.variationIndex The evaluation produced a non-null variation index. Emitted as an integer, including the value 0.
feature_flag.result.reason.inExperiment The evaluation reason has inExperiment=true. When false, the attribute is omitted entirely rather than emitted as false.
feature_flag.set.id TracingHookOptions::$environmentId is configured with a non-empty string, or the LaunchDarkly SDK supplies an environment ID on EvaluationSeriesContext. The configured value takes precedence.

When addSpans=true, the wrapper LDClient.<method> span carries only feature_flag.key and feature_flag.context.id; all other attributes remain on the feature_flag event on the caller's surrounding span.

When no span is active on the current OpenTelemetry context, or the active span has an invalid context, the hook emits nothing.

PHP-FPM and short-lived request lifecycles

Under PHP-FPM and similar request-response SAPIs, the PHP process hands control back to the web server as soon as a request completes, which can cut off span exports that a background processor has not yet flushed.

If you use BatchSpanProcessor, its in-memory queue is not guaranteed to flush before the process returns to the pool, and spans emitted late in the request may be lost. You have two straightforward options:

  1. Use SimpleSpanProcessor, which exports each span synchronously on end. This is the simplest correct default for FPM deployments.
  2. Continue using BatchSpanProcessor, but register a shutdown hook that flushes the tracer provider before the process exits:

Worker pools (RoadRunner, Swoole, and similar) keep the PHP process alive across requests, so BatchSpanProcessor works as intended there. Follow your pool's shutdown hooks to call $tracerProvider->shutdown() at process exit.

Known limitations

When addSpans=true, the wrapper span name is built from the PHP SDK method string (variation, variationDetail, migrationVariation), producing LDClient.variation, LDClient.variationDetail, and LDClient.migrationVariation. Aligning the casing with other LaunchDarkly SDKs is a concern for the core PHP Server-Side SDK and is tracked separately.

Contributing

We encourage pull requests and other contributions from the community. Check out our contributing guidelines for instructions on how to contribute to this SDK.

License

Apache 2.0. See LICENSE.txt for the full text.

About LaunchDarkly


All versions of server-sdk-otel with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
launchdarkly/server-sdk Version ^6.8
open-telemetry/api Version ^1.0
psr/log Version ^1.0|^2.0|^3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package launchdarkly/server-sdk-otel contains the following files

Loading the files please wait ...