Skip to content

Commit ec407c8

Browse files
committed
fix: SDK specific docs
1 parent e9d6d81 commit ec407c8

File tree

3 files changed

+51
-2
lines changed

3 files changed

+51
-2
lines changed

src/collections/_documentation/performance-monitoring/configuration/javascript.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,24 @@ Sentry.init({
214214
});
215215
```
216216

217+
**Retrieving a Transaction**
218+
219+
In cases where you want to attach Spans to an already ongoing Transaction you can use `Sentry.getCurrentHub().getScope().getTransaction()`. This function will return a `Transaction` in case there is a running Transaction otherwise it returns `undefined`. If you are using our Tracing integration by default we attach the Transaction to the Scope. So you could do something like this:
220+
221+
```javascript
222+
function myJsFunction() {
223+
const transaction = Sentry.getCurrentHub().getScope().getTransaction();
224+
if (transaction) {
225+
let span = transaction.startChild({
226+
op: "encode",
227+
description: "parseAvatarImages"
228+
});
229+
// Do something
230+
span.finish();
231+
}
232+
}
233+
```
234+
217235
**Adding Query Information and Parameters to Spans**
218236

219237
Currently, every tag has a maximum character limit of 200 characters. Tags over the 200 character limit will become truncated, losing potentially important information. To retain this data, you can split data over several tags instead.
@@ -237,7 +255,6 @@ span.setTag("baseUrl", baseUrl);
237255
span.setTag("endpoint", endpoint);
238256
span.setTag("parameters", parameters);
239257
http.get(`${base_url}/${endpoint}/`, data=parameters);
240-
...
241258
```
242259

243260
baseUrl

src/collections/_documentation/performance-monitoring/configuration/node.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,5 +92,23 @@ app.use(function processItems(req, res, next) {
9292
})
9393
});
9494
```
95-
9695
<!-- ENDWIZARD -->
96+
97+
#### Retrieving a Transaction
98+
99+
In cases where you want to attach Spans to an already ongoing Transaction you can use `Sentry.getCurrentHub().getScope().getTransaction()`. This function will return a `Transaction` in case there is a running Transaction otherwise it returns `undefined`. If you are using our Express integration by default we attach the Transaction to the Scope. So you could do something like this:
100+
101+
```javascript
102+
app.get("/success", function successHandler(req, res) {
103+
const transaction = Sentry.getCurrentHub().getScope().getTransaction();
104+
if (transaction) {
105+
let span = transaction.startChild({
106+
op: "encode",
107+
description: "parseAvatarImages"
108+
});
109+
// Do something
110+
span.finish();
111+
}
112+
res.status(200).end();
113+
});
114+
```

src/collections/_documentation/performance-monitoring/configuration/python.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,20 @@ def process_item(item):
100100

101101
<!-- ENDWIZARD -->
102102

103+
104+
#### Retrieving a Transaction
105+
106+
// TODO
107+
108+
In cases where you want to attach Spans to an already ongoing Transaction you can use `Sentry.getCurrentHub().getScope().getTransaction()`. This function will return a `Transaction` in case there is a running Transaction otherwise it returns `undefined`. If you are using our Express integration by default we attach the Transaction to the Scope. So you could do something like this:
109+
110+
```python
111+
from sentry_sdk import Hub
112+
transaction = Hub.current.scope.transaction
113+
```
114+
115+
// TODO
116+
103117
**Adding Query Information and Parameters to Spans**
104118

105119
Currently, every tag has a maximum character limit of 200 characters. Tags over the 200 character limit will become truncated, losing potentially important information. To retain this data, you can split data over several tags instead.

0 commit comments

Comments
 (0)