Skip to content

Commit 42e3a25

Browse files
authored
Merge c4bcd1a into d590d3e
2 parents d590d3e + c4bcd1a commit 42e3a25

File tree

72 files changed

+2512
-88
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+2512
-88
lines changed

.github/workflows/system-tests-backend.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,13 @@ jobs:
2020
fail-fast: false
2121
matrix:
2222
sample: [ "sentry-samples-spring-boot-jakarta" ]
23+
agent: [ "0" ]
2324
include:
2425
- sample: "sentry-samples-spring-boot"
2526
- sample: "sentry-samples-spring-boot-webflux-jakarta"
2627
- sample: "sentry-samples-spring-boot-webflux"
28+
- sample: "sentry-samples-spring-boot-jakarta-opentelemetry"
29+
agent: "1"
2730
steps:
2831
- uses: actions/checkout@v4
2932
with:
@@ -56,9 +59,13 @@ jobs:
5659
run: |
5760
./gradlew :sentry-samples:${{ matrix.sample }}:bootJar
5861
62+
- name: Build agent jar
63+
run: |
64+
./gradlew :sentry-opentelemetry:sentry-opentelemetry-agent:assemble
65+
5966
- name: Start server and run integration test for sentry-cli commands
6067
run: |
61-
test/system-test-sentry-server-start.sh > sentry-mock-server.txt 2>&1 & test/system-test-spring-server-start.sh "${{ matrix.sample }}" > spring-server.txt 2>&1 & test/wait-for-spring.sh && ./gradlew :sentry-samples:${{ matrix.sample }}:systemTest
68+
test/system-test-sentry-server-start.sh > sentry-mock-server.txt 2>&1 & test/system-test-spring-server-start.sh "${{ matrix.sample }}" "${{ matrix.agent }}" > spring-server.txt 2>&1 & test/wait-for-spring.sh && ./gradlew :sentry-samples:${{ matrix.sample }}:systemTest
6269
6370
- name: Upload test results
6471
if: always()

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
- `globalHubMode` used to only be a param on `Sentry.init`. To make it easier to be used in e.g. Desktop environments, we now additionally added it as an option on SentryOptions that can also be set via `sentry.properties`.
99
- If both the param on `Sentry.init` and the option are set, the option will win. By default the option is set to `null` meaning whatever is passed to `Sentry.init` takes effect.
1010

11+
### Fixes
12+
13+
- Add `auto.graphql.graphql22` to ignored span origins when using OpenTelemetry
14+
- The Spring Boot 3 WebFlux sample now uses our GraphQL v22 integration
15+
1116
### Behavioural Changes
1217

1318
- (Android) Enable Performance V2 by default ([#3824](https://github.com/getsentry/sentry-java/pull/3824))

build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ apiValidation {
6060
"sentry-samples-spring-jakarta",
6161
"sentry-samples-spring-boot",
6262
"sentry-samples-spring-boot-jakarta",
63+
"sentry-samples-spring-boot-jakarta-opentelemetry",
6364
"sentry-samples-spring-boot-webflux",
6465
"sentry-samples-spring-boot-webflux-jakarta",
6566
"sentry-uitest-android",
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# Sentry Sample Spring Boot 3.0+
2+
3+
Sample application showing how to use Sentry with [Spring boot](http://spring.io/projects/spring-boot) from version `3.0` onwards.
4+
5+
## How to run?
6+
7+
To see events triggered in this sample application in your Sentry dashboard, go to `src/main/resources/application.properties` and replace the test DSN with your own DSN.
8+
9+
Then, execute a command from the module directory:
10+
11+
```
12+
../../gradlew bootRun
13+
```
14+
15+
Make an HTTP request that will trigger events:
16+
17+
```
18+
curl -XPOST --user user:password http://localhost:8080/person/ -H "Content-Type:application/json" -d '{"firstName":"John","lastName":"Smith"}'
19+
```
20+
21+
## GraphQL
22+
23+
The following queries can be used to test the GraphQL integration.
24+
25+
### Greeting
26+
```
27+
{
28+
greeting(name: "crash")
29+
}
30+
```
31+
32+
### Greeting with variables
33+
34+
```
35+
query GreetingQuery($name: String) {
36+
greeting(name: $name)
37+
}
38+
```
39+
variables:
40+
```
41+
{
42+
"name": "crash"
43+
}
44+
```
45+
46+
### Project
47+
48+
```
49+
query ProjectQuery($slug: ID!) {
50+
project(slug: $slug) {
51+
slug
52+
name
53+
repositoryUrl
54+
status
55+
}
56+
}
57+
```
58+
variables:
59+
```
60+
{
61+
"slug": "statuscrash"
62+
}
63+
```
64+
65+
### Mutation
66+
67+
```
68+
mutation AddProjectMutation($slug: ID!) {
69+
addProject(slug: $slug)
70+
}
71+
```
72+
variables:
73+
```
74+
{
75+
"slug": "nocrash",
76+
"name": "nocrash"
77+
}
78+
```
79+
80+
### Subscription
81+
82+
```
83+
subscription SubscriptionNotifyNewTask($slug: ID!) {
84+
notifyNewTask(projectSlug: $slug) {
85+
id
86+
name
87+
assigneeId
88+
assignee {
89+
id
90+
name
91+
}
92+
}
93+
}
94+
```
95+
variables:
96+
```
97+
{
98+
"slug": "crash"
99+
}
100+
```
101+
102+
### Data loader
103+
104+
```
105+
query TasksAndAssigneesQuery($slug: ID!) {
106+
tasks(projectSlug: $slug) {
107+
id
108+
name
109+
assigneeId
110+
assignee {
111+
id
112+
name
113+
}
114+
}
115+
}
116+
```
117+
variables:
118+
```
119+
{
120+
"slug": "crash"
121+
}
122+
```
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
import org.jetbrains.kotlin.config.KotlinCompilerVersion
2+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
3+
4+
plugins {
5+
id(Config.BuildPlugins.springBoot) version Config.springBoot3Version
6+
id(Config.BuildPlugins.springDependencyManagement) version Config.BuildPlugins.springDependencyManagementVersion
7+
kotlin("jvm")
8+
kotlin("plugin.spring") version Config.kotlinVersion
9+
id("com.apollographql.apollo3") version "3.8.2"
10+
}
11+
12+
group = "io.sentry.sample.spring-boot-jakarta"
13+
version = "0.0.1-SNAPSHOT"
14+
java.sourceCompatibility = JavaVersion.VERSION_17
15+
java.targetCompatibility = JavaVersion.VERSION_17
16+
17+
repositories {
18+
mavenCentral()
19+
}
20+
21+
configure<JavaPluginExtension> {
22+
sourceCompatibility = JavaVersion.VERSION_17
23+
targetCompatibility = JavaVersion.VERSION_17
24+
}
25+
26+
tasks.withType<KotlinCompile>().configureEach {
27+
kotlinOptions.jvmTarget = JavaVersion.VERSION_17.toString()
28+
}
29+
30+
tasks.withType<KotlinCompile> {
31+
kotlinOptions {
32+
freeCompilerArgs = listOf("-Xjsr305=strict")
33+
jvmTarget = JavaVersion.VERSION_17.toString()
34+
}
35+
}
36+
37+
dependencies {
38+
implementation(Config.Libs.springBoot3StarterSecurity)
39+
implementation(Config.Libs.springBoot3StarterActuator)
40+
implementation(Config.Libs.springBoot3StarterWeb)
41+
implementation(Config.Libs.springBoot3StarterWebsocket)
42+
implementation(Config.Libs.springBoot3StarterGraphql)
43+
implementation(Config.Libs.springBoot3StarterQuartz)
44+
implementation(Config.Libs.springBoot3StarterWebflux)
45+
implementation(Config.Libs.springBoot3StarterAop)
46+
implementation(Config.Libs.aspectj)
47+
implementation(Config.Libs.springBoot3Starter)
48+
implementation(Config.Libs.kotlinReflect)
49+
implementation(Config.Libs.springBootStarterJdbc)
50+
implementation(kotlin(Config.kotlinStdLib, KotlinCompilerVersion.VERSION))
51+
implementation(projects.sentrySpringBootStarterJakarta)
52+
implementation(projects.sentryLogback)
53+
implementation(projects.sentryGraphql22)
54+
implementation(projects.sentryQuartz)
55+
implementation(Config.Libs.OpenTelemetry.otelSdk)
56+
57+
// database query tracing
58+
implementation(projects.sentryJdbc)
59+
runtimeOnly(Config.TestLibs.hsqldb)
60+
testImplementation(Config.Libs.springBoot3StarterTest) {
61+
exclude(group = "org.junit.vintage", module = "junit-vintage-engine")
62+
}
63+
testImplementation(kotlin(Config.kotlinStdLib))
64+
testImplementation(Config.TestLibs.kotlinTestJunit)
65+
testImplementation("ch.qos.logback:logback-classic:1.3.5")
66+
testImplementation(Config.Libs.slf4jApi2)
67+
testImplementation(Config.Libs.apolloKotlin)
68+
}
69+
70+
configure<SourceSetContainer> {
71+
test {
72+
java.srcDir("src/test/java")
73+
}
74+
}
75+
76+
tasks.register<Test>("systemTest").configure {
77+
group = "verification"
78+
description = "Runs the System tests"
79+
80+
// maxParallelForks = Runtime.getRuntime().availableProcessors() / 2
81+
maxParallelForks = 1
82+
83+
// Cap JVM args per test
84+
minHeapSize = "128m"
85+
maxHeapSize = "1g"
86+
87+
filter {
88+
includeTestsMatching("io.sentry.systemtest*")
89+
}
90+
}
91+
92+
tasks.named("test").configure {
93+
require(this is Test)
94+
95+
filter {
96+
excludeTestsMatching("io.sentry.systemtest.*")
97+
}
98+
}
99+
100+
apollo {
101+
service("service") {
102+
srcDir("src/test/graphql")
103+
packageName.set("io.sentry.samples.graphql")
104+
outputDirConnection {
105+
connectToKotlinSourceSet("test")
106+
}
107+
}
108+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package io.sentry.samples.spring.boot.jakarta;
2+
3+
import io.sentry.EventProcessor;
4+
import io.sentry.Hint;
5+
import io.sentry.SentryEvent;
6+
import io.sentry.protocol.SentryRuntime;
7+
import org.jetbrains.annotations.NotNull;
8+
import org.springframework.boot.SpringBootVersion;
9+
import org.springframework.stereotype.Component;
10+
11+
/**
12+
* Custom {@link EventProcessor} implementation lets modifying {@link SentryEvent}s before they are
13+
* sent to Sentry.
14+
*/
15+
@Component
16+
public class CustomEventProcessor implements EventProcessor {
17+
private final String springBootVersion;
18+
19+
public CustomEventProcessor(String springBootVersion) {
20+
this.springBootVersion = springBootVersion;
21+
}
22+
23+
public CustomEventProcessor() {
24+
this(SpringBootVersion.getVersion());
25+
}
26+
27+
@Override
28+
public @NotNull SentryEvent process(@NotNull SentryEvent event, @NotNull Hint hint) {
29+
final SentryRuntime runtime = new SentryRuntime();
30+
runtime.setVersion(springBootVersion);
31+
runtime.setName("Spring Boot");
32+
event.getContexts().setRuntime(runtime);
33+
return event;
34+
}
35+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package io.sentry.samples.spring.boot.jakarta;
2+
3+
import io.sentry.spring.jakarta.checkin.SentryCheckIn;
4+
import io.sentry.spring.jakarta.tracing.SentryTransaction;
5+
import org.slf4j.Logger;
6+
import org.slf4j.LoggerFactory;
7+
import org.springframework.stereotype.Component;
8+
9+
/**
10+
* {@link SentryTransaction} added on the class level, creates transaction around each method
11+
* execution of every method of the annotated class.
12+
*/
13+
@Component
14+
@SentryTransaction(operation = "scheduled")
15+
public class CustomJob {
16+
17+
private static final Logger LOGGER = LoggerFactory.getLogger(CustomJob.class);
18+
19+
@SentryCheckIn("monitor_slug_1")
20+
// @Scheduled(fixedRate = 3 * 60 * 1000L)
21+
void execute() throws InterruptedException {
22+
LOGGER.info("Executing scheduled job");
23+
Thread.sleep(2000L);
24+
}
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package io.sentry.samples.spring.boot.jakarta;
2+
3+
public class Person {
4+
private final String firstName;
5+
private final String lastName;
6+
7+
public Person(String firstName, String lastName) {
8+
this.firstName = firstName;
9+
this.lastName = lastName;
10+
}
11+
12+
public String getFirstName() {
13+
return firstName;
14+
}
15+
16+
public String getLastName() {
17+
return lastName;
18+
}
19+
20+
@Override
21+
public String toString() {
22+
return "Person{" + "firstName='" + firstName + '\'' + ", lastName='" + lastName + '\'' + '}';
23+
}
24+
}

0 commit comments

Comments
 (0)