Skip to content

Commit

Permalink
fix Span.addLink, Span.addLinks retval
Browse files Browse the repository at this point in the history
  • Loading branch information
trentm committed Jun 12, 2024
1 parent 96c9e28 commit c0340b2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/instrumentation/generic-span.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ GenericSpan.prototype._serializeOTel = function (payload) {
// span link as it will be serialized and sent to APM server. If the linkArg is
// invalid, this will return null.
//
// @param {Array} linkArg - An object with a `context` property that is
// @param {Object} linkArg - An object with a `context` property that is
// a Transaction, Span, or TraceParent instance; an OTel SpanContext object;
// or a W3C trace-context 'traceparent' string.
function linkFromLinkArg(linkArg) {
Expand Down
2 changes: 2 additions & 0 deletions lib/opentelemetry-bridge/OTelSpan.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,12 @@ class OTelSpan {

addLink(link) {
this._span.addLink(link);
return this;
}

addLinks(links) {
this._span.addLinks(links);
return this;
}

end(otelEndTime) {
Expand Down
6 changes: 4 additions & 2 deletions test/opentelemetry-bridge/fixtures/interface-span.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,10 @@ const linkContext = {
spanId: 'ffe4cfa94865ee2a',
traceFlags: otel.TraceFlags.SAMPLED,
};
sAddLinks.addLink({ context: linkContext });
sAddLinks.addLinks([{ context: linkContext }]);
rv = sAddLinks.addLink({ context: linkContext });
assert.strictEqual(rv, sAddLinks, 'addLink return value is the span');
rv = sAddLinks.addLinks([{ context: linkContext }]);
assert.strictEqual(rv, sAddLinks, 'addLinks return value is the span');
sAddLinks.end();

// Span#end
Expand Down

0 comments on commit c0340b2

Please sign in to comment.