Git Product home page Git Product logo

applicationinsights-wordpress's Introduction

Application Insights WordPress Plugin

Integrates a WordPress site with Azure Application Insights.

Please refer to README.txt for plugin information. See details on plugin readme authoring here.

See CONTRIBUTING.md for details on how to contribute.

Status

This SDK is NOT maintained or supported by Microsoft even though we've contributed to it in the past. Note that Azure Monitor only provides support when using the supported SDKs. We’re constantly assessing opportunities to expand our support for other languages, so follow our GitHub Announcements page to receive the latest SDK news.

applicationinsights-wordpress's People

Contributors

dmitry-matveev avatar jackscottau avatar jakuboleksy avatar lukdanek avatar mattmccleary avatar sergeykanzhelev avatar stefanvangastel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

applicationinsights-wordpress's Issues

Apparent Issue with Decoupled Wordpress Installations

We have a 4.9.8 Installation running in an Azure App Service. The Application Insights plugin is installed and configured with the appropriate instrumentation key. Wordpress, in this instance, is being used only as a backend with a React application using the data via the WP Rest Api. From what we can tell, Application insights is only logging requests or errors that occur in the UI of the Worpress installation. We can see activity if we browse to /wp-admin/ for example but see nothing for any of the rest endpoints.

I'm trying to work out if we have some misconfiguration or, if the API never loads the plugin and therefore never logs any data.

Functions are called incorrectly in Server_instrumentation.php

I get these errors in a continuous loop while debug is turned on. I had to add some code to my WP install in the "_doing_it_wrong" function to find out the culprit, and it was this plugin. Here's a snippet:

[06-Apr-2020 19:23:26 UTC] PHP Notice:  is_page was called <strong>incorrectly</strong> (in D:\home\site\wwwroot\wp-content\plugins\application-insights\src\Server_Instrumentation.php line 33). Conditional query tags do not work before the query is run. Before then, they always return false. Please see <a href="https://codex.wordpress.org/Debugging_in_WordPress">Debugging in WordPress</a> for more information. (This message was added in version 3.1.0.) in D:\home\site\wwwroot\wp-includes\functions.php on line 4674
[06-Apr-2020 19:23:26 UTC] PHP Notice:  is_single was called <strong>incorrectly</strong> (in D:\home\site\wwwroot\wp-content\plugins\application-insights\src\Server_Instrumentation.php line 33). Conditional query tags do not work before the query is run. Before then, they always return false. Please see <a href="https://codex.wordpress.org/Debugging_in_WordPress">Debugging in WordPress</a> for more information. (This message was added in version 3.1.0.) in D:\home\site\wwwroot\wp-includes\functions.php on line 4674
[06-Apr-2020 19:23:26 UTC] PHP Notice:  is_category was called <strong>incorrectly</strong> (in D:\home\site\wwwroot\wp-content\plugins\application-insights\src\Server_Instrumentation.php line 33). Conditional query tags do not work before the query is run. Before then, they always return false. Please see <a href="https://codex.wordpress.org/Debugging_in_WordPress">Debugging in WordPress</a> for more information. (This message was added in version 3.1.0.) in D:\home\site\wwwroot\wp-includes\functions.php on line 4674
[06-Apr-2020 19:23:26 UTC] PHP Notice:  is_home was called <strong>incorrectly</strong> (in D:\home\site\wwwroot\wp-content\plugins\application-insights\src\Server_Instrumentation.php line 33). Conditional query tags do not work before the query is run. Before then, they always return false. Please see <a href="https://codex.wordpress.org/Debugging_in_WordPress">Debugging in WordPress</a> for more information. (This message was added in version 3.1.0.) in D:\home\site\wwwroot\wp-includes\functions.php on line 4674
[06-Apr-2020 19:23:26 UTC] PHP Notice:  is_archive was called <strong>incorrectly</strong> (in D:\home\site\wwwroot\wp-content\plugins\application-insights\src\Server_Instrumentation.php line 33). Conditional query tags do not work before the query is run. Before then, they always return false. Please see <a href="https://codex.wordpress.org/Debugging_in_WordPress">Debugging in WordPress</a> for more information. (This message was added in version 3.1.0.) in D:\home\site\wwwroot\wp-includes\functions.php on line 4674
[06-Apr-2020 19:23:26 UTC] PHP Notice:  is_404 was called <strong>incorrectly</strong> (in D:\home\site\wwwroot\wp-content\plugins\application-insights\src\Server_Instrumentation.php line 33). Conditional query tags do not work before the query is run. Before then, they always return false. Please see <a href="https://codex.wordpress.org/Debugging_in_WordPress">Debugging in WordPress</a> for more information. (This message was added in version 3.1.0.) in D:\home\site\wwwroot\wp-includes\functions.php on line 4674

Line 33 of the file in question is the if-statement within this function:

function endRequest()
    {
        if (is_page() || is_single() || is_category() || is_home() || is_archive() || is_404())
        {
            $url = $_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"];
            $requestName = Common::getPageTitle();
            $startTime = $_SERVER["REQUEST_TIME"];
            $duration = floatval(timer_stop(0, 3)) * 1000;
            $this->_telemetryClient->trackRequest($requestName, $url, $startTime, $duration, http_response_code(), !is_404());

            // Flush all telemetry items
            $this->_telemetryClient->flush();
        }
    }

I don't know why, when, or where "endRequest" is being called, or why it's doing so before the query is run, but it seems kind of important...

Error on line 10

Line 10 requires that a file be loaded, but the file isn't included, so the plugin is useless in it's current state.

Regex not working on a client instrumentation Page name

Hello
Plugin bug on tracking title on certain page :

image

I don't know if this is this statement

or more complexe regex trouble but it raise on error like that :
Uncaught SyntaxError: missing ) after argument list

Page name pattern on \wp-content\plugins\application-insights\src\Client_Instrumentation.php
$patterns[1] = '/PAGE_NAME/';
if (is_home() == false)
{
$replacements[1] = get_the_title();
}
else
{
$replacements[1] = 'Home';
}

Telemetry send but errors generated in php

Hello,
The php error log is full with 'Call to undefined function ApplicationInsights\Channel\utf8_encode()' errors.
Here is the full stack.
2016/03/15 12:53:36 [error] 1271#1271: *35 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught Error: Call to undefined function ApplicationInsights\Channel\utf8_encode() in /var/www/html/wp-content/plugins/application-insights/vendor/microsoft/application-insights/ApplicationInsights/Channel/Telemetry_Channel.php:165
Stack trace:
/var/www/html/wp-content/plugins/application-insights/vendor/microsoft/application-insights/ApplicationInsights/Telemetry_Client.php(281): ApplicationInsights\Channel\Telemetry_Channel->send()
/var/www/html/wp-content/plugins/application-insights/src/Server_Instrumentation.php(31): ApplicationInsights\Telemetry_Client->flush()
/var/www/html/wp-includes/plugin.php(525): ApplicationInsights\WordPress\Server_Instrumentation->endRequest('')
/var/www/html/wp-includes/load.php(635): do_action('shutdown')

{main}
thrown in /var/www/html/wp-content/plugins/application-insights/vendor/microsoft/application-insights/ApplicationInsights/Channel/Telemetry_Channel.php on line 165" while reading upstream, request: "GET /account/edit/ HTTP/2.0", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:"

Execution time sent in seconds and not miliseconds

Installed on WP 5.1.1

Receiving page request telemetry, but as 0s, 1s, 2s, etc ...
Looks like values are not sent in miliseconds which doesnt provide accurate results.

Also, are the errors captured with this plugin and can we see 500 errors with trace ?
What about dependencies ?

I'm also worried by the fact there were no updates over 2 years :)

I cannot activate the plugin

Hi,

I'm trying to using this plugin in my Wordpress but once is installed I cannot activate it. I click on Activate button but nothing happens.... It remains deactivated.

Any thoughts?

Error to active plugin on WordPress 4.2.2

I'm trying to use this plugin on my WordPress MU installation of 4.2.2, the following error occured when I activate the plugin

Plugin could not be activated because it triggered a fatal error.
Warning: require_once(vendor/autoload.php): failed to open stream: No such file or directory in D:\home\site\wwwroot\wp-content\plugins\application-insights\ApplicationInsightsPlugin.php on line 10 Fatal error: require_once(): Failed opening required 'vendor/autoload.php' (include_path='.;C:\php\pear') in D:\home\site\wwwroot\wp-content\plugins\application-insights\ApplicationInsightsPlugin.php on line 10

500 error: Class 'ApplicationInsights\WordPress\Settings' not found

I get the following error after activating the plugin:

Class 'ApplicationInsights\WordPress\Settings' not found on Line 13

 3:    Plugin Name: Application Insights
 4:    Description: Integrates a WordPress site with Microsoft Application Insights.
 5:    Version: 2.3
 6:    Author: ApplicationInsights
 7:    License:  MIT
 8:     */
 9:    
10:    require_once 'vendor/autoload.php';
11:    
12:    // Enables Admin configuration experience
13:    $mySettingsPage = new ApplicationInsights\WordPress\Settings();
14:    
15:    // Enables client-side instrumentation
16:    $clientInstrumentation = new ApplicationInsights\WordPress\Client_Instrumentation();
17:    add_action('wp_head', array($clientInstrumentation, 'addPrefix'));

WordPress 4.9.1
PHP 7.2.10-0ubuntu0.18.04.1
Apache/2.4.29 (Ubuntu)

Weird issue with plugin at HostGator shared hosting

Hi,

I used this plugin at my blog hosted at HostGator but had to disable it because of few issues.

Suddenly my blog gave frequently error 500 and few times I saw error messages about curl (page rendered still well). I contacted support about server errors and they told me that my site has more processes than allowed for shared hosting. There were not many people visiting blog at this moment and I have had no issues like this even at some high peak moments. Issues disappeared after disabling this plugin.

As I got not much information by hosting support and they were not very interested in helping me. Therefore I have no feedback by their techies about what was going on at server. As far as I understood from mere mortal feedback given by first line support then for some reason my site spawned new processes and at one point it reached the limit.

Is it possible that some libraries used with this plugin start new processes and is there any way to avoid it?

Memory usage

Hello!

When i enable this plugin, memory consumption grow up very high on the servers (classic LAMP).

This is when plugin disabled.

[L root@centos-web02 ~]$ free -h
              total        used        free      shared  buff/cache   available
Mem:           7.7G        1.0G        4.3G        352M        2.4G        6.0G
Swap:          2.0G        326M        1.7G

And this when enabled.

[L root@centos-web02 ~]$ ps aux | gfree -h
              total        used        free      shared  buff/cache   available
Mem:           7.7G        2.7G        2.7G        198M        2.3G        4.5G
Swap:          2.0G        520M        1.5G

Failed opening required 'vendor/autoload.php'

Something seems to be missing in this repo. It seems you have to install composer before you can add the plugin to your Wordpress site. Would it be possible to include all the required files in this repo?

I get HTTP 500 after some days working in production

Hi all I have a wordpress installation inside a docker container running on azure appservice for Linux.

The plugin has started creating exceptions that made the server unresponsive.

Unfortunately I don't have the docker container logs. Because we re-imaged the server in order to recover, but it clearly stated an exception while trying to access an application insights http route. One more indication for this is that no exception/http500 ever was retrieved and shown in the app insights failures tab. Only the azure AppService http500 chart traced the problem (this is essentialy reported by the proxy/loadbalacer which runs on windows).

I will try to recover the logs and post back if possible.

Is there by any chance a reason why this may be happening.

PHP Fatal error: Uncaught TypeError: Argument exceptionHandler

On PHP 7

PHP Fatal error: Uncaught TypeError: Argument 1 passed to ApplicationInsights\WordPress\Server_Instrumentation::exceptionHandler() must be an instance of Exception, instance of Error given in D:\home\site\wwwroot\wp-content\plugins\application-insights\src\Server_Instrumentation.php:56
Stack trace:
#0 [internal function]: ApplicationInsights\WordPress\Server_Instrumentation->exceptionHandler(Object(Error))

The Server_Instrumentation is not compatible with php7
http://php.net/set_exception_handler

Not working as per instructions in readme.txt

I've just tried to upload the code to an existing Wordpress site. I see the plugin in the WordPress admin plugin page but when I try to activate the plugin I get this:

Warning: require_once(vendor/autoload.php): failed to open stream: No such file or directory in /var/www/html/wp-content/plugins/ApplicationInsights/ApplicationInsightsPlugin.php on line 10

Fatal error: require_once(): Failed opening required 'vendor/autoload.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/html/wp-content/plugins/ApplicationInsights/ApplicationInsightsPlugin.php on line 10

Where is the /vendor/ stuff supposed to come from?

This is a Wordpress site running in a Ubuntu VM in Azure.
/Joakim

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.