Skip to content

Custom Instrumentation is Not working with New APIs in V8 #13470

Description

@an-and10

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/browser

SDK Version

8.116.0

Framework Version

React SadK 8.116.0

Link to Sentry event

https://hrc-t3.sentry.io/performance/?project=4507842173861888&query=&referrer=performance-transaction-summary&showTransactions=recent&source=performance_transaction_summary&statsPeriod=14d&unselectedSeries=p100%28%29&unselectedSeries=avg%28%29

Reproduction Example/SDK Setup

Sentry Instrument.js file - we have added the sentry Intialization

Sentry.init({
  dsn: "https://c556b54f@o3312.ingest.us.sentry.io/450888",
  debug:true,
  integrations: [
    // See docs for support of different versions of variation of react router
    // https://docs.sentry.io/platforms/javascript/guides/react/configuration/integrations/react-router/
    Sentry.reactRouterV6BrowserTracingIntegration({
      useEffect,
      useLocation,
      useNavigationType,
      createRoutesFromChildren,
      matchRoutes,
    }),
    Sentry.replayIntegration(),
  ],

  // Set tracesSampleRate to 1.0 to capture 100%
  // of transactions for tracing.
  tracesSampleRate: 1.0,

  // Set tracePropagationTargets to control for which URLs trace propagation should be enabled
  tracePropagationTargets: [/^\//, /^https:\/\/localhost\/api/],

  // Capture Replay for 10% of all sessions,
  // plus for 100% of sessions with an error
  replaysSessionSampleRate: 0.1,
  replaysOnErrorSampleRate: 1.0,
});

Steps to Reproduce

  1. Custom Instrumentation: We are looking for custom instrumentation to determine the htp request, UI thread and others request in a single group of spans/transaction
    In Version7.XX> this feature was available using startTransaction and end the transaction anywhere after custom logic of code

  2. In Newer version. - With startSpan, startSpanManual, or startInActiveSpan() - all these are starting the span correctly, and ending in callback  - working fine,

Requirment:
We dont want to close the span immediately after callback end. To be precise, we want to have any callback as well.
Example: start the user journey span at one component
lets says Component 1 - startSpan()

But performing  few actives - like filling a form of 4-5 components

Want to close this span and need to have the entire user journey - HTTP request, UI, component timing, loading images resources script ,etc loading
Closing can be at component 5 .

This we are not able to achieve as callback cannot be single-line. startIdelSpan() - this is also not working.
StartInActiveSpa ()- this works fine but do not capture any http request, resources script etc.

Componet1:

const handleAddLabelClick = () => {
       console.log("handleAddLabelClick, start sentry transaction");
     captureSentryObservabilityStart();
    };

Component 5:

 const handleSave = async () => {
        // Handle Save sentry closed
     captureSentryObservabilityEnd();
    };


captureSentryObservabilityStart = () => {
 Sentry.continueTrace({ sentryTrace: '', baggage: '' }, function (){
        return Sentry.withActiveSpan(null,function(){
            parentMenuClicked = Sentry.startInactiveSpan({
                op: "menuclicked",
                name: entityName,
                attributes: {
                    entityName: entityName
                },
                forceTransaction: true,
            });
        });
}


captureSentryObservabilityEnd = () => {
 Sentry.withActiveSpan(parentMenuClicked, function(){
                childSpanOnParent = Sentry.startInactiveSpan({
                    name: "gridload",
                    description: entityPropertyName,
                    parentSpan: parentMenuClicked,
                    parentSpanId: parentMenuClicked.spanId,
                    op: "gridload"
                });
            });

}

Reference link: #12222

Expected Result

In my Transaction - it should able to track all the HTTP request , reasoucrs, script, etc

Actual Result

In my Transaction - it should able to track all the HTTP request , reasoucrs, script, etc

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions