-
Notifications
You must be signed in to change notification settings - Fork 964
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'philkra-add-opaque-id-mutator'
- Loading branch information
Showing
7 changed files
with
176 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,32 @@ | |
There are several configurations that can be set on a per-request basis, rather than at a connection- or client-level. | ||
These are specified as part of the request associative array. | ||
|
||
|
||
=== Request Identification | ||
|
||
You can enrich your requests against Elasticsearch with an identifier string, that allows you to discover this identifier | ||
in https://www.elastic.co/guide/en/elasticsearch/reference/7.4/logging.html#deprecation-logging[deprecation logs], to support you with | ||
https://www.elastic.co/guide/en/elasticsearch/reference/7.4/index-modules-slowlog.html#_identifying_search_slow_log_origin[identifying search slow log origin] | ||
or to help with https://www.elastic.co/guide/en/elasticsearch/reference/current/tasks.html#_identifying_running_tasks[identifying running tasks]. | ||
|
||
|
||
[source,php] | ||
---- | ||
$client = ClientBuilder::create()->build(); | ||
$params = [ | ||
'index' => 'test', | ||
'id' => 1, | ||
'client' => [ | ||
'opaqueId' => '[email protected]_user1234', <1> | ||
] | ||
]; | ||
$response = $client->get($params); | ||
---- | ||
<1> This will populate the `X-Opaque-Id` header with the value `[email protected]_user1234` | ||
|
||
|
||
=== Ignoring exceptions | ||
The library attempts to throw exceptions for common problems. These exceptions match the HTTP response code provided | ||
by Elasticsearch. For example, attempting to GET a nonexistent document will throw a `MissingDocument404Exception`. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
namespace Elasticsearch\Tests\ClientBuilder; | ||
|
||
use Psr\Log\LoggerInterface; | ||
use Psr\Log\LogLevel; | ||
|
||
class ArrayLogger implements LoggerInterface | ||
{ | ||
public $output = []; | ||
|
||
public function emergency($message, array $context = array()) | ||
{ | ||
$this->log(LogLevel::EMERGENCY, $message, $context); | ||
} | ||
|
||
public function alert($message, array $context = array()) | ||
{ | ||
$this->log(LogLevel::ALERT, $message, $context); | ||
} | ||
|
||
public function critical($message, array $context = array()) | ||
{ | ||
$this->log(LogLevel::CRITICAL, $message, $context); | ||
} | ||
|
||
public function error($message, array $context = array()) | ||
{ | ||
$this->log(LogLevel::ERROR, $message, $context); | ||
} | ||
|
||
public function warning($message, array $context = array()) | ||
{ | ||
$this->log(LogLevel::WARNING, $message, $context); | ||
} | ||
|
||
public function notice($message, array $context = array()) | ||
{ | ||
$this->log(LogLevel::NOTICE, $message, $context); | ||
} | ||
|
||
public function info($message, array $context = array()) | ||
{ | ||
$this->log(LogLevel::INFO, $message, $context); | ||
} | ||
|
||
public function debug($message, array $context = array()) | ||
{ | ||
$this->log(LogLevel::DEBUG, $message, $context); | ||
} | ||
|
||
public function log($level, $message, array $context = array()) | ||
{ | ||
$this->output[] = sprintf("%s: %s %s", $level, $message, json_encode($context)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,5 +5,5 @@ | |
|
||
class DummyLogger | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters