feat: exit spans, infer destination.service.resource#2458
Closed
feat: exit spans, infer destination.service.resource#2458
Conversation
This adds the explicit concept of "exit spans" -- spans the represent an outgoing call to a downstream service. An exit span doesn't have child spans. (Technically it can have spans of the same type+subtype, but this agent doesn't have any cases of that.) An exit span is explicitly marked at creation time by setting the `exitSpan` option to true. https://github.com/elastic/apm/blob/master/specs/agents/tracing-spans.md#exit-spans For exit spans the 'span.context.destination.service.resource' is automatically inferred from other context. This can be overriden with the new `span.setDestinationService(resource)`. https://github.com/elastic/apm/blob/master/specs/agents/tracing-spans-destination.md Fixes: #2103
💔 Build Failed
Expand to view the summary
Build stats
Test stats 🧪
Steps errors
Expand to view the steps failures
|
trentm
added a commit
that referenced
this pull request
Sep 14, 2022
This adds the new `span.context.service.target.{type,name}` fields for
improved granularity on backend services data in exit spans. This data is
used for "Service Maps" and "Dependencies" in the Kibana APM app.
All instrumentations have been updated to set appropriate service target
values. `service.target.*` is typically inferred automatically from other
span data, so much of the instrumentation work was in adding other span
fields, most commonly `span.context.db.instance`. The one current exception
to the general inference algorithm is S3 spans, for which the spec'd
`service.target.name` doesn't follow the general pattern.
A new, public `span.setServiceTarget(type, name)` API has been added (this is
a "SHOULD" in the spec).
The new fields will replace the (now deprecated)
`span.context.destination.service.*` fields. In the current stage of
transition:
- `destination.service.{type,name}` are set to the empty string. They are no
longer used, but the intake API v2 schema up to 7.13 require them to be
set.
- Setting `destination.service.resource` directly is discouraged. Typically
it is inferred from `service.target.*` values when a span is ended. Again
the one exception is S3 spans.
The not-public-but-available-because-JavaScript `span.setDestinationContext`
has been deprecated (using it will `process.emitWarning()`) and replaced with
an internal `span._setDestinationContext()`.
As part of this change, improvements have been made to some module
instrumentations:
- `redis` and `ioredis`: `span.type` has changed from "cache" to "db" per
spec (https://github.com/elastic/apm/blob/main/specs/agents/tracing-instrumentation-db.md#redis)
- `mongodb`: `span.action` used to be "query", now it will be the mongodb
command name, e.g. "find", "insert".
- `mongodb` and `mongodb-core`: `span.db.instance` is now set to the database
name (#1494)
- `mysql` and `mysql2`: `span.db.{instance,user}` are now populated.
- `@elastic/elasticsearch`: The cluster name is heuristically determined for
Elastic Cloud deployments and used for `db.instance`.
- `sqs`: `span.destination.{address,port}` are now populated.
- `pg`: `span.db.{instance,user}` are now populated.
- `cassandra-driver`: the Cassandra keyspace is captured for service target
data, if available.
- OpenTelemetry Bridge: OTel spans with kind PRODUCER and CLIENT are now
handled as exit spans (e.g. span compression could apply).
Closes: #2621
Closes: #2822
Closes: #1494
Closes: #1897
Closes: #2103
Obsoletes: #2458
Member
Author
PeterEinberger
pushed a commit
to fpm-git/apm-agent-nodejs
that referenced
this pull request
Aug 20, 2024
This adds the new `span.context.service.target.{type,name}` fields for
improved granularity on backend services data in exit spans. This data is
used for "Service Maps" and "Dependencies" in the Kibana APM app.
All instrumentations have been updated to set appropriate service target
values. `service.target.*` is typically inferred automatically from other
span data, so much of the instrumentation work was in adding other span
fields, most commonly `span.context.db.instance`. The one current exception
to the general inference algorithm is S3 spans, for which the spec'd
`service.target.name` doesn't follow the general pattern.
A new, public `span.setServiceTarget(type, name)` API has been added (this is
a "SHOULD" in the spec).
The new fields will replace the (now deprecated)
`span.context.destination.service.*` fields. In the current stage of
transition:
- `destination.service.{type,name}` are set to the empty string. They are no
longer used, but the intake API v2 schema up to 7.13 require them to be
set.
- Setting `destination.service.resource` directly is discouraged. Typically
it is inferred from `service.target.*` values when a span is ended. Again
the one exception is S3 spans.
The not-public-but-available-because-JavaScript `span.setDestinationContext`
has been deprecated (using it will `process.emitWarning()`) and replaced with
an internal `span._setDestinationContext()`.
As part of this change, improvements have been made to some module
instrumentations:
- `redis` and `ioredis`: `span.type` has changed from "cache" to "db" per
spec (https://github.com/elastic/apm/blob/main/specs/agents/tracing-instrumentation-db.md#redis)
- `mongodb`: `span.action` used to be "query", now it will be the mongodb
command name, e.g. "find", "insert".
- `mongodb` and `mongodb-core`: `span.db.instance` is now set to the database
name (elastic#1494)
- `mysql` and `mysql2`: `span.db.{instance,user}` are now populated.
- `@elastic/elasticsearch`: The cluster name is heuristically determined for
Elastic Cloud deployments and used for `db.instance`.
- `sqs`: `span.destination.{address,port}` are now populated.
- `pg`: `span.db.{instance,user}` are now populated.
- `cassandra-driver`: the Cassandra keyspace is captured for service target
data, if available.
- OpenTelemetry Bridge: OTel spans with kind PRODUCER and CLIENT are now
handled as exit spans (e.g. span compression could apply).
Closes: elastic#2621
Closes: elastic#2822
Closes: elastic#1494
Closes: elastic#1897
Closes: elastic#2103
Obsoletes: elastic#2458
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds the explicit concept of "exit spans" -- spans the represent an
outgoing call to a downstream service. An exit span doesn't have child
spans. (Technically it can have spans of the same type+subtype, but this
agent doesn't have any cases of that.) An exit span is explicitly marked
at creation time by setting the
exitSpanoption to true.https://github.com/elastic/apm/blob/master/specs/agents/tracing-spans.md#exit-spans
For exit spans the 'span.context.destination.service.resource' is
automatically inferred from other context. This can be overriden with
the new
span.setDestinationService(resource).https://github.com/elastic/apm/blob/master/specs/agents/tracing-spans-destination.md
Fixes: #2103
Checklist