Coder Social home page Coder Social logo

auxmoney / opentracingbundle-guzzle Goto Github PK

View Code? Open in Web Editor NEW
5.0 5.0 5.0 215 KB

Guzzle extension for the auxmoney/OpentracingBundle-core

License: MIT License

PHP 96.63% Shell 3.37%
auxmoney opentracing opentracing-bundle symfony symfony-bundle distributed-tracing guzzle guzzlehttp

opentracingbundle-guzzle's People

Contributors

cawolf avatar dependabot[bot] avatar filisko avatar mmross avatar semantic-release-bot avatar vincentlemaireagriconomie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

opentracingbundle-guzzle's Issues

EightPointsGuzzleBundle support

Within https://github.com/8p/EightPointsGuzzleBundle the handlers are services by themself. The Client doesn't seem to get registred.

id: eight_points_guzzle.handler_stack.
class: GuzzleHttp\HandlerStack

I would suggest the following change:

if ($definition->getClass() === Client::class) {
    $this->addMiddlewareToHandlerStack($container, $definition, $clientServiceName);
} elseif () {
    $definition->addMethodCall('push', [new Reference(GuzzleRequestSpanning::class)]);
    $definition->addMethodCall('push', [new Reference(GuzzleTracingHeaderInjection::class)]);
}

Promise interface, onRejected ?

In GuzzleRequestSpanning, isn't the $onRejected callback missing ?

return $promise->then(
function (ResponseInterface $response) {
$this->requestSpanning->finish($response->getStatusCode());
$this->tracing->finishActiveSpan();
return $response;
}
);

See the relevant interface here:
https://github.com/guzzle/promises/blob/89b1a76b7fda5853401297dc4b2a093cba1fda23/src/PromiseInterface.php#L28-L31

I fear that if the request is canceled or in case of an error, the open span won't be closed.

Not working with factory ?

We have a factory that creates a guzzle client, this factory returns the guzzle client with a handler created given some arguments.

The service looks like this:

    admin.microservice.client:
        class: GuzzleHttp\Client
        factory: [\Agriconomie\Microservice\ClientFactory, create]
        arguments:
            $debug: '%kernel.debug%'
            $logger: '@monolog.logger.internal_api'

And the factory:

    /**
     * @param bool $debug
     * @param LoggerInterface|null $logger
     */
    public static function create(bool $debug, ?LoggerInterface $logger) {
        $handlerStack = HandlerStack::create();
        $client = new \GuzzleHttp\Client([
            'handler' => $handlerStack
        ]);
        if (null !== $logger) {
            $handlerStack->push(Middleware::log($logger, new MessageFormatter(MessageFormatter::SHORT), LogLevel::INFO));
            if ($debug) {
                $handlerStack->push(Middleware::log($logger, new MessageFormatter(MessageFormatter::DEBUG), LogLevel::DEBUG));
            }
        }
        return $client;
    }

I integrated the opentracing guzzle bundle, it breaks here i think:

foreach ($container->getDefinitions() as $clientServiceName => $definition) {
if ($definition->getClass() === Client::class) {
$this->addMiddlewareToClient($container, $definition, $clientServiceName);
} elseif ($definition->getClass() === HandlerStack::class) {
$this->addUniqueMethodCallsToHandlerStack($definition);
}
}

probably because of this:

private function getConfiguration(Definition $definition): array
{
$arguments = $definition->getArguments();
$configuration = [];
if (isset($arguments[0])) {
$configuration = $arguments[0];
} elseif (isset($arguments['$config'])) {
$configuration = $arguments['$config'];
}
return $configuration;
}

Shouldn't the process method take care of the factory use case ?

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.