File tree 3 files changed +50
-19
lines changed
3 files changed +50
-19
lines changed Original file line number Diff line number Diff line change @@ -210,49 +210,39 @@ export class Span implements SpanInterface, SpanContext {
210
210
}
211
211
212
212
/**
213
- * Sets the tag attribute on the current span
214
- * @param key Tag key
215
- * @param value Tag value
213
+ * @inheritDoc
216
214
*/
217
215
public setTag ( key : string , value : string ) : this {
218
216
this . tags = { ...this . tags , [ key ] : value } ;
219
217
return this ;
220
218
}
221
219
222
220
/**
223
- * Sets the data attribute on the current span
224
- * @param key Data key
225
- * @param value Data value
221
+ * @inheritDoc
226
222
*/
227
223
public setData ( key : string , value : any ) : this {
228
224
this . data = { ...this . data , [ key ] : value } ;
229
225
return this ;
230
226
}
231
227
232
228
/**
233
- * Sets the data attribute on the current span
234
- * @param key Data key
235
- * @param value Data value
229
+ * @inheritDoc
236
230
*/
237
231
public setFailure ( ) : this {
238
232
this . setTag ( 'status' , 'failure' ) ;
239
233
return this ;
240
234
}
241
235
242
236
/**
243
- * Sets the data attribute on the current span
244
- * @param key Data key
245
- * @param value Data value
237
+ * @inheritDoc
246
238
*/
247
239
public setSuccess ( ) : this {
248
240
this . setTag ( 'status' , 'success' ) ;
249
241
return this ;
250
242
}
251
243
252
244
/**
253
- * Sets the data attribute on the current span
254
- * @param key Data key
255
- * @param value Data value
245
+ * @inheritDoc
256
246
*/
257
247
public isSuccess ( ) : boolean {
258
248
return this . tags . status !== 'failure' ;
Original file line number Diff line number Diff line change @@ -214,16 +214,22 @@ export class TransactionActivity implements Integration {
214
214
/**
215
215
* Removes activity and finishes the span in case there is one
216
216
*/
217
- public static popActivity ( id : number ) : void {
217
+ public static popActivity ( id : number , spanData ?: { [ key : string ] : any } ) : void {
218
218
if ( ! TransactionActivity . _isEnabled ( ) ) {
219
219
// Tracing is not enabled
220
220
return ;
221
221
}
222
222
223
223
const activity = TransactionActivity . _activities [ id ] ;
224
224
if ( activity ) {
225
- if ( activity . span ) {
226
- activity . span . finish ( ) ;
225
+ const span = activity . span ;
226
+ if ( span ) {
227
+ if ( spanData ) {
228
+ Object . keys ( spanData ) . forEach ( ( key : string ) => {
229
+ span . setData ( key , spanData [ key ] ) ;
230
+ } ) ;
231
+ }
232
+ span . finish ( ) ;
227
233
}
228
234
// tslint:disable-next-line: no-dynamic-delete
229
235
delete TransactionActivity . _activities [ id ] ;
@@ -247,7 +253,7 @@ export class TransactionActivity implements Integration {
247
253
function xhrCallback ( handlerData : { [ key : string ] : any } ) : void {
248
254
// tslint:disable: no-unsafe-any
249
255
if ( handlerData . requestComplete && handlerData . xhr . __sentry_xhr_activity_id__ ) {
250
- TransactionActivity . popActivity ( handlerData . xhr . __sentry_xhr_activity_id__ ) ;
256
+ TransactionActivity . popActivity ( handlerData . xhr . __sentry_xhr_activity_id__ , handlerData . xhr . __sentry_xhr__ ) ;
251
257
return ;
252
258
}
253
259
// We only capture complete, non-sentry requests
Original file line number Diff line number Diff line change @@ -8,6 +8,41 @@ export interface Span {
8
8
getTraceContext ( ) : object ;
9
9
/** Convert the object to JSON */
10
10
toJSON ( ) : object ;
11
+
12
+ /**
13
+ * Sets the tag attribute on the current span
14
+ * @param key Tag key
15
+ * @param value Tag value
16
+ */
17
+ setTag ( key : string , value : string ) : this;
18
+
19
+ /**
20
+ * Sets the data attribute on the current span
21
+ * @param key Data key
22
+ * @param value Data value
23
+ */
24
+ setData ( key : string , value : any ) : this;
25
+
26
+ /**
27
+ * Sets the data attribute on the current span
28
+ * @param key Data key
29
+ * @param value Data value
30
+ */
31
+ setFailure ( ) : this;
32
+
33
+ /**
34
+ * Sets the data attribute on the current span
35
+ * @param key Data key
36
+ * @param value Data value
37
+ */
38
+ setSuccess ( ) : this;
39
+
40
+ /**
41
+ * Sets the data attribute on the current span
42
+ * @param key Data key
43
+ * @param value Data value
44
+ */
45
+ isSuccess ( ) : boolean ;
11
46
}
12
47
13
48
/** Interface holder all properties that can be set on a Span on creation. */
You can’t perform that action at this time.
0 commit comments