Giter Site home page Giter Site logo

Comments (10)

robbieaverill avatar robbieaverill commented on May 25, 2024

cc @samuel-holt

from raygun4php.

samuel-holt avatar samuel-holt commented on May 25, 2024

Hi @siekanski

You could include the request data in the UserCustomData, this is an associative array that can be sent with the error payload.

This could be set at the top level to be sent with each payload.

For example:

$tags = [];
$customData = [
  "requestUri" => "ENCRYPTED_REQUEST_DATA_HERE"
];

set_error_handler(function ($errno, $errstr, $errfile, $errline) use ($raygunClient, $tags, $customData) {
  $raygunClient->SendError($errno, $errstr, $errfile, $errline, $tags, $customData);
});

Or when a specific exception occurs:

try {
  // ...
} catch (Exception $e) {
  $customData = [
    "requestUri" => "ENCRYPTED_REQUEST_DATA_HERE"
  ];

  $raygunClient->SendException($e, null, $customData);
}

In this case, you would need to ensure that the request data does not contain any PII or other sensitive data. Let me know if this could work for you. You can also contact support directly here if you would like to discuss this further.

Thanks
Sam

from raygun4php.

siekanski avatar siekanski commented on May 25, 2024

Hi @samuel-holt ,

Thank you very much for such a quick and professional response. Your solution is enough for me and is helpful. We can close this topic. :)

Best regards,
siekan

from raygun4php.

siekanski avatar siekanski commented on May 25, 2024

@samuel-holt

I have one more question, but I will write it already here. Are you able to help me with logging in to both the api and the docker? It seems to me that after the implementation of your client, login takes place only on the site, while the docker logs command has stopped recording it.

Thanks
siekan

from raygun4php.

samuel-holt avatar samuel-holt commented on May 25, 2024

Hi @siekanski

I've created this PR that has an example docker config. I did run into an issue where the log file was not outputting, which I solved here by changing the owner of the /var/www directory to be www-data. I did also have to create the src/debug.log file before doing the docker-compose build.

Let me know if this is helpful, or contact us here if you want to discuss it in greater detail.

Thanks
Sam

from raygun4php.

siekanski avatar siekanski commented on May 25, 2024

Hi @samuel-holt

Thanks for the reply, however the problem I'm facing is this: errors are being sent to the raygun but there is no exact error message being passed. I know where something happened and what the request was, but I have no information, as is always the case in docker logs, what the exact error message is. I've only got a brief, e. g. Undefinet offset [3]. In dokcer logs in the same situation I have information what is wrong with the parameter and I know exactly what to look for. What's more after plugging the raygun in, as I wrote, the errors go to the raygun application but automatically the logs in the docker stop displaying any message. All I know is that it flew 500 and nothing else. Here is a piece on how to plug in the raygun.

` $transport = new GuzzleAsync($httpClient);
$raygunClient = new RaygunClient($transport);
$raygunClient = RaygunService::filterParams($raygunClient);
$tags = [];
$customData = [
"requestUri" => RaygunService::createRequestUri($request)
];

set_error_handler(function ($errno, $errstr, $errfile, $errline) use ($raygunClient, $tags, $customData) {
    $raygunClient->SendError($errno, $errstr, $errfile, $errline, $tags, $customData);
});

set_exception_handler(function ($exception) use ($raygunClient, $customData) {
    $raygunClient->SendException($exception, null, $customData);
});

register_shutdown_function(function () use ($raygunClient, $tags, $customData) {
    $lastError = error_get_last();

    if ($lastError !== null) {
        [$type, $message, $file, $line] = $lastError;
        $raygunClient->SendError($type, $message, $file, $line, $tags, $customData);
    }
});

register_shutdown_function([$transport, 'wait']);`

from raygun4php.

siekanski avatar siekanski commented on May 25, 2024

I need a way to get the error messages into both the raygun app as well as the docker logs

from raygun4php.

samuel-holt avatar samuel-holt commented on May 25, 2024

Hi @siekanski,

Sorry, I misunderstood your previous message. Fortunately, setting up a Docker container helped to solve this. In this case, I would recommend using the PHP error_log function. For example:

set_error_handler(function ($errno, $errstr, $errfile, $errline) use ($raygunClient, $tags, $customData) {
    $raygunClient->SendError($errno, $errstr, $errfile, $errline, $tags, $customData);
    error_log("[RAYGUN_CAPTURED_ERROR] {$errstr}", $errno, $errfile);
});

I can now see the following logged in my docker log:

web_1  | [Wed Apr 28 04:14:54.265646 2021] [php7:notice] [pid 18] [client 127.0.0.1:46664] [RAYGUN_CAPTURED_ERROR] Undefined index: time
web_1  | [Wed Apr 28 04:14:54.266654 2021] [php7:notice] [pid 18] [client 127.0.0.1:46664] [RAYGUN_CAPTURED_ERROR] Undefined index: distance

Thanks,
Sam

from raygun4php.

GuySartorelli avatar GuySartorelli commented on May 25, 2024

@samuel-holt @siekanski Has this been resolved? Or is there still some issue here?

from raygun4php.

siekanski avatar siekanski commented on May 25, 2024

we can close it

from raygun4php.

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.