Skip to content
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

feat(opentelemetry): Add addLink(s) to span #15387

Merged
merged 12 commits into from
Feb 17, 2025
Merged

feat(opentelemetry): Add addLink(s) to span #15387

merged 12 commits into from
Feb 17, 2025

Conversation

s1gr1d
Copy link
Member

@s1gr1d s1gr1d commented Feb 12, 2025

Link spans which are related. Example:

  const span1 = startInactiveSpan({ name: 'span1' });

    startSpan({ name: 'span2' }, span2 => {
      span2.addLink({
        context: span1.spanContext(),
        attributes: { 'sentry.link.type': 'previous_trace' },
      });

@s1gr1d s1gr1d self-assigned this Feb 12, 2025
@s1gr1d s1gr1d mentioned this pull request Feb 12, 2025
7 tasks
Copy link
Contributor

github-actions bot commented Feb 12, 2025

size-limit report 📦

Path Size % Change Change
@sentry/browser 23.02 KB +0.34% +78 B 🔺
@sentry/browser - with treeshaking flags 22.8 KB +0.31% +70 B 🔺
@sentry/browser (incl. Tracing) 35.96 KB +0.23% +84 B 🔺
@sentry/browser (incl. Tracing, Replay) 72.94 KB +0.09% +65 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 66.43 KB +0.08% +54 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 77.19 KB +0.09% +67 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 90.11 KB +0.07% +63 B 🔺
@sentry/browser (incl. Feedback) 40.13 KB +0.19% +77 B 🔺
@sentry/browser (incl. sendFeedback) 27.65 KB +0.27% +76 B 🔺
@sentry/browser (incl. FeedbackAsync) 32.45 KB +0.24% +79 B 🔺
@sentry/react 24.84 KB +0.27% +68 B 🔺
@sentry/react (incl. Tracing) 37.84 KB +0.17% +64 B 🔺
@sentry/vue 27.2 KB +0.25% +68 B 🔺
@sentry/vue (incl. Tracing) 37.64 KB +0.14% +53 B 🔺
@sentry/svelte 23.06 KB +0.32% +74 B 🔺
CDN Bundle 24.22 KB +0.25% +60 B 🔺
CDN Bundle (incl. Tracing) 35.99 KB +0.18% +64 B 🔺
CDN Bundle (incl. Tracing, Replay) 70.82 KB +0.1% +71 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 75.99 KB +0.12% +87 B 🔺
CDN Bundle - uncompressed 70.83 KB +0.27% +195 B 🔺
CDN Bundle (incl. Tracing) - uncompressed 106.92 KB +0.18% +195 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 218.14 KB +0.09% +195 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 230.71 KB +0.09% +195 B 🔺
@sentry/nextjs (client) 38.83 KB +0.2% +78 B 🔺
@sentry/sveltekit (client) 36.37 KB +0.14% +51 B 🔺
@sentry/node 127.71 KB +0.08% +103 B 🔺
@sentry/node - without tracing 97.99 KB +0.09% +88 B 🔺
@sentry/aws-serverless 107.42 KB +0.08% +80 B 🔺

View base workflow run

Copy link

codecov bot commented Feb 12, 2025

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
4553 1 4552 316
View the top 1 failed test(s) by shortest run time
Prisma ORM v5 Tests CJS - should instrument PostgreSQL queries from Prisma ORM
Stack Traces | 16.4s run time
Error: thrown: "Exceeded timeout of 15000 ms for a test.
Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test."
    at .../tracing/prisma-orm-v5/test.ts:8:3
    at _dispatchDescribe (.../jest-circus/build/index.js:98:26)
    at describe (.../jest-circus/build/index.js:60:5)
    at Object.<anonymous> (.../tracing/prisma-orm-v5/test.ts:7:1)
    at Runtime._execModule (.../jest-runtime/build/index.js:1646:24)
    at Runtime._loadModule (.../jest-runtime/build/index.js:1185:12)
    at Runtime.requireModule (.../jest-runtime/build/index.js:1009:12)
    at jestAdapter (.../build/legacy-code-todo-rewrite/jestAdapter.js:79:13)
    at processTicksAndRejections (node:internal/process/task_queues:105:5)
    at runTestInternal (.../jest-runner/build/runTest.js:389:16)

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@s1gr1d s1gr1d marked this pull request as draft February 12, 2025 13:44
Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! This all looks reasonable to me. Just wondered if we're missing something to correctly serialize a span link on the root span to event.contexts.trace?

So basically for a case like

const someSpan = startInactiveSpan(...);
someSpanContext = someSpan.spanContext();
someSpan.end();

startSpan({name: 'rootSpan'}, () => {
  rootSpan.addLink({context: someSpanContext});
})

(which is probably quite similar to how we'll eventually link previous traces)

Comment on lines 3 to 4
// A general note regarding this test:
// The fact that the trace_id and span_id are correctly linked is tested in a unit test
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also only learned this by chance but if this is about not being able to store the ids in variables to compare: You can pass a function to expect({ transaction }) so that you can write better assertions than just comparing the matching object. See here for an example

Base automatically changed from sig/span-link-types to develop February 13, 2025 10:34
@s1gr1d s1gr1d marked this pull request as ready for review February 13, 2025 13:06
@s1gr1d s1gr1d requested a review from Lms24 February 13, 2025 13:09
@s1gr1d s1gr1d changed the title feat(node): Add addLink(s) to span feat(opentelemetry): Add addLink(s) to span Feb 13, 2025
Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks!

@s1gr1d s1gr1d merged commit 5e6b852 into develop Feb 17, 2025
147 checks passed
@s1gr1d s1gr1d deleted the sig/otel-addLink branch February 17, 2025 11:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants