Conversation
Closes: #594
|
The following are some comments/notes on how each of the APM agent APIs could add span links support, if it is decided that is worthwhile for each language agent. Do not take these as requirements at all -- you all know the various APM agents better than I. Node.js APM agentHere is the OTel API:
The addition to the Node.js APM agent public API could be: // Link, Attributes, and `links` are intended to be compatible with OTel's
// equivalent APIs in "opentelemetry-js-api/src/trace/link.ts", with the
// exception that attributes are not yet accepted.
export interface Link {
/** A traceparent-format string, Transaction, or Span. */
context: Transaction | Span | string; // This is a SpanContext in OTel.
}
export interface TransactionOptions {
startTime?: number;
childOf?: Transaction | Span | string;
links?: Link[];
}
export interface SpanOptions {
startTime?: number;
childOf?: Transaction | Span | string;
links?: Link[];
exitSpan?: boolean;
}The Usage in JS code would look something like: const span = apm.startSpan("my-span-name", {
links: [{ context: record.messageAttributes.traceparent }]
})The following was considered and rejected: Minimally the API could be reduced to the following. However, that means supporting two different calling forms if/when |
Python APM agentIn opentelemetry-python/../src/opentelemetry/trace/__init__.py the start span API is: @abstractmethod
def start_span(
self,
name: str,
context: Optional[Context] = None,
links: _Links = None,
...
) -> "Span":
@contextmanager
@abstractmethod
def start_as_current_span(
self,
name: str,
context: Optional[Context] = None,
links: _Links = None,
...
) -> Iterator["Span"]:
# where `_Links` is basically (modulo some typings) a list of:
class Link:
def __init__(self, context, attributes):
# ...The Python APM agent could perhaps add a similar |
Go APM agentPresumably a type SpanOptions struct {
// ...
links []Link
} |
| that the APM agent does not or cannot instrument. (For some agents it would be | ||
| a burden to internally support span links and *not* expose the API publicly.) | ||
|
|
||
| TODO: For the .NET APM agent is there much value in providing a public API to add span links? Perhaps usage of the Activity API and the OTel Bridge dominates? |
There was a problem hiding this comment.
I'd not say that the Activity API dominates... it gets adaption, but it's far from being widely used.
I see the other command regarding Java - our .NET API is similar in a sense that long term we expect Activity being the primary API for manual instrumentation. We haven't discussed span links specifically for .NET yet.
It's not a huge effort to add this to the public API, so at this point I'd lean towards adding it to our public API in .NET.
| @@ -0,0 +1,18 @@ | |||
| TODO: this content will be appended to "span-links.md" when that file is added in https://github.com/elastic/apm/pull/600 | |||
There was a problem hiding this comment.
REVIEW NOTE: This will be done after #600 goes in.
Refs: #594
Notes for reviewers
Checklist
sanitize_field_names)CODEOWNERS)