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

Fos HTTP Cache show as index.php #206

Open
Webonaute opened this issue Oct 6, 2018 · 7 comments
Open

Fos HTTP Cache show as index.php #206

Webonaute opened this issue Oct 6, 2018 · 7 comments

Comments

@Webonaute
Copy link

Webonaute commented Oct 6, 2018

I have problem to see my cached request to display in new relic. they all show as index.php

is there a way to specially name it cached_<routeName>?

@Nyholm
Copy link
Collaborator

Nyholm commented Oct 6, 2018

Sure. Have a look at the NamingStrategy section. https://github.com/ekino/EkinoNewRelicBundle#transaction-naming-strategies

@Webonaute
Copy link
Author

but why my cache is see as index.php instead of routename?

here is my config. did I miss anything?

ekino_new_relic:
    enabled: true                         # Defaults to true
    application_name: 'api-%kernel.environment%' # default value in newrelic is "PHP Application", or whatever is set
                                          # as php ini-value
    deployment_names: '%api_version%'                   # default value is 'application_name', supports string array or semi-colon separated string
    api_key:  '%newrelic_api_key%'        # New Relic API
    license_key: '%newrelic_license_key%' # New Relic license key (optional, default value is read from php.ini)
    xmit: false                           # if you want to record the metric data up to the point newrelic_set_appname is called, set this to true (default: false)
    logging: false                        # If true, logs all New Relic interactions to the Symfony log (default: false)
    #interactor: Ekino\NewRelicBundle\NewRelic\AdaptiveInteractor                      # The interactor service that is used. Setting enabled=false will override this value
    twig: false                           # Allows you to disable twig integration (falls back to class_exists(\Twig_Environment::class))
    exceptions: true                      # If true, sends exceptions to New Relic (default: true)
    deprecations: false                   # If true, reports deprecations to New Relic (default: true)
    instrument: false                     # If true, uses enhanced New Relic RUM instrumentation (see below) (default: false)
    http:
        enabled: true
        using_symfony_cache: true        # Symfony HTTP cache (see below) (default: false)
        transaction_naming: route         # route, controller or service (see below)
    #    transaction_naming_service: ~     # Transaction naming service (see below)
    #    ignored_routes: []                # No transaction recorded for this routes
    #    ignored_paths: []                 # No transaction recorded for this paths
    #monolog:
    #    enabled: false                    # When enabled, send application's logs to New Relic (default: disabled)
    #    channels: [app]                   # Channels to listen (default: null). [See Symfony's documentation](http://symfony.com/doc/current/logging/channels_handlers.html#yaml-specification)
    #    level: error                      # Report only logs higher than this level (see \Psr\Log\LogLevel) (default: error)
    #    service: app.my_custom_handler    # Define a custom log handler (default: ekino.new_relic.monolog_handler)
    commands:
        enabled: true                     # If true, logs CLI commands to New Relic as Background jobs (>2.3 only) (default: true)
        ignored_commands: []              # No transaction recorded for this commands (background tasks)


@Webonaute
Copy link
Author

from what I see, the RequestListener is never trigger on cached request. so the transaction name cannot be set.

@jderusse
Copy link
Collaborator

jderusse commented Oct 9, 2018

Hmm.. are you using SymfonyCache?

If yes, Symfony is probably returning the cached response before calling the NewrelicBundle's code. That would explain why the transaction is not defined.

@Webonaute
Copy link
Author

Yeah. That’s what I found. I am using FoshttpCache bundle. Look like I need a special subscriber in my AppCache setup.

@jderusse
Copy link
Collaborator

Thinking about your issue, IMHO, this is a good thing that the RequestListener is not called. First, for performance reason, but mainly because NewRelic should not mix metrics from cached response with not-cached.

I think you may try to set a ReverseCache temporary name in the Kernel's handle function. This name will be overrided by the RequestListener for Missed calls, and it'll stay a default name for Cached responses.

class CacheKernel extends HttpCache
{
  public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true) {
    newrelic_name_transaction('cached');
    // or with NR objects: (new AdaptiveInteractor(new NewRelicInteractor(), new BlackholeInteractor))->setTransactionName('cached');
     
    return parent::handle($request, $type, $catch);
  }
}

Could you give a try and tell us if it works for you? We'll add an entry in the documentation

@Webonaute
Copy link
Author

already try to handle the transaction name in the handle method, it's not applied.

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

No branches or pull requests

3 participants