Skip to content

Commit bf6ed98

Browse files
authored
Fix reference to span in processOrderBatch function (#14741)
## DESCRIBE YOUR PR There's no `it`, should be `span`. ## IS YOUR CHANGE URGENT? Help us prioritize incoming PRs by letting us know when the change needs to go live. - [ ] Urgent deadline (GA date, etc.): <!-- ENTER DATE HERE --> - [ ] Other deadline: <!-- ENTER DATE HERE --> - [x] None: Not urgent, can wait up to 1 week+ ## SLA - Teamwork makes the dream work, so please add a reviewer to your PRs. - Please give the docs team up to 1 week to review your PR unless you've added an urgent due date to it. Thanks in advance for your help! ## PRE-MERGE CHECKLIST *Make sure you've checked the following before merging your changes:* - [ ] Checked Vercel preview for correctness, including links - [ ] PR was reviewed and approved by any necessary SMEs (subject matter experts) - [ ] PR was reviewed and approved by a member of the [Sentry docs team](https://github.com/orgs/getsentry/teams/docs) ## LEGAL BOILERPLATE <!-- Sentry employees and contractors can delete or ignore this section. --> Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms. ## EXTRA RESOURCES - [Sentry Docs contributor guide](https://docs.sentry.io/contributing/)
1 parent 4d72109 commit bf6ed98

File tree

2 files changed

+21
-20
lines changed
  • platform-includes/performance

2 files changed

+21
-20
lines changed

platform-includes/performance/add-spans-example/java.mdx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,9 @@ try {
2222
transaction.finish();
2323
}
2424

25-
void processOrderBatch(ISpan span) {
26-
if (span == null) {
27-
span = Sentry.startTransaction("processOrderBatch()", "task");
28-
}
25+
void processOrderBatch(ISpan parentSpan) {
2926
// span operation: task, span description: operation
30-
ISpan innerSpan = span.startChild("task", "operation");
27+
ISpan innerSpan = parentSpan.startChild("task", "operation");
3128
try {
3229
// omitted code
3330
} catch (FileNotFoundException e) {
@@ -57,9 +54,9 @@ try {
5754
transaction.finish()
5855
}
5956

60-
fun processOrderBatch(span: ISpan) {
57+
fun processOrderBatch(parentSpan: ISpan) {
6158
// span operation: task, span description: operation
62-
val innerSpan = it.startChild("task", "operation")
59+
val innerSpan = parentSpan.startChild("task", "operation")
6360

6461
try {
6562
// omitted code

platform-includes/performance/create-transaction-bound-to-scope/java.mdx

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,23 @@ try {
3232
}
3333

3434
void processOrderBatch() {
35-
ISpan span = Sentry.getSpan();
36-
if (span == null) {
37-
span = Sentry.startTransaction("processOrderBatch()", "task");
35+
ISpan parentSpan = Sentry.getSpan(); // returns the "processOrderBatch()" transaction
36+
ISpan innerSpan = null;
37+
if (parentSpan != null) {
38+
innerSpan = parentSpan.startChild("task", "operation");
3839
}
39-
ISpan innerSpan = span.startChild("task", "operation");
40+
4041
try {
4142
// omitted code
4243
} catch (FileNotFoundException e) {
43-
innerSpan.setThrowable(e);
44-
innerSpan.setStatus(SpanStatus.NOT_FOUND);
44+
if (innerSpan != null) {
45+
innerSpan.setThrowable(e);
46+
innerSpan.setStatus(SpanStatus.NOT_FOUND);
4547
throw e;
4648
} finally {
47-
innerSpan.finish();
49+
if (innerSpan != null) {
50+
innerSpan.finish();
51+
}
4852
}
4953
}
5054
```
@@ -67,18 +71,18 @@ try {
6771
transaction.finish()
6872
}
6973

70-
fun processOrderBatch(item: Item) {
71-
val span = Sentry.getSpan() ?: Sentry.startTransaction("processOrderBatch()", "task")
72-
val innerSpan = it.startChild("task", "operation")
74+
fun processOrderBatch() {
75+
val parentSpan = Sentry.getSpan() // returns the "processOrderBatch()" transaction
76+
val innerSpan = parentSpan?.startChild("task", "operation")
7377

7478
try {
7579
// omitted code
7680
} catch (e: FileNotFoundException) {
77-
innerSpan.throwable = e
78-
innerSpan.status = SpanStatus.NOT_FOUND
81+
innerSpan?.throwable = e
82+
innerSpan?.status = SpanStatus.NOT_FOUND
7983
throw e
8084
} finally {
81-
innerSpan.finish()
85+
innerSpan?.finish()
8286
}
8387
}
8488
```

0 commit comments

Comments
 (0)