Skip to content

Commit

Permalink
fixing api breakages
Browse files Browse the repository at this point in the history
the SDK BC layer only works if the SDK is installed :(
  • Loading branch information
brettmc committed Jun 26, 2023
1 parent ce970de commit 041f049
Show file tree
Hide file tree
Showing 15 changed files with 41 additions and 18 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ help: ## Show this help
@echo "example: PROJECT=Aws PHP_VERSION=8.1 make <command>"
@printf "\033[33m%s:\033[0m\n" 'Available commands'
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z0-9_-]+:.*?## / {printf " \033[32m%-18s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
all: update style validate phan psalm phpstan test ## Everything
all-checks: style validate phan psalm phpstan test
all: update all-checks ## Everything
build: ## Build image
$(DOCKER_COMPOSE) build --build-arg PHP_VERSION php
install: ## Install dependencies
Expand Down
6 changes: 4 additions & 2 deletions src/Aws/src/AwsSdkInstrumentation.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

use Aws\Middleware;
use Aws\ResultInterface;
use OpenTelemetry\API\Common\Instrumentation\InstrumentationInterface;
use OpenTelemetry\API\Common\Instrumentation\InstrumentationTrait;
use OpenTelemetry\API\Instrumentation\InstrumentationInterface;
use OpenTelemetry\API\Instrumentation\InstrumentationTrait;
use OpenTelemetry\API\Trace\SpanInterface;
use OpenTelemetry\API\Trace\SpanKind;
use OpenTelemetry\API\Trace\TracerInterface;
Expand Down Expand Up @@ -98,6 +98,7 @@ public function activate(): bool

$propagator->inject($carrier);

/** @psalm-suppress PossiblyInvalidArgument */
$this->span->setAttributes([
'rpc.method' => $cmd->getName(),
'rpc.service' => $this->clientName,
Expand All @@ -106,6 +107,7 @@ public function activate(): bool
]);
});

/** @psalm-suppress PossiblyInvalidArgument */
$end_middleware = Middleware::mapResult(function (ResultInterface $result) {
$this->span->setAttributes([
'http.status_code' => $result['@metadata']['statusCode'], //@phan-suppress-current-line PhanTypeMismatchDimFetch
Expand Down
2 changes: 1 addition & 1 deletion src/Aws/src/Xray/Propagator.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public function extract($carrier, PropagationGetterInterface $getter = null, Con
$spanContext = SpanContext::createFromRemoteParent(
$parsedTraceId,
$parsedSpanId,
self::IS_SAMPLED === $sampledFlag ? API\SpanContextInterface::TRACE_FLAG_SAMPLED : API\SpanContextInterface::TRACE_FLAG_DEFAULT
self::IS_SAMPLED === $sampledFlag ? API\TraceFlags::SAMPLED : API\TraceFlags::DEFAULT
);

if ($spanContext->isValid()) {
Expand Down
5 changes: 5 additions & 0 deletions src/Instrumentation/HttpAsyncClient/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,10 @@
"open-telemetry/sdk": "^1.0",
"phpunit/phpunit": "^9.5",
"vimeo/psalm": "^4.0"
},
"config": {
"allow-plugins": {
"php-http/discovery": false
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

use Http\Client\HttpAsyncClient;
use Http\Promise\Promise;
use OpenTelemetry\API\Common\Instrumentation;
use OpenTelemetry\API\Common\Instrumentation\CachedInstrumentation;
use OpenTelemetry\API\Globals;
use OpenTelemetry\API\Instrumentation\CachedInstrumentation;
use OpenTelemetry\API\Trace\Span;
use OpenTelemetry\API\Trace\SpanKind;
use OpenTelemetry\API\Trace\StatusCode;
Expand Down Expand Up @@ -37,7 +37,7 @@ public static function register(): void
return null;
}

$propagator = Instrumentation\Globals::propagator();
$propagator = Globals::propagator();
$parentContext = Context::getCurrent();

/** @psalm-suppress ArgumentTypeCoercion */
Expand Down
1 change: 1 addition & 0 deletions src/Instrumentation/Laravel/src/QueryWatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public function recordQuery(QueryExecuted $query): void
];

$attributes[TraceAttributes::DB_STATEMENT] = $query->sql;
/** @psalm-suppress PossiblyInvalidArgument */
$span->setAttributes($attributes);
$span->end($nowInNs);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Illuminate\Auth\Events\Registered;
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Event;

class EventServiceProvider extends ServiceProvider
{
Expand Down
2 changes: 1 addition & 1 deletion src/Instrumentation/PDO/src/PDOInstrumentation.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace OpenTelemetry\Contrib\Instrumentation\PDO;

use OpenTelemetry\API\Common\Instrumentation\CachedInstrumentation;
use OpenTelemetry\API\Instrumentation\CachedInstrumentation;
use OpenTelemetry\API\Trace\Span;
use OpenTelemetry\API\Trace\SpanBuilderInterface;
use OpenTelemetry\API\Trace\SpanKind;
Expand Down
5 changes: 5 additions & 0 deletions src/Instrumentation/Psr15/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,10 @@
"open-telemetry/sdk": "^1.0",
"phpunit/phpunit": "^9.5",
"vimeo/psalm": "^4.0"
},
"config": {
"allow-plugins": {
"php-http/discovery": false
}
}
}
4 changes: 2 additions & 2 deletions src/Instrumentation/Psr15/src/Psr15Instrumentation.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace OpenTelemetry\Contrib\Instrumentation\Psr15;

use OpenTelemetry\API\Common\Instrumentation\CachedInstrumentation;
use OpenTelemetry\API\Common\Instrumentation\Globals;
use OpenTelemetry\API\Globals;
use OpenTelemetry\API\Instrumentation\CachedInstrumentation;
use OpenTelemetry\API\Trace\Span;
use OpenTelemetry\API\Trace\SpanInterface;
use OpenTelemetry\API\Trace\SpanKind;
Expand Down
5 changes: 5 additions & 0 deletions src/Instrumentation/Psr18/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,10 @@
"open-telemetry/sdk": "^1.0",
"phpunit/phpunit": "^9.5",
"vimeo/psalm": "^4.0"
},
"config": {
"allow-plugins": {
"php-http/discovery": false
}
}
}
8 changes: 4 additions & 4 deletions src/Instrumentation/Psr18/src/Psr18Instrumentation.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
namespace OpenTelemetry\Contrib\Instrumentation\Psr18;

use function get_cfg_var;
use OpenTelemetry\API\Common\Instrumentation;
use OpenTelemetry\API\Common\Instrumentation\CachedInstrumentation;
use OpenTelemetry\API\Globals;
use OpenTelemetry\API\Instrumentation\CachedInstrumentation;
use OpenTelemetry\API\Trace\Span;
use OpenTelemetry\API\Trace\SpanKind;
use OpenTelemetry\API\Trace\StatusCode;
Expand Down Expand Up @@ -40,7 +40,7 @@ public static function register(): void
return null;
}

$propagator = Instrumentation\Globals::propagator();
$propagator = Globals::propagator();
$parentContext = Context::getCurrent();

/** @psalm-suppress ArgumentTypeCoercion */
Expand All @@ -52,7 +52,7 @@ public static function register(): void
->setAttribute(TraceAttributes::HTTP_URL, (string) $request->getUri())
->setAttribute(TraceAttributes::HTTP_METHOD, $request->getMethod())
->setAttribute(TraceAttributes::HTTP_FLAVOR, $request->getProtocolVersion())
->setAttribute(TraceAttributes::HTTP_USER_AGENT, $request->getHeaderLine('User-Agent'))
->setAttribute(TraceAttributes::USER_AGENT_ORIGINAL, $request->getHeaderLine('User-Agent'))
->setAttribute(TraceAttributes::HTTP_REQUEST_CONTENT_LENGTH, $request->getHeaderLine('Content-Length'))
->setAttribute(TraceAttributes::NET_PEER_NAME, $request->getUri()->getHost())
->setAttribute(TraceAttributes::NET_PEER_PORT, $request->getUri()->getPort())
Expand Down
2 changes: 1 addition & 1 deletion src/Instrumentation/Slim/.php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
'phpdoc_scalar' => true,
'phpdoc_types' => true,
'short_scalar_cast' => true,
'single_blank_line_before_namespace' => true,
'blank_lines_before_namespace' => true,
'single_quote' => true,
'trailing_comma_in_multiline' => true,
])
Expand Down
5 changes: 5 additions & 0 deletions src/Instrumentation/Slim/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,10 @@
"psr-4": {
"OpenTelemetry\\Tests\\Instrumentation\\Slim\\": "tests/"
}
},
"config": {
"allow-plugins": {
"php-http/discovery": false
}
}
}
4 changes: 2 additions & 2 deletions src/Instrumentation/Slim/src/SlimInstrumentation.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace OpenTelemetry\Contrib\Instrumentation\Slim;

use OpenTelemetry\API\Common\Instrumentation\CachedInstrumentation;
use OpenTelemetry\API\Common\Instrumentation\Globals;
use OpenTelemetry\API\Globals;
use OpenTelemetry\API\Instrumentation\CachedInstrumentation;
use OpenTelemetry\API\Trace\Span;
use OpenTelemetry\API\Trace\SpanInterface;
use OpenTelemetry\API\Trace\SpanKind;
Expand Down

0 comments on commit 041f049

Please sign in to comment.