Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ContextInterface.php

interface ContextInterface

Same name in this branch
  1. 11.1.x core/lib/Drupal/Core/Plugin/Context/ContextInterface.php \Drupal\Core\Plugin\Context\ContextInterface
  2. 11.1.x core/lib/Drupal/Component/Plugin/Context/ContextInterface.php \Drupal\Component\Plugin\Context\ContextInterface

Immutable execution scoped propagation mechanism.

Hierarchy

  • interface \OpenTelemetry\Context\ContextInterface

Expanded class hierarchy of ContextInterface

All classes that implement ContextInterface

See also

https://github.com/open-telemetry/opentelemetry-specification/blob/main…

60 files declare their use of ContextInterface
AggregationInterface.php in vendor/open-telemetry/sdk/Metrics/AggregationInterface.php
AllExemplarFilter.php in vendor/open-telemetry/sdk/Metrics/Exemplar/ExemplarFilter/AllExemplarFilter.php
AlwaysOffSampler.php in vendor/open-telemetry/sdk/Trace/Sampler/AlwaysOffSampler.php
AlwaysOnSampler.php in vendor/open-telemetry/sdk/Trace/Sampler/AlwaysOnSampler.php
AttributeProcessorInterface.php in vendor/open-telemetry/sdk/Metrics/AttributeProcessorInterface.php

... See full list

File

vendor/open-telemetry/context/ContextInterface.php, line 12

Namespace

OpenTelemetry\Context
View source
interface ContextInterface {
    
    /**
     * Creates a new context key.
     *
     * @param non-empty-string $key name of the key
     * @return ContextKeyInterface created key
     *
     * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/context/README.md#create-a-key
     */
    public static function createKey(string $key) : ContextKeyInterface;
    
    /**
     * Returns the current context.
     *
     * @return ContextInterface current context
     *
     * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/context/README.md#get-current-context
     */
    public static function getCurrent() : ContextInterface;
    
    /**
     * Attaches this context as active context.
     *
     * The returned scope has to be {@link ScopeInterface::detach()}ed. In most
     * cases this should be done using a `try-finally` statement:
     * ```php
     * $scope = $context->activate();
     * try {
     *     // ...
     * } finally {
     *     $scope->detach();
     * }
     * ```
     *
     * @return ScopeInterface scope to detach the context and restore the previous
     *         context
     *
     * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/context/README.md#attach-context
     */
    public function activate() : ScopeInterface;
    
    /**
     * Returns a context with the given key set to the given value.
     *
     * @template T
     * @param ContextKeyInterface<T> $key key to set
     * @param T|null $value value to set
     * @return ContextInterface a context with the given key set to `$value`
     *
     * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/context/README.md#set-value
     */
    public function with(ContextKeyInterface $key, $value) : ContextInterface;
    
    /**
     * Returns a context with the given value set.
     *
     * @param ImplicitContextKeyedInterface $value value to set
     * @return ContextInterface a context with the given `$value`
     *
     * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/context/README.md#set-value
     */
    public function withContextValue(ImplicitContextKeyedInterface $value) : ContextInterface;
    
    /**
     * Returns the value assigned to the given key.
     *
     * @template T
     * @param ContextKeyInterface<T> $key key to get
     * @return T|null value assigned to `$key`, or null if no such value exists
     *
     * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/context/README.md#get-value
     */
    public function get(ContextKeyInterface $key);

}

Members

Title Sort descending Modifiers Object type Summary Overrides
ContextInterface::activate public function Attaches this context as active context. 1
ContextInterface::createKey public static function Creates a new context key. 1
ContextInterface::get public function Returns the value assigned to the given key. 1
ContextInterface::getCurrent public static function Returns the current context. 1
ContextInterface::with public function Returns a context with the given key set to the given value. 1
ContextInterface::withContextValue public function Returns a context with the given value set. 1

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal