Skip to content

Commit a4fb272

Browse files
authored
chore: document and add type for parent option to captureError() (#2979)
This also includes some docs chores: fixes escaping and tweaks capitalization of the `type-string-array` and `type-undefined` labels. Closes: #2977
1 parent ea76358 commit a4fb272

File tree

5 files changed

+16
-2
lines changed

5 files changed

+16
-2
lines changed

CHANGELOG.asciidoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ paths are considered for body capture. ({pull}2873[#2873])
119119
(because there is no point). This is a performance improvement for
120120
Knex usage in the default configuration. ({pull}2879[#2879])
121121
122+
* Document and add types for `parent` option to
123+
<<apm-capture-error,`apm.captureError()`>>. ({issues}2977[#2977])
124+
122125
123126
[[release-notes-3.38.0]]
124127
==== 3.38.0 2022/08/11

docs/agent-api.asciidoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,8 @@ See the <<apm-add-labels,`apm.addLabels()`>> method for details about the format
335335

336336
** `skipOutcome` +{type-boolean}+ Whether to skip setting the outcome value for the current span to `failure`. See <<span-outcome,Span outcome>> for more information. *Default:* `false`.
337337

338+
** `parent` <<transaction-api,Transaction>> | <<span-api,Span>> | `null` - A Transaction or Span instance to make the parent of this error. If not given (or `undefined`), then the current span or transaction will be used. If `null` is given, then no span or transaction will be used. [small]#(Added in v3.33.0.)#
339+
338340
* `callback` - Will be called after the error has been sent to the APM Server.
339341
It will receive an `Error` instance if the agent failed to send the error,
340342
and the id of the captured error.

docs/index.asciidoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ include::{asciidoc-dir}/../../shared/versions/stack/current.asciidoc[]
22
include::{asciidoc-dir}/../../shared/attributes.asciidoc[]
33

44
:type-string: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type[<string>]
5-
:type-string-array: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type[<string[]>]
5+
:type-string-array: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type[<string[\]>]
66
:type-array: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array[<Array>]
77
:type-boolean: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type[<boolean>]
88
:type-object: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object[<Object>]
99
:type-number: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type[<number>]
1010
:type-function: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function[<Function>]
1111
:type-error: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error[<Error>]
12-
:type-undefined: https://developer.mozilla.org/en-US/docs/Glossary/Undefined[<Undefined>]
12+
:type-undefined: https://developer.mozilla.org/en-US/docs/Glossary/Undefined[<undefined>]
1313
:type-incomingmessage: https://nodejs.org/api/http.html#http_class_http_incomingmessage[<http.IncomingMessage>]
1414
:type-serverresponse: https://nodejs.org/api/http.html#http_class_http_serverresponse[<http.ServerResponse>]
1515

index.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,12 @@ declare namespace apm {
320320
message?: string;
321321
captureAttributes?: boolean;
322322
skipOutcome?: boolean;
323+
/**
324+
* A Transaction or Span instance to make the parent of this error. If not
325+
* given (undefined), then the current span or transaction will be used. If
326+
* `null` is given, then no span or transaction will be used.
327+
*/
328+
parent?: Transaction | Span | null;
323329
}
324330

325331
interface Labels {

test/types/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ apm.captureError({ message: 'hello %s', params: ['world'] }, { tags: { foo: 'bar
8787
apm.captureError(new Error('foo'), () => {})
8888
apm.captureError('foo', () => {})
8989
apm.captureError({ message: 'hello %s', params: ['world'] }, () => {})
90+
apm.captureError(new Error('an error on the transaction'), { parent: trans })
91+
apm.captureError(new Error('an error on the span'), { parent: span })
92+
apm.captureError(new Error('an error with explicitly no parent'), { parent: null })
9093

9194
apm.startTransaction()
9295
apm.startTransaction('foo')

0 commit comments

Comments
 (0)