Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

logging more errors #764

Merged
merged 1 commit into from
Jul 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Contrib/Jaeger/JaegerTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function flush($force = false): int
// reset the process tag
$this->process = null;
} catch (TTransportException $e) {
self::logError('jaeger: transport failure: ' . $e->getMessage());
self::logError('jaeger: transport failure', ['exception' => $e]);

return 0;
}
Expand Down
8 changes: 8 additions & 0 deletions src/SDK/Trace/Behavior/HttpSpanExporterTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use InvalidArgumentException;
use JsonException;
use OpenTelemetry\SDK\Behavior\LogsMessagesTrait;
use OpenTelemetry\SDK\Trace\SpanExporterInterface;
use Psr\Http\Client\ClientExceptionInterface;
use Psr\Http\Client\ClientInterface;
Expand All @@ -24,6 +25,7 @@
*/
trait HttpSpanExporterTrait
{
use LogsMessagesTrait;
use SpanExporterTrait;

protected string $endpointUrl;
Expand All @@ -46,14 +48,20 @@ protected function doExport(iterable $spans): int
try {
$response = $this->dispatchSpans($spans);
} catch (ClientExceptionInterface $e) {
self::logError('Unable to export span(s)', ['exception' => $e]);

return $e instanceof RequestExceptionInterface
? SpanExporterInterface::STATUS_FAILED_NOT_RETRYABLE
: SpanExporterInterface::STATUS_FAILED_RETRYABLE;
} catch (Throwable $e) {
self::logError('Unable to export span(s)', ['exception' => $e]);

return SpanExporterInterface::STATUS_FAILED_NOT_RETRYABLE;
}

if ($response->getStatusCode() >= 400) {
self::logError('Unable to export span(s)', ['code' => $response->getStatusCode()]);

return $response->getStatusCode() < 500
? SpanExporterInterface::STATUS_FAILED_NOT_RETRYABLE
: SpanExporterInterface::STATUS_FAILED_RETRYABLE;
Expand Down
6 changes: 3 additions & 3 deletions src/SDK/Trace/TracerProviderFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,21 @@ public function create(): TracerProviderInterface
try {
$exporter = $this->exporterFactory->fromEnvironment();
} catch (\Throwable $t) {
self::logWarning('Unable to create exporter', ['error' => $t]);
self::logWarning('Unable to create exporter', ['exception' => $t]);
$exporter = null;
}

try {
$sampler = $this->samplerFactory->fromEnvironment();
} catch (\Throwable $t) {
self::logWarning('Unable to create sampler', ['error' => $t]);
self::logWarning('Unable to create sampler', ['exception' => $t]);
$sampler = null;
}

try {
$spanProcessor = $this->spanProcessorFactory->fromEnvironment($exporter);
} catch (\Throwable $t) {
self::logWarning('Unable to create span processor', ['error' => $t]);
self::logWarning('Unable to create span processor', ['exception' => $t]);
$spanProcessor = null;
}

Expand Down