Giter Site home page Giter Site logo

Comments (15)

labbati avatar labbati commented on May 19, 2024 1

Hi @chregu, I think the problem is not "how" you do it (which is correct) but "when" you do it. What I bet is happening is that you do it early on in the process (e.g. in a bundle or similar) and that value is overwritten by our integration.

While we are working to improve the way we handle resources, here is a temporarily workaround that you can put in place in the meantime.

If you use a pretty much standard web/app.php you should have toward the end something like:

$response->send();
$kernel->terminate($request, $response);

In this case you can either move your snippet after the kernel termination or early on in the process hook into the terminate invocation:

dd_trace('Symfony\Component\HttpKernel\Kernel', 'terminate', function () {

    $rootScope = \DDTrace\GlobalTracer::get()->getRootScope();
    if (null !== $rootScope) {
        $rootSpan = $rootScope->getSpan();
        $rootSpan->setResource($name);
        $rootSpan->setTag('symfony.route.name', $name);
    }

    return call_user_func_array([$this, 'terminate'], func_get_args());
});

A couple of notes though:

  1. We are working to make working with resource names easier in our api/configuration
  2. IMPORTANT: It is very important that you properly set resource names. Say you have 10k users and you set as the resource name $_SERVER('REQUEST_URI') you would end up with 10k different resources for the very same endpoint /users/<id>/profile. In this case what you set as the resource name should not involve the id, e.g. user-profile would be ok.

from dd-trace-php.

nickdgriffin avatar nickdgriffin commented on May 19, 2024 1

Is DD_SERVICE_MAPPING going to make an appearance?

from dd-trace-php.

chregu avatar chregu commented on May 19, 2024

Thanks a lot for the quick reply. Will try something in this direction.

from dd-trace-php.

labbati avatar labbati commented on May 19, 2024

Hi @chregu just checking in to know if the approach I suggested did work?

from dd-trace-php.

lucas-koontz avatar lucas-koontz commented on May 19, 2024
  1. We are working to make working with resource names easier in our api/configuration

Hi @labbati , we are currently facing this issue in company. Any updates in this front would would be deeply appreciated.

Having two different PHP applications running in the same environment proved to be a headache because there is not a way to track each service, from each app, properly. Currently we adopt a workaround, but it is far from ideal. As well as Manual Instrumentation would not be something we would be able to do.

from dd-trace-php.

labbati avatar labbati commented on May 19, 2024

Hi @lucasfernand-es

Having two different PHP applications running in the same environment proved to be a headache because there is not a way to track each service, from each app, properly.

Why not use DD_TRACE_APP_NAME=app_name with different values in order to differentiate the two apps? Am I missing something?

from dd-trace-php.

lucas-koontz avatar lucas-koontz commented on May 19, 2024

Why not use DD_TRACE_APP_NAME=app_name with different values in order to differentiate the two apps? Am I missing something?

The problem is that DD_TRACE_APP_NAME=app_name only renames the framework, in our case Laravel.
All other resources we use, such as PDO, Curl, Guzzle (etc) share the same name in the APM dashboard. We would like to be able to differentiate those for each project. Other languages, like Ruby, have that covered by DataDog.

from dd-trace-php.

labbati avatar labbati commented on May 19, 2024

@lucasfernand-es thanks for clarifying this. What you need then is service mapping (e.g. DD_SERVICE_MAPPING in Java docs).

Currently PHP does not implement this but it is scheduled to be implemented very soon. I will get back to you with an ETA asap.

from dd-trace-php.

labbati avatar labbati commented on May 19, 2024

Hi @nickdgriffin, service mapping is in the road map but we cannot provide an ETA at the moment.

from dd-trace-php.

nickdgriffin avatar nickdgriffin commented on May 19, 2024

@labbati OK, thanks for the update

from dd-trace-php.

taneishamitchell avatar taneishamitchell commented on May 19, 2024

👍 looking forward to the addition of DD_SERVICE_MAPPING for php

from dd-trace-php.

tonglil avatar tonglil commented on May 19, 2024

+1

from dd-trace-php.

lucas-koontz avatar lucas-koontz commented on May 19, 2024

👍

from dd-trace-php.

nickdgriffin avatar nickdgriffin commented on May 19, 2024

DD_SERVICE_MAPPING looks to now be supported: https://github.com/DataDog/dd-trace-php/releases/tag/0.43.0

from dd-trace-php.

labbati avatar labbati commented on May 19, 2024

👋 hello everyone! With service mapping now released I think this issue can be closed. Feel free to reopen it if you think there is more work to be done.

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.