-
-
Notifications
You must be signed in to change notification settings - Fork 435
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
71 changed files
with
2,495 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
122 changes: 122 additions & 0 deletions
122
sentry-samples/sentry-samples-spring-boot-jakarta-opentelemetry/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
# Sentry Sample Spring Boot 3.0+ | ||
|
||
Sample application showing how to use Sentry with [Spring boot](http://spring.io/projects/spring-boot) from version `3.0` onwards. | ||
|
||
## How to run? | ||
|
||
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. | ||
|
||
Then, execute a command from the module directory: | ||
|
||
``` | ||
../../gradlew bootRun | ||
``` | ||
|
||
Make an HTTP request that will trigger events: | ||
|
||
``` | ||
curl -XPOST --user user:password http://localhost:8080/person/ -H "Content-Type:application/json" -d '{"firstName":"John","lastName":"Smith"}' | ||
``` | ||
|
||
## GraphQL | ||
|
||
The following queries can be used to test the GraphQL integration. | ||
|
||
### Greeting | ||
``` | ||
{ | ||
greeting(name: "crash") | ||
} | ||
``` | ||
|
||
### Greeting with variables | ||
|
||
``` | ||
query GreetingQuery($name: String) { | ||
greeting(name: $name) | ||
} | ||
``` | ||
variables: | ||
``` | ||
{ | ||
"name": "crash" | ||
} | ||
``` | ||
|
||
### Project | ||
|
||
``` | ||
query ProjectQuery($slug: ID!) { | ||
project(slug: $slug) { | ||
slug | ||
name | ||
repositoryUrl | ||
status | ||
} | ||
} | ||
``` | ||
variables: | ||
``` | ||
{ | ||
"slug": "statuscrash" | ||
} | ||
``` | ||
|
||
### Mutation | ||
|
||
``` | ||
mutation AddProjectMutation($slug: ID!) { | ||
addProject(slug: $slug) | ||
} | ||
``` | ||
variables: | ||
``` | ||
{ | ||
"slug": "nocrash", | ||
"name": "nocrash" | ||
} | ||
``` | ||
|
||
### Subscription | ||
|
||
``` | ||
subscription SubscriptionNotifyNewTask($slug: ID!) { | ||
notifyNewTask(projectSlug: $slug) { | ||
id | ||
name | ||
assigneeId | ||
assignee { | ||
id | ||
name | ||
} | ||
} | ||
} | ||
``` | ||
variables: | ||
``` | ||
{ | ||
"slug": "crash" | ||
} | ||
``` | ||
|
||
### Data loader | ||
|
||
``` | ||
query TasksAndAssigneesQuery($slug: ID!) { | ||
tasks(projectSlug: $slug) { | ||
id | ||
name | ||
assigneeId | ||
assignee { | ||
id | ||
name | ||
} | ||
} | ||
} | ||
``` | ||
variables: | ||
``` | ||
{ | ||
"slug": "crash" | ||
} | ||
``` |
108 changes: 108 additions & 0 deletions
108
sentry-samples/sentry-samples-spring-boot-jakarta-opentelemetry/build.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
import org.jetbrains.kotlin.config.KotlinCompilerVersion | ||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | ||
|
||
plugins { | ||
id(Config.BuildPlugins.springBoot) version Config.springBoot3Version | ||
id(Config.BuildPlugins.springDependencyManagement) version Config.BuildPlugins.springDependencyManagementVersion | ||
kotlin("jvm") | ||
kotlin("plugin.spring") version Config.kotlinVersion | ||
id("com.apollographql.apollo3") version "3.8.2" | ||
} | ||
|
||
group = "io.sentry.sample.spring-boot-jakarta" | ||
version = "0.0.1-SNAPSHOT" | ||
java.sourceCompatibility = JavaVersion.VERSION_17 | ||
java.targetCompatibility = JavaVersion.VERSION_17 | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
configure<JavaPluginExtension> { | ||
sourceCompatibility = JavaVersion.VERSION_17 | ||
targetCompatibility = JavaVersion.VERSION_17 | ||
} | ||
|
||
tasks.withType<KotlinCompile>().configureEach { | ||
kotlinOptions.jvmTarget = JavaVersion.VERSION_17.toString() | ||
} | ||
|
||
tasks.withType<KotlinCompile> { | ||
kotlinOptions { | ||
freeCompilerArgs = listOf("-Xjsr305=strict") | ||
jvmTarget = JavaVersion.VERSION_17.toString() | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation(Config.Libs.springBoot3StarterSecurity) | ||
implementation(Config.Libs.springBoot3StarterActuator) | ||
implementation(Config.Libs.springBoot3StarterWeb) | ||
implementation(Config.Libs.springBoot3StarterWebsocket) | ||
implementation(Config.Libs.springBoot3StarterGraphql) | ||
implementation(Config.Libs.springBoot3StarterQuartz) | ||
implementation(Config.Libs.springBoot3StarterWebflux) | ||
implementation(Config.Libs.springBoot3StarterAop) | ||
implementation(Config.Libs.aspectj) | ||
implementation(Config.Libs.springBoot3Starter) | ||
implementation(Config.Libs.kotlinReflect) | ||
implementation(Config.Libs.springBootStarterJdbc) | ||
implementation(kotlin(Config.kotlinStdLib, KotlinCompilerVersion.VERSION)) | ||
implementation(projects.sentrySpringBootStarterJakarta) | ||
implementation(projects.sentryLogback) | ||
implementation(projects.sentryGraphql22) | ||
implementation(projects.sentryQuartz) | ||
implementation(Config.Libs.OpenTelemetry.otelSdk) | ||
|
||
// database query tracing | ||
implementation(projects.sentryJdbc) | ||
runtimeOnly(Config.TestLibs.hsqldb) | ||
testImplementation(Config.Libs.springBoot3StarterTest) { | ||
exclude(group = "org.junit.vintage", module = "junit-vintage-engine") | ||
} | ||
testImplementation(kotlin(Config.kotlinStdLib)) | ||
testImplementation(Config.TestLibs.kotlinTestJunit) | ||
testImplementation("ch.qos.logback:logback-classic:1.3.5") | ||
testImplementation(Config.Libs.slf4jApi2) | ||
testImplementation(Config.Libs.apolloKotlin) | ||
} | ||
|
||
configure<SourceSetContainer> { | ||
test { | ||
java.srcDir("src/test/java") | ||
} | ||
} | ||
|
||
tasks.register<Test>("systemTest").configure { | ||
group = "verification" | ||
description = "Runs the System tests" | ||
|
||
// maxParallelForks = Runtime.getRuntime().availableProcessors() / 2 | ||
maxParallelForks = 1 | ||
|
||
// Cap JVM args per test | ||
minHeapSize = "128m" | ||
maxHeapSize = "1g" | ||
|
||
filter { | ||
includeTestsMatching("io.sentry.systemtest*") | ||
} | ||
} | ||
|
||
tasks.named("test").configure { | ||
require(this is Test) | ||
|
||
filter { | ||
excludeTestsMatching("io.sentry.systemtest.*") | ||
} | ||
} | ||
|
||
apollo { | ||
service("service") { | ||
srcDir("src/test/graphql") | ||
packageName.set("io.sentry.samples.graphql") | ||
outputDirConnection { | ||
connectToKotlinSourceSet("test") | ||
} | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...entelemetry/src/main/java/io/sentry/samples/spring/boot/jakarta/CustomEventProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package io.sentry.samples.spring.boot.jakarta; | ||
|
||
import io.sentry.EventProcessor; | ||
import io.sentry.Hint; | ||
import io.sentry.SentryEvent; | ||
import io.sentry.protocol.SentryRuntime; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.springframework.boot.SpringBootVersion; | ||
import org.springframework.stereotype.Component; | ||
|
||
/** | ||
* Custom {@link EventProcessor} implementation lets modifying {@link SentryEvent}s before they are | ||
* sent to Sentry. | ||
*/ | ||
@Component | ||
public class CustomEventProcessor implements EventProcessor { | ||
private final String springBootVersion; | ||
|
||
public CustomEventProcessor(String springBootVersion) { | ||
this.springBootVersion = springBootVersion; | ||
} | ||
|
||
public CustomEventProcessor() { | ||
this(SpringBootVersion.getVersion()); | ||
} | ||
|
||
@Override | ||
public @NotNull SentryEvent process(@NotNull SentryEvent event, @NotNull Hint hint) { | ||
final SentryRuntime runtime = new SentryRuntime(); | ||
runtime.setVersion(springBootVersion); | ||
runtime.setName("Spring Boot"); | ||
event.getContexts().setRuntime(runtime); | ||
return event; | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...-jakarta-opentelemetry/src/main/java/io/sentry/samples/spring/boot/jakarta/CustomJob.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package io.sentry.samples.spring.boot.jakarta; | ||
|
||
import io.sentry.spring.jakarta.checkin.SentryCheckIn; | ||
import io.sentry.spring.jakarta.tracing.SentryTransaction; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.stereotype.Component; | ||
|
||
/** | ||
* {@link SentryTransaction} added on the class level, creates transaction around each method | ||
* execution of every method of the annotated class. | ||
*/ | ||
@Component | ||
@SentryTransaction(operation = "scheduled") | ||
public class CustomJob { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(CustomJob.class); | ||
|
||
@SentryCheckIn("monitor_slug_1") | ||
// @Scheduled(fixedRate = 3 * 60 * 1000L) | ||
void execute() throws InterruptedException { | ||
LOGGER.info("Executing scheduled job"); | ||
Thread.sleep(2000L); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...oot-jakarta-opentelemetry/src/main/java/io/sentry/samples/spring/boot/jakarta/Person.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package io.sentry.samples.spring.boot.jakarta; | ||
|
||
public class Person { | ||
private final String firstName; | ||
private final String lastName; | ||
|
||
public Person(String firstName, String lastName) { | ||
this.firstName = firstName; | ||
this.lastName = lastName; | ||
} | ||
|
||
public String getFirstName() { | ||
return firstName; | ||
} | ||
|
||
public String getLastName() { | ||
return lastName; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Person{" + "firstName='" + firstName + '\'' + ", lastName='" + lastName + '\'' + '}'; | ||
} | ||
} |
Oops, something went wrong.