-
-
Notifications
You must be signed in to change notification settings - Fork 452
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
Add Trace on captureMessage #859
Comments
What you're searching for is the It's the doc of the unified API. |
Thanks for the hint @Jean85 , i will take a deeper look into this. As far as i can see from the docs you provided, this allows me to turn it off, but does not explain how to provided stack trace informations? Maybe you could show me the part in the php sdk where the stack trace is provided? Thank you very much for the help! Here you could see how i currently try to send the proper exception: https://github.com/luyadev/luya-module-errorapi/blob/sentry-adapter/src/adapters/SentryAdapter.php |
Nope, that option is |
And how can i then provide the trace informations? (thanks for your help!) |
As mentioned in the documentation when setting Or is it something specific you would like to attach that we're not understanding? |
Hey @stayallive thanks for helping me on this. Yes, i want to send the trace informations by myself because the error api module we have made (https://github.com/luyadev/luya-module-errorapi) already recieves the error informations from the different websites, including stack trace, ip, etc. - so now we don't want to use the PHP SDK's strack trace, as we don't have exceptions. So basically our MODULE recives the json including the data (this one for example => https://github.com/luyadev/luya-module-errorapi/blob/sentry-adapter/tests/adapters/SentryAdapterTest.php#L25-L82) And now we want to pass this informations to senty - including stack trace, etc.Therfore we use |
If i inspect the json payload from a sentry error message i can see there is a json key
So basically what i am asking my self, how does the php sdk create the event? :D What payload to which endpoint? Update: So i was trying to use the captureEvent with strack trace payload, but this won't work as well: Sentry\captureEvent([
"message" => 'NEW ERROR: ' . time(),
"stacktrace" => [
"frames" => [
[
"function" => 'fn()',
"abs_path" => 'path/',
"pre_context" => [],
"post_context" => [],
"filename" => 'cih.php',
"lineno" => 12,
"in_app" => true,
"context_line" => 'path/cli()',
]
]
]
]); |
You should take a peek into our source code starting from here: https://github.com/getsentry/sentry-php/blob/master/src/EventFactory.php#L67-L71 |
I guess what i was looking for was this: https://docs.sentry.io/development/sdk-dev/overview/ Because i have to do everything by myself i assume. Thank you @Jean85 @stayallive for pointing me into the right direction! For anyone else maybe googling into this issue:
This is what my example payload array lookes like: $examplePayLoad = [
'transaction' => $data->getRequestUri(),
'server_name' => $data->getServerName(),
'fingerprint' => [
$data->getRequestUri(),
$data->getServerName(),
],
'logger' => 'luya.errorapi',
'platform' => 'php',
'sdk' => [
'name' => 'luya-errorapi',
'version' => '1.0.0',
],
'environment' => 'prod',
'level' => 'error',
'tags' => [
'luya_version' => '1.0',
],
'exception' => [
'values' => [
[
'type' => 'Exception',
'value' => $data->getErrorMessage(),
'stacktrace' => [
'frames' => [
'filename' => $trace->file,
'function' => $trace->function,
'lineno' => $trace->line,
'module' => $trace->class,
]
]
]
]
]
]; |
@nadar you don't normally need to do it all by yourself, the SDK should be used to do that. Point is that you have a strange setup, where a separate piece of software of your own is acting as a middleman between the project having errors and Sentry itself. If you install Sentry directly in your project, you can cut out the middleman and use the automatic stacktrace detection. |
Yes @Jean85, this is exactly the point, i thought the PHP SDK could be configured to take those certain data - but it does not, i understand that. I would not call it a "strange" setup, as the solution allows use the integrate error handling without even define a DNS for every project. Configure and Setup hundreds of Websites would be a pain this way 😄 Thanks anyhow for helping me! And maybe i could solve this questions for others. |
Even though it's a bit more verbose, you can actually do it with the SDK by creating an event processor. Those will be executed when the scope's information are added to the event and before the event itself is sent, so it's the perfect place to modify its data. A rough example of the code could be: Scope::addGlobalEventProcessor(static function (Event $event, array $payload): Event {
if (isset($payload['exceptions'])) {
$event->setExceptions($payload['exceptions']);
}
return $event;
});
captureEvent([
'exceptions' => [
...,
],
]); However, I don't really see the point in using the SDK if you just want to collect data from a third party service and proxy it to Sentry as it could be done more easily by just using an HTTP client, cURL or whatever else you prefer and send the raw data. This of course has the drawbacks that you have to implement the authentication handling yourself and build the entire payload to send |
Hey there, as i could not find anything in the code, nor in the docs and no community resources are provided (slack, gitter), i try to ask my question here (as an issue, which is actually never a good place for questions):
I have a situation where an error module acts as proxy in order to gather error informations from several sites at one place. So i have a json with all the php exception informations including trace.
As i have found out that i can send the error message like this:
So far so good. But what really makes the error message meaning full are all the other information like trace. How can i send trace information? How does the error handler internally send the trace information? Is it a "Breadcrumb" object i can attache to the Scope object? Is there any easy to read and understand example in how the internal error handler converts the exception and sends it to the sentry API?
All the information about "capture message" is could find is this one: https://docs.sentry.io/enriching-error-data/context/?platform=php
(also i could not find an api endpoint in the sentry docs i could use)
The text was updated successfully, but these errors were encountered: