Code Monkey home page Code Monkey logo

Comments (8)

skranz-codi avatar skranz-codi commented on May 25, 2024 1

Hi @PROFeNoM ,
i try to list all the pieces from the "outside" to the "inside":

$results = Utils::unwrap([ 
'foo' => $fooService->getFoo($id),
'bar' => $barService->getBar($id),
'baz' => $bazService->getBaz($id),
]);

inside those service calls:

return $this->client->getAsync('/foo/bar/baz' , $options + ['http_errors' => false,]);

this is how the client is build:

$guzzleClient = new HttpClient([
'base_uri' => $config->get('foo.client.base_uri'),
'auth' => [ 
$config->get('foo.client.auth.username'), 
$config->get('foo.client.auth.password')
],
'verify' => $config->get('foo.client.verify'),
'timeout' => $config->get('foo.client.timeout'),
'allow_redirects' => false,
'handler' => $handlerStack,
'headers' => [ 
'Accept' => 'application/json', 
'Accept-Encoding' => 'gzip, deflate', 
'foo-statistics' => $this->getFooHeaderValue($config),
],
]);

and here the handlerstack:

$this->app->singleton(HttpFooHandlerStack::class, static function (Application $app) {
    $handlerStack = HttpFooHandlerStack::create($app->make(CurlMultiHandler::class));
    $handlerStack->push($app->make(FooErrorHandlingMiddleware::class)->__invoke());
    $handlerStack->before('http_errors', $app->make(HttpLoggingMiddleware::class)->__invoke());
    return $handlerStack;
});

the middlewares look kind of like this:

public function __invoke(): callable{
    return function (callable $handler) {
        return function (RequestInterface $request, array $options) use ($handler) {
            return $handler($request, $options)->then($this->handleResponse($request));
        };
    }
;}

 private function handleResponse(RequestInterface $request): callable
{
        return function (ResponseInterface $response) use ($request) {
            ...
        }
}

and

public function __invoke(){
    return function (callable $handler) {
        return function (RequestInterface $request, array $options) use ($handler) {
            $id = Uuid::uuid4()->toString();
            $request = $this->handleRequest($request, $id);
            $start = microtime(true);
            return $this
                ->getPromise($request, $options, $handler)
                ->then(
                    $this->handleResponse($request, $start, $id),
                    $this->handleRejection($id)
                );
        };
    };
}

private function getPromise(RequestInterface $request, array $options, callable $next): PromiseInterface
{
        return $next($request, $options);
}

private function handleRequest(RequestInterface $request, string $guzzleRequestId): RequestInterface
{
...
}

private function handleResponse(RequestInterface $request, float $start, string $guzzleRequestId)
{
        return function (ResponseInterface $response) use ($request, $start, $guzzleRequestId) {
            return $response;
        };
}

While checking this out i made some more tests and found out, that leaving out the second and third call from the unwrap, the error is gone and the first request will be displayed correctly in the dd ui:

$results = Utils::unwrap([ 
'foo' => $fooService->getFoo($id),
]);
image

Hope this helps. Let me know if i can give you more infos.

from dd-trace-php.

skranz-codi avatar skranz-codi commented on May 25, 2024 1

i only had 5 minutes but this looks really promising:
image
thx so far.

from dd-trace-php.

PROFeNoM avatar PROFeNoM commented on May 25, 2024

Hi @skranz-codi !

After doing some testing on my side, using guzzle, I may have been able to reproduce your issue:
image

I'd have what I call "dummy curl_exec spans", most notably with host-unparsable-host. I tried some changes in a branch of mine that aims to address some cases.

Could please try out this artifact (CI job)? To use the artifact, you can simply replace the datadog-setup.php link you are using when installing the tracer with the one from the artifact.

from dd-trace-php.

skranz-codi avatar skranz-codi commented on May 25, 2024

hi @PROFeNoM and thx for the response!
I tried your version, but the issue sadly is still there:
image
i checked the build pipe and i am quite sure i am now using your version when installing the extension:
image

One thing I never fully understood: I have to install the extension AND add the dependency via composer ("datadog/dd-trace": "0.96.0"), right? While testing your version i still have the 0.96.0 composer lib installed. Is this ok?

Thx again for your effort!

from dd-trace-php.

PROFeNoM avatar PROFeNoM commented on May 25, 2024

Hi @skranz-codi !

Alright, I'll try to reproduce it further. Can I please know how are you making these requests (the essence of the code that is running)? What I was trying was to do some getAsync and wait for them (as you may see in this draft test file).

If you have this information, I'd be interested to know what status code you expect from these requests (so that I can try to reproduce it with the same type of request).

Thanks

I have to install the extension AND add the dependency via composer ("datadog/dd-trace": "0.96.0"), right? While testing your version i still have the 0.96.0 composer lib installed.

You don't have to. Only the extension is required.

Is this ok?

It shouldn't be a problem; it isn't required for common use cases.

from dd-trace-php.

PROFeNoM avatar PROFeNoM commented on May 25, 2024

Hi @skranz-codi!

Thanks for your fantastic description.

This time I've made another artifact (CI Job - Branch) that should cover some additional cases, especially when considering non-erroneous requests (which is your case) 🤞

from dd-trace-php.

PROFeNoM avatar PROFeNoM commented on May 25, 2024

Hey @skranz-codi 👋

FYI, the 0.97.0 release was made yesterday, which includes the PR #2460 :)

from dd-trace-php.

skranz-codi avatar skranz-codi commented on May 25, 2024

hi, i am already testing it and it still looks very good 👍 thx again for the fix!

from dd-trace-php.

Related Issues (20)

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.