Skip to content

Commit

Permalink
docs: clarify suggested stringify=false for setLabel/addLabels APIs (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
trentm authored Aug 2, 2023
1 parent 2be89df commit 9ea8c50
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 10 deletions.
22 changes: 19 additions & 3 deletions docs/agent-api.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,18 @@ TIP: Before using custom context, ensure you understand the different types of
Any periods (`.`), asterisks (`*`), or double quotation marks (`"`) will be replaced by underscores (`_`),
as those characters have special meaning in Elasticsearch
* `value` +{type-string}+ | +{type-number}+ | +{type-boolean}+
If the `stringify` argument is not given, or set to `true` then the given value
will be converted to a string.
* `stringify` +{type-boolean}+
Defaults to `true`. When true, if a non-string `value` is given, it is
This defaults to `true` for backwards compatibility, but new usage will
typically want `false`. When true, if a non-string `value` is given, it is
converted to a string before being sent to the APM Server.

[source,js]
----
apm.setLabel('productId', 42, false);
----

Set a label on the current transaction.
You can set multiple labels on the same transaction.
If an error happens during the current transaction,
Expand All @@ -273,10 +281,18 @@ Defining too many unique fields in an index is a condition that can lead to a
Any periods (`.`), asterisks (`*`), or double quotation marks (`"`) will be replaced by underscores (`_`),
as those characters have special meaning in Elasticsearch
** `value` +{type-string}+ | +{type-number}+ | +{type-boolean}+
If the `stringify` argument is not given, or set to `true` then the given value
will be converted to a string.
* `stringify` +{type-boolean}+
Defaults to `true`. When true, if a non-string `value` is given, it is
This defaults to `true` for backwards compatibility, but new usage will
typically want `false`. When true, if a non-string `value` is given, it is
converted to a string before being sent to the APM Server.

[source,js]
----
apm.addLabels({productId: 42, productName: 'butter'}, false);
----

Add several labels on the current transaction.
You can add labels multiple times.
If an error happens during the current transaction,
Expand Down Expand Up @@ -739,7 +755,7 @@ Manually end the active outgoing HTTP request to the APM Server.
The HTTP request is otherwise ended automatically at regular intervals,
controlled by the <<api-request-time,`apiRequestTime`>> and <<api-request-size,`apiRequestSize`>> config options.

If an optional `callback` is provided as the first argument to this method, it will call `callback(flushErr)` when complete.
If an optional `callback` is provided as the first argument to this method, it will call `callback(flushErr)` when complete.
If no `callback` is provided, then a `Promise` will be returned, which will either resolve with `void` or reject with `flushErr`.

The callback is called (or the `Promise` resolves if no `callback` argument is provided) *after* the active HTTP request has ended.
Expand Down
41 changes: 39 additions & 2 deletions docs/span-api.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ a database query would generally have an action of `query`.

Get the serialized traceparent string of the span.


[[span-set-label]]
==== `span.setLabel(name, value[, stringify = true])`

Expand All @@ -105,13 +106,31 @@ Get the serialized traceparent string of the span.
Any periods (`.`), asterisks (`*`), or double quotation marks (`"`) will be replaced by underscores (`_`),
as those characters have special meaning in Elasticsearch
* `value` +{type-string}+ | +{type-number}+ | +{type-boolean}+
If the `stringify` argument is not given, or set to `true` then the given value
will be converted to a string.
* `stringify` +{type-boolean}+
Defaults to `true`. When true, if a non-string `value` is given, it is
This defaults to `true` for backwards compatibility, but new usage will
typically want `false`. When true, if a non-string `value` is given, it is
converted to a string before being sent to the APM Server.

[source,js]
----
span.setLabel('productId', 42, false);
----

Set a label on the span.
You can set multiple labels on the same span.

TIP: Labels are key/value pairs that are indexed by Elasticsearch and therefore searchable
(as opposed to data set via <<apm-set-custom-context,`apm.setCustomContext()`>>).
Before using custom labels, ensure you understand the different types of
{apm-guide-ref}/data-model-metadata.html[metadata] that are available.

WARNING: Avoid defining too many user-specified labels.
Defining too many unique fields in an index is a condition that can lead to a
{ref}/mapping.html#mapping-limit-settings[mapping explosion].


[[span-add-labels]]
==== `span.addLabels({ [name]: value }[, stringify = true])`

Expand All @@ -124,13 +143,31 @@ You can set multiple labels on the same span.
Any periods (`.`), asterisks (`*`), or double quotation marks (`"`) will be replaced by underscores (`_`),
as those characters have special meaning in Elasticsearch
** `value` +{type-string}+ | +{type-number}+ | +{type-boolean}+
If the `stringify` argument is not given, or set to `true` then the given value
will be converted to a string.
* `stringify` +{type-boolean}+
Defaults to `true`. When true, if a non-string `value` is given, it is
This defaults to `true` for backwards compatibility, but new usage will
typically want `false`. When true, if a non-string `value` is given, it is
converted to a string before being sent to the APM Server.

[source,js]
----
span.addLabels({productId: 42, productName: 'butter'}, false);
----

Add several labels on the span.
You can add labels multiple times.

TIP: Labels are key/value pairs that are indexed by Elasticsearch and therefore searchable
(as opposed to data set via <<apm-set-custom-context,`apm.setCustomContext()`>>).
Before using custom labels, ensure you understand the different types of
{apm-guide-ref}/data-model-metadata.html[metadata] that are available.

WARNING: Avoid defining too many user-specified labels.
Defining too many unique fields in an index is a condition that can lead to a
{ref}/mapping.html#mapping-limit-settings[mapping explosion].


[[span-ids]]
==== `span.ids`

Expand Down
42 changes: 37 additions & 5 deletions docs/transaction-api.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,32 @@ See <<span-api,Span API>> docs for details on how to use custom spans.
Any periods (`.`), asterisks (`*`), or double quotation marks (`"`) will be replaced by underscores (`_`),
as those characters have special meaning in Elasticsearch
* `value` +{type-string}+ | +{type-number}+ | +{type-boolean}+
If the `stringify` argument is not given, or set to `true` then the given value
will be converted to a string.
* `stringify` +{type-boolean}+
Defaults to `true`. When true, if a non-string `value` is given, it is
converted to a string before being sent to the APM Server
This defaults to `true` for backwards compatibility, but new usage will
typically want `false`. When true, if a non-string `value` is given, it is
converted to a string before being sent to the APM Server.

[source,js]
----
transaction.setLabel('productId', 42, false);
----

Set a label on the transaction.
You can set multiple labels on the same transaction.
If an error happens during the transaction,
it will also get tagged with the same labels.

Tags are key/value pairs that are indexed by Elasticsearch and therefore searchable (as opposed to data set via <<apm-set-custom-context,`apm.setCustomContext()`>>).
TIP: Labels are key/value pairs that are indexed by Elasticsearch and therefore searchable
(as opposed to data set via <<apm-set-custom-context,`apm.setCustomContext()`>>).
Before using custom labels, ensure you understand the different types of
{apm-guide-ref}/data-model-metadata.html[metadata] that are available.

WARNING: Avoid defining too many user-specified labels.
Defining too many unique fields in an index is a condition that can lead to a
{ref}/mapping.html#mapping-limit-settings[mapping explosion].


[[transaction-add-labels]]
==== `transaction.addLabels({ [name]: value }[, stringify = true])`
Expand All @@ -165,16 +181,32 @@ Tags are key/value pairs that are indexed by Elasticsearch and therefore searcha
Any periods (`.`), asterisks (`*`), or double quotation marks (`"`) will be replaced by underscores (`_`),
as those characters have special meaning in Elasticsearch
** `value` +{type-string}+ | +{type-number}+ | +{type-boolean}+
If the `stringify` argument is not given, or set to `true` then the given value
will be converted to a string.
* `stringify` +{type-boolean}+
Defaults to `true`. When true, if a non-string `value` is given, it is
This defaults to `true` for backwards compatibility, but new usage will
typically want `false`. When true, if a non-string `value` is given, it is
converted to a string before being sent to the APM Server.

[source,js]
----
transaction.addLabels({productId: 42, productName: 'butter'}, false);
----

Add several labels on the transaction.
You can add labels multiple times.
If an error happens during the transaction,
it will also get tagged with the same labels.

Labels are key/value pairs that are indexed by Elasticsearch and therefore searchable (as opposed to data set via <<apm-set-custom-context,`apm.setCustomContext()`>>).
TIP: Labels are key/value pairs that are indexed by Elasticsearch and therefore searchable
(as opposed to data set via <<apm-set-custom-context,`apm.setCustomContext()`>>).
Before using custom labels, ensure you understand the different types of
{apm-guide-ref}/data-model-metadata.html[metadata] that are available.

WARNING: Avoid defining too many user-specified labels.
Defining too many unique fields in an index is a condition that can lead to a
{ref}/mapping.html#mapping-limit-settings[mapping explosion].


[[transaction-ensure-parent-id]]
==== `transaction.ensureParentId()`
Expand Down

0 comments on commit 9ea8c50

Please sign in to comment.