-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Backend granularity (service.target.*) clarifications #674
Conversation
Q4: The Java agent has |
Q5: tracing-spans-service-target.md has an OTel Bridge section that includes:
However, the pseudo-code in "tracing-api-otel.md" still shows setting |
But the Java agent impl uses Should I update the compressed-spans spec to use the alg in the Java impl? |
Q7: Two questions on the S3 spec
|
This is only because for the user-facing API we have |
Yes, this pseudo-code should be updated to also infer the new |
Yes |
For S3, I think that we need to discuss what is the best option here, here are a few thoughts on this
Update: I found that there has been a stage 0 RFC to add a field in ECS that would allow to store the the bucket name, but it's far from being done. |
Paraphrasing myself from my last conversation with @trentm (before I forget about it): On the agent side, there are two places where the new and old fields can be set:
For (2), we can infer resource from the new service.target fields for the general case, but can't deal with special cases like s3. So, while modifying the convention for S3 would be great, it is not strictly required if we handle it as a "special case" explicitly in all S3 instrumentations. |
…rver' is deprecated in favour of 'mssql'
Done in bebe220 |
…ice.target The, perhaps surprising, use of `span.type === "external"` is discussed in more detail here: https://github.com/elastic/apm-agent-nodejs/blob/a10bccfe797577f8414c957aaf1ec50ea581e8b9/lib/instrumentation/span.js#L146-L173 This is for my Q3.
…span service.target rather than destination.service.resource
The OTel Bridge compatibility mapping code is updated to set service.target (rather than destination.service.resource) in commit 2a66234. |
@SylvainJuge I believe all my questions have been answered, except the S3 discussion (Q7). I've spent a bit more time with that and have a proposal that I'll run by you and then create a separate spec PR for that. I'm ready for a regular re-review of this spec PR from you, when you have a chance. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add notes for reviewers.
} | ||
} | ||
``` | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
REVIEW NOTE: This change updates the composite span.name calculation to match the implementation in the Java Agent here: https://github.com/elastic/apm-agent-java/blob/32611fe5174cf7c67f12c885cb6759176749f243/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/Span.java#L381-L403
@@ -169,13 +169,14 @@ if (span_kind == 'SERVER' && (isRpc || isHttp)) { | |||
} | |||
``` | |||
|
|||
#### Span type, sub-type and destination service resource | |||
#### Span type, sub-type and service target |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
REVIEW NOTE: This section updates the OTel Bridge compatibility mapping logic to set span.context.service.target.*
rather than span.context.destination.service.resource
. (Inferring the destination.service.resource value is handled by the general logic for all spans in tracing-spans-destination.md below.) It should correspond to the logic in the Java agent here: https://github.com/elastic/apm-agent-java/blob/32611fe5174cf7c67f12c885cb6759176749f243/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-plugin/src/main/java/co/elastic/apm/agent/opentelemetry/sdk/OTelSpan.java#L148-L250
@@ -227,7 +227,7 @@ The Elasticsearch cluster name is not always available in ES clients, as a resul | |||
| MySQL | `mysql` | | |||
| MariaDB | `mariadb` | | |||
| PostgreSQL | `postgresql`| | |||
| Microsoft SQL server | `sqlserver` | | |||
| Microsoft SQL server | `mssql` | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
REVIEW NOTE: I think this use of sqlserver
was unintended. "json-specs/span_types.json" suggests that "sqlserver" is deprecated in favour of "mssql".
else | ||
subtype ?: type | ||
"${span.context.service.target.type}/${span.context.service.target.name}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
REVIEW NOTE: This section updates the logic for inferring context.destination.service.resource
from context.service.target.*
(and span.type
). This is the logic I'm using in the Node.js APM agent here: https://github.com/elastic/apm-agent-nodejs/blob/a10bccfe797577f8414c957aaf1ec50ea581e8b9/lib/instrumentation/span.js#L146-L173
That link provides some more discussion on why else if (span.type == 'external')
was used. My observation was that the exceptional case in the spec text and "otel_bridge.feature" -- where we skip the "${service.target.type}/" prefix -- is for HTTP and RPC system spans (like gRPC and Apache Dubbo). These are exactly the set of spans that we specify should use span.type == 'external'
. It seems to me a much clearer check that using other attributes such as:
} else if (!context.db && !context.message && context.http && context.http.url) {
which is closer to the old logic that was used for inferring destination.service.resource. Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, it's simpler to rely on span.type = "external"
here, that would probably be a very good argument to enforce adherence to the spec for span types & subtypes.
@@ -105,35 +105,37 @@ This specification assumes that values for `span.type` and `span.subtype` fit th | |||
- `span.context.service.target.name` depends on the span context attributes | |||
|
|||
On agents, the following algorithm should be used to infer the values for `span.context.service.target.*` fields. | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
REVIEW NOTE: This section slightly tweaks the pseudo-code to infer context.service.target.*
from other span fields to avoid a couple gotchas that I hit:
- The
if (!service_target.type)
check in JavaScript would accidentally overrideservice_target.type
if it had explicitly been set to the empty string. - The
if (span.context.db.instance)
branch was changed toif (span.context.db)
to use the DB logic for DB spans even if the span didn't happen to have a "db.instance" set -- which is less surprising and matches the old pseudo-code for inferring destination.service.resource.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks a lot for helping clarify this !
else | ||
subtype ?: type | ||
"${span.context.service.target.type}/${span.context.service.target.name}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, it's simpler to rely on span.type = "external"
here, that would probably be a very good argument to enforce adherence to the spec for span types & subtypes.
I have some questions and clarifications on the
service.target.*
backend granularity changes. I'll try to ask them in comments and code-review-comments below.Update 2022-09-13: There was a lot of earlier discussion of Q1 - Q7 on this PR. If you are a new reviewer of this PR, you can probably skip all that earlier discussion and just look at the current file changes. I added some "REVIEW NOTE:" review comments that add context.
checklist
CODEOWNERS
)To auto-merge the PR, add
/
schedule YYYY-MM-DD
to the PR description.