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

Transaction not getting associated with Errors on Elastic Cloud APM #78

Closed
abhishek1234graphs opened this issue Jul 15, 2022 · 6 comments · Fixed by #79
Closed

Transaction not getting associated with Errors on Elastic Cloud APM #78

abhishek1234graphs opened this issue Jul 15, 2022 · 6 comments · Fixed by #79

Comments

@abhishek1234graphs
Copy link

If you notice the latest intake/v2/events Error schema on https://www.elastic.co/guide/en/apm/guide/current/api-error.html, along with the transaction_id, a transaction object should also be present in the incoming JSON.
Now in jsonSerialize function of Nipwaayoni\Events\Error, the transaction key is not present. Therefore this key is never included during API calls made to Elastic Cloud APM Server.
I called the API with and without the transaction key - the resulting Error (captured using captureThrowable function) got associated with a Transaction only if this key is included in the request body. Without the inclusion of this key, the Transaction correctly displays the presence of an Error, but never really redirects to the Error upon trying to inspect the associated Error separately (when you click on "View related error" on the Transaction).
Is it possible for you to upgrade Nipwaayoni\Events\Error to appropriately include this new Schema?

@dstepe
Copy link
Contributor

dstepe commented Jul 15, 2022

Thanks for bringing this up. I won't be able to look at updating the package to support the 8.3 schema for a couple of days, and cannot provide an estimate on when it may be complete. I'd like to review the new schema for more than just the issue you identified with the error object. I will look at it when I have an opportunity, though.

@abhishek1234graphs
Copy link
Author

@dstepe thank you for your assurance!
I think this further explains the issue: elastic/apm#531

@dstepe
Copy link
Contributor

dstepe commented Jul 20, 2022

@abhishek1234graphs I believe the necessary change is available on the add-apm-8-support branch. If you are able to try that branch in your specific use case, I would appreciate the feedback. I'd like to look over the 8.x schema a bit more to see if there are other useful changes before merging this and making a new release.

@abhishek1234graphs
Copy link
Author

@dstepe
I think the jsonSerialize function of Nipwaayoni\Events\Error should be:

public function jsonSerialize(): array
    {
        

    return [
            $this->eventType => array_merge(
                [
                    'id'             => $this->getId(),
                    'transaction_id' => $this->getParentId(),
                    'parent_id'      => $this->getParentId(),
                    'trace_id'       => $this->getTraceId(),
                    'timestamp'      => $this->getTimestamp(),
                    'context'        => $this->getContext(),
                    'culprit'        => Encoding::keywordField(sprintf('%s:%d', $this->throwable->getFile(), $this->throwable->getLine())),
                    'exception'      => [
                        'message'    => $this->throwable->getMessage(),
                        'type'       => Encoding::keywordField(get_class($this->throwable)),
                        'code'       => $this->throwable->getCode(),
                        'stacktrace' => $this->mapStacktrace(),
                    ],
                ]
            , $this->transactionData())
        ];
    }

I changed the position of the array_merge function.

@dstepe
Copy link
Contributor

dstepe commented Jul 26, 2022

Good catch. I was clearly not paying attention. Thanks. That should be fixed if you want to give it a try.

@abhishek1234graphs
Copy link
Author

Hi @dstepe !
Good job transforming the code to fix elastic/apm#531. I have tested the add-apm-8-support branch and can verify that Transactions are now getting correlated with Errors properly on Elastic APM's latest version (that is hosted on Elastic Cloud).
Is it possible for you to merge add-apm-8-support with the main branch and publish your changes to Packagist? Just to notify you, we rely on https://github.com/arkaitzgarro/elastic-apm-laravel.

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

Successfully merging a pull request may close this issue.

2 participants