Skip to content

Span.addLink throws when using @vercel/otel due to missing method #2060

Open
@nicole0707

Description

@nicole0707

Please make sure you have searched for information in the following guides.

A screenshot that you have tested with "Try this API".

N/A

Link to the code that reproduces this issue. A link to a public Github Repository or gist with a minimal reproduction.

https://github.com/nicole0707/otel-addlink-compat-repro

A step-by-step description of how to reproduce the issue, based on the linked reproduction.

  • npm install
  • npm start

A clear and concise description of what the bug is, and what you expected to happen.

When using @vercel/otel for OpenTelemetry initialization, spans do not support the .addLink() method.

In the PubsubSpans.createPublishRpcSpan() and similar methods, addLink is called unguarded. However, Vercel’s OTEL wrapper currently uses @opentelemetry/[email protected], which does not support addLink() on the span object.

This leads to runtime errors:

TypeError: span.addLink is not a function

Expected behavior:

The library should check whether .addLink is supported before calling it.

This would allow compatibility with OTEL wrappers like @vercel/otel, even if they’re on older SDK versions.

A clear and concise description WHY you expect this behavior, i.e., was it a recent change, there is documentation that points to this behavior, etc. **

The OpenTelemetry spec introduced Span.addLink() more recently, and not all implementations support it yet, particularly lightweight wrappers like Vercel’s.

Metadata

Metadata

Assignees

No one assigned

    Labels

    api: pubsubIssues related to the googleapis/nodejs-pubsub API.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions