Skip to main content

PHP SDK developer's guide - Observability

The observability section of the Temporal Developer's guide covers the many ways to view the current state of your Temporal ApplicationLink preview iconWhat is a Temporal Application

A Temporal Application is a set of Workflow Executions.

Learn more—that is, ways to view which Workflow Executions are tracked by the Temporal PlatformLink preview iconWhat is the Temporal Platform?

The Temporal Platform consists of a Temporal Cluster and Worker Processes.

Learn more and the state of any specified Workflow Execution, either currently or at points of an execution.

WORK IN PROGRESS

This guide is a work in progress. Some sections may be incomplete or missing for some languages. Information may change at any time.

If you can't find what you are looking for in the Developer's guide, it could be in older docs for SDKs.

This section covers features related to viewing the state of the application, including:

Visibility

The term Visibility, within the Temporal Platform, refers to the subsystems and APIs that enable an operator to view Workflow Executions that currently exist within a Cluster.

Search Attributes

The typical method of retrieving a Workflow Execution is by its Workflow Id.

However, sometimes you'll want to retrieve one or more Workflow Executions based on another property. For example, imagine you want to get all Workflow Executions of a certain type that have failed within a time range, so that you can start new ones with the same arguments.

You can do this with Search AttributesLink preview iconWhat is a Search Attribute?

A Search Attribute is an indexed name used in List Filters to filter a list of Workflow Executions that have the Search Attribute in their metadata.

Learn more.

The steps to using custom Search Attributes are:

Here is how to query Workflow Executions:

Custom Search Attributes

After you've created custom Search Attributes in your Cluster (using tctl search-attribute createor the Cloud UI), you can set the values of the custom Search Attributes when starting a Workflow.

Use the WorkflowOptions::withSearchAttributes() method to provide Search Attributes when you start a Workflow.

$workflow = $this->workflowClient->newWorkflowStub(
GreetingWorkflowInterface::class,
WorkflowOptions::new()
->withWorkflowExecutionTimeout(CarbonInterval::minute())
->withSearchAttributes(
[
'CustomKeywordField' => 'value',
'CustomIntField' => 123,
]
)
);

Upsert Search Attributes

You can upsert Search Attributes to add or update Search Attributes from within Workflow code.

To upsert Search Attributes within a Workflow, use Workflow::upsertSearchAttributes().

class GreetingWorkflow implements GreetingWorkflowInterface
{
public function getGreeting(string $name)
{
Workflow::upsertSearchAttributes(
[
'CustomKeywordField' => 'attr1-value',
'CustomIntField' => 123,
]
);

// ...
}
}

Remove Search Attribute

To remove a Search Attribute that was previously set, set it to an empty array: [].

To remove a Search Attribute that was previously set, set it to an empty array [].