sentry-java
sentry-java copied to clipboard
MonoRepo has multiple source-roots - needs `root_source_code_paths`
Platform:
- [V] Java -> Java 17 (I'm actually using dropwizard-sentry, which is based on sentry-logback)
IDE:
- [V] IntelliJ -> 2021.3
Build system:
- [V] Gradle
Platform installed with:
- [V] JCenter
The version of the SDK: 5.5.2
I have the following issue: My project is a mono-repo - it contains many sub-projects, each with its own sources (Kotlin). directory structure is something like this:
-|-QuestionnaireService
| |
| | - src/main/java/com/acmi/questionnaire
| | - foo
| | - question.java
| | - bar
| | - option.java
|
|- DocumentGeneratorService
| | - src/main/java/com/acmi/docgen
| | - page
| | - section.java
| | - paragraph.java
So I'll have 2 service (in this example. in reality - dozens), each with its own configuration, sending ERROR events to sentry. But each has a different source root -
- QuestionnaireService -
QuestionnaireService/src/main/java - DocumentGeneratorService -
DocumentGeneratorService/src/main/java
For that reason, I can't seem to be able to use suspect commits, and other features.
Expected result: I should be able to configure several source-roots, or have Sentry "investigate" my repo automatically.
I saw a similar issue in Elixir SDK:
https://github.com/getsentry/sentry/issues/26026
I understand that it was solved by adding configuration in the sdk called root_source_code_paths.
If that's what I think it is, it can also solve my problem, if it's accessible by sentry-logback integration (and later on - by dropwizard-sentry)
Update
I've seen "Suspect Commit" on one issue 🎉 .
The stacktrace was from QuestionnaireService, which is the only sub-project that I have mapping for,
so that suggests that I was right about the mapping - and if so, I can only get suspect commits for a very small portion of my code-base (just QuestionnaireService, or pick another sub-project).
Hey @pinkasey thanks for opening the issue, could you share a bit more details about your setup? I assume you've been through https://docs.sentry.io/platforms/java/configuration/releases/ and https://docs.sentry.io/product/releases/suspect-commits/ ?
@romtsn thank you very much for the quick reply, this time of year 🎅 🎆 🎄
First, an update -
I've seen "Suspect Commit" on one issue since I've opened this issue 🎉
The stacktrace was from QuestionnaireService, which is the only sub-project that I have mapping for,
so that suggests that I was right about the mapping - and if so, I can only get suspect commits for a very small portion of my code-base (just QuestionnaireService, or pick another sub-project).
Yes, I've read the 2 pages you've mentioned, and more. Thanks. I'm pretty sure that my setup for releases works - I see link to a release in every issue, and it is correct. I also see, in every release, the number of issues associated with it, and I think it's correct too (I've seen releases with 1 issue, most have 0, as we release dozens time a day)
about my setup -
Project structure
as mentioned in the issue description, in my git repo (backend in Kotlin), there are many sub-directories, some of which are backend services:
QuestionnaireServiceDocumentGeneratorService- ... each such directory is a sub-project, it compiles and deployed in its own pipeline (there are some shared code in shared directories)
SDK config
Our services are based on Dropwizard, which supports logback for logging.
So I figured the easiest way to integrate with Sentry would be using the dropwizard-sentry plugin.
So in each service we have config file for dropwizard, config-prod.yaml (and config-stg.yaml for staging), and here's the sentry part:
logging:
appenders:
- type: sentry
threshold: ERROR
dsn: ${enc:Fq....8=}
environment: prod
mdcTags:
- 'context'
- 'reqDurationMS'
- 'reqURL'
- 'responseStatusCode'
- 'reqMethod'
- 'traceId'
- 'spanId'
- 'requestId'
# sentryClientFactory: com.example.SentryClientFactory
release: ${GIT_COMMIT:-git_commit}
# serverName: 10.0.0.1
tags:
service: QuestionnaireService
commit: ${GIT_COMMIT:-git_commit}
stacktraceAppPackages: ['com.nextinsurance','com.ni']
Release Management
I use the github action on every merge to master, as described here. Every merge to master means some service got deployed, which is not ideal maybe (perhaps I want each service to publish a version when it is deployed), but I don't think it's a problem and I don't want to over-complicate.
name: Sentry Release
on:
push:
branches:
- 'master'
jobs:
update_sentry_release:
name: Update Sentry Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: getsentry/[email protected]
name: Create Sentry release
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: "____" #forgive my paranoia for censoring this
SENTRY_PROJECT: "backend-prod"
with:
environment: production
# projects: "backend-prod backend-stg" # this didn't work for some reason. maybe it does.
Sentry configuration
I have a project for production and a project for staging environments.
in the github integration part, I've added the mapping noted above:
which seems to work.
Anything else I didn't cover?
We're reaching out to folks from the workflow team, we'll get back to this once we learn more.
@vladistol @talrom @roypillar FYI
I'm facing a similar issue. Have we found a solution for this?
@bruno-garcia do you remember what was the outcome from the workflow team? Can this be something for the new mobile experience team?