Skip to content

Commit

Permalink
deprecate specified format of Span#toString() and Transaction#toStrin…
Browse files Browse the repository at this point in the history
…g() (#2349)

Refs: #2348
  • Loading branch information
trentm committed Sep 27, 2021
1 parent 6361691 commit 60ed413
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 18 deletions.
8 changes: 6 additions & 2 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,14 @@ Notes:
[float]
===== Bug fixes
* <<span-to-string,`span.toString()`>> and <<transaction-to-string,`transaction.toString()`>>
have been *deprecated*. The exact string output may change in v4 of the
agent.
* Add `Span.ids` and `Transaction.ids` to TypeScript types. ({pull}2347[#2347])
* Improve `span.sync` determination (fixes {issue}1996[#1996]) and stop
reporting `transaction.sync` which was never used ({issue}2292[#2292]).
* Improve `span.sync` determination (fixes {issues}1996[#1996]) and stop
reporting `transaction.sync` which was never used ({issues}2292[#2292]).
A minor semantic change is that `span.sync` is not set to a final value
until `span.end()` is called. Before `span.end()` the value will always
by `true`.
Expand Down
13 changes: 1 addition & 12 deletions docs/agent-api.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ apm.clearPatches(['timers'])

`apm.currentTraceIds` produces an object containing `trace.id` and either `transaction.id` or `span.id` when a current transaction or span is available.
When no transaction or span is available it will return an empty object.
This enables log correlation to APM traces with structured loggers.
This enables <<log-correlation,log correlation>> to APM traces with structured loggers.

[source,js]
----
Expand All @@ -837,17 +837,6 @@ This enables log correlation to APM traces with structured loggers.
}
----

All current trace id objects,
including the empty form,
include a `toString()` implementation.
This enables log correlation to APM traces with text-only loggers.

[source,js]
----
"trace.id=abc123 transaction.id=abc123"
// or ...
"trace.id=abc123 span.id=abc123"
----
// end::currentTraceIds[]

[[apm-register-custom-metrics]]
Expand Down
18 changes: 16 additions & 2 deletions docs/span-api.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,12 @@ This enables log correlation to APM traces with structured loggers.
}
----


[[span-to-string]]
==== `span.toString()`
==== `span.toString()` deprecated:[v3.23.0]

[small]#Added in: v2.17.0#
[small]#Added in: v2.17.0# +
[small]#Deprecated in: v3.23.0#

Produces a string representation of the span to inject in log messages.
This enables log correlation to APM traces with text-only loggers.
Expand All @@ -160,6 +162,18 @@ This enables log correlation to APM traces with text-only loggers.
"trace.id=abc123 span.id=abc123"
----

Relying on the format of `span.toString()` has been **deprecated** and may
change in v4 of the agent. Prefer the use of <<span-ids,`span.ids`>> or
<<apm-current-trace-ids,`apm.currentTraceIds`>>. The v3 format may be reproduced
via:

[source,js]
----
const { stringify } = require('querystring')
console.log( stringify(span.ids, ' ', '=')) )
----


[[span-end]]
==== `span.end([endTime])`

Expand Down
18 changes: 16 additions & 2 deletions docs/transaction-api.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,12 @@ This enables log correlation to APM traces with structured loggers.
}
----


[[transaction-to-string]]
==== `transaction.toString()`
==== `transaction.toString()` deprecated:[v3.23.0]

[small]#Added in: v2.17.0#
[small]#Added in: v2.17.0# +
[small]#Deprecated in: v3.23.0#

Produces a string representation of the transaction to inject in log messages.
This enables log correlation to APM traces with text-only loggers.
Expand All @@ -223,6 +225,18 @@ This enables log correlation to APM traces with text-only loggers.
"trace.id=abc123 transaction.id=abc123"
----

Relying on the format of `transaction.toString()` has been **deprecated** and may
change in v4 of the agent. Prefer the use of <<transaction-ids,`transaction.ids`>> or
<<apm-current-trace-ids,`apm.currentTraceIds`>>. The v3 format may be reproduced
via:

[source,js]
----
const { stringify } = require('querystring')
console.log( stringify(transaction.ids, ' ', '=')) )
----


[[transaction-end]]
==== `transaction.end([result][, endTime])`

Expand Down

0 comments on commit 60ed413

Please sign in to comment.