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

Absolute paths instead of relative paths since 4.0 #431

Closed
ruudk opened this issue Jan 27, 2021 · 12 comments · Fixed by #434
Closed

Absolute paths instead of relative paths since 4.0 #431

ruudk opened this issue Jan 27, 2021 · 12 comments · Fixed by #434
Milestone

Comments

@ruudk
Copy link
Contributor

ruudk commented Jan 27, 2021

Environment

How do you use Sentry?
Sentry SaaS (sentry.io)

Which SDK and version?
Symfony 4.0

Steps to Reproduce

Since upgrading to Symfony 4.0 I noticed that reported paths are no longer relative to the project_dir but absolute paths like this:
Screenshot 2021-01-27 at 08 44 53@2x

I searched the docs but couldn't find anything related to this.

Expected Result

Relative path to %kernel.project_dir%.

@Jean85
Copy link
Collaborator

Jean85 commented Jan 27, 2021

@ste93cry are you using 4.0 in prod? Do you have the same issue?

[EDIT] I see that in_app_include does not have a default value; previously, we where using the project_root option to handle that, but we stopped in #311 due to its deprecation... @ruudk can you check if the regression is exactly due to 4.0 or if it's related to #311 instead (which was released with 3.4.3)?

@Jean85
Copy link
Collaborator

Jean85 commented Jan 27, 2021

I'm using 3.5.2 in prod with default options and I do NOT get the full path. Hence, it's probably due to 4.0.

@ste93cry
Copy link
Collaborator

@ste93cry are you using 4.0 in prod

Not yet

@ruudk
Copy link
Contributor Author

ruudk commented Jan 27, 2021

I tried this config in production but it doesn't solve the problem:

sentry:
    options:
        in_app_include:
            - '%kernel.project_dir%'

@ruudk
Copy link
Contributor Author

ruudk commented Jan 27, 2021

I checked the compiled container on production and found that my in_app_include setting is correctly done:

// var/cache/prod/ContainerCsF2Fdk/App_KernelProdContainer.php
// ...
public function __construct(array $buildParameters = [], $containerDir = __DIR__)
{
        // ...
        $this->targetDir = \dirname($containerDir);
        // ...
}
// ....
protected function getSentry_ClientService()
{
    $a = new \Sentry\Options([
        'in_app_include'    => [
            0 => \dirname(__DIR__, 4),
        ],
        'integrations'      => [
            0 => new \Sentry\Integration\IgnoreErrorsIntegration(['ignore_exceptions' => $this->parameters['excluded_exceptions_in_tracking']]),
            1 => new \Sentry\Integration\RequestIntegration(
                new \Sentry\SentryBundle\Integration\RequestFetcher(
                    ($this->services['request_stack'] ?? ($this->services['request_stack'] = new \Symfony\Component\HttpFoundation\RequestStack())),
                    null
                )
            ),
        ],
        'release'           => $this->getEnv('APP_REVISION'),
        'environment'       => 'production',
        'prefixes'          => [],
        'tags'              => [],
        'in_app_exclude'    => [
            0 => $this->targetDir . '',
            1 => $this->targetDir . '',
            2 => (\dirname(__DIR__, 4) . '/vendor'),
        ],
        'class_serializers' => [],
        'dsn'               => $this->getEnv('SENTRY_DSN'),
    ]);
}

But I find it weird that for in_app_exclude there is a double declaration of the targetDir (that resolves to var/cache/prod/ContainerCsF2Fdk).

@Jean85
Copy link
Collaborator

Jean85 commented Jan 27, 2021

in_app_exclude has these defaults:

'%kernel.cache_dir%',
'%kernel.build_dir%',
'%kernel.project_dir%/vendor',

So it could be duplicated, that's normal.

@mbabker
Copy link

mbabker commented Jan 29, 2021

If I'm following right, the issue is the prefixes option isn't being set, and you'll need this to make relative paths again:

sentry:
    options:
        prefixes:
            - '%kernel.project_dir%'

@ruudk
Copy link
Contributor Author

ruudk commented Jan 29, 2021

@mbabker Thanks. I'm going to try that out next week and reply back.

@ruudk
Copy link
Contributor Author

ruudk commented Feb 1, 2021

sentry:
    options:
        prefixes:
            - '%kernel.project_dir%'

seems to be the solution.

However, I think I need to add a / suffix because it now looks like this:
CleanShot 2021-02-01 at 10 11 45@2x

I think it would make more sense if Sentry automatically truncated starting slashes.

@Jean85
Copy link
Collaborator

Jean85 commented Feb 1, 2021

The / at the start should be trimmed serverside, and was already reported as an issue elsewhere (but I can't find a link).

@HazAT can you to report it to the proper channels?

@Jean85 Jean85 linked a pull request Feb 1, 2021 that will close this issue
@Jean85
Copy link
Collaborator

Jean85 commented Feb 1, 2021

Scratch that, prefixes is a client-side thing that should be fixed in the base SDK. In the meantime, I've opened #434 to add the prefix by default.

@Jean85
Copy link
Collaborator

Jean85 commented Feb 1, 2021

I've also found the related PR for the slash that needs to be trimmed: getsentry/sentry-php#1163

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants