robertcepa/toucan-js

Timestamps sent with year 2077

gourgouris opened this issue · 3 comments

The following repro will send timestamps with year 2077 in Self Hosted:
In Sentry.io the transaction is dropped (I assume because it is 53 years in the future!)

import { Toucan } from "toucan-js";
import { addTracingExtensions } from '@sentry/core';

export interface Env {
  SENTRY_DSN: string;
}

export default {
  async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
    addTracingExtensions();
    const sentry = new Toucan({
      dsn: env.SENTRY_DSN,
      release: '1.0.0',
      context: ctx,
      request,
      sampleRate: 1.0,
      tracesSampleRate: 1.0,
      enableTracing: true,
    });

    const transaction = sentry.startTransaction({ name: 'test', description: 'test', op: 'http.server', metadata: { source: 'route' } });
    try {
      await fetch('https://google.com'); // just to cause some IO
      return new Response('Hello world!');
    } catch (e) {
      sentry.captureException(e);

      return new Response('Something went wrong! Team has been notified.', {
        status: 500,
      });
    } finally {
      transaction.finish();
    }
  },
};

Passing startTimestamp and endTimestamp explicitly via performance.now()/1000 it works as expected.
I have raised this issue with sentry, but they asked me to follow up here.
I am sorry if this is not related to this repo, but it could be worth being aware.

My understanding was that tracing is not currently supported:
#66

Thank you.
I did not realize that tracing was not supported, I dont know how I drew that conclusion - apologies.

The runtime seems to support the Performance API nowadays https://community.cloudflare.com/t/2023-5-12-workers-runtime-release-notes/508952 with the limitation that time advances only when I/O is performed - which is better than nothing.

I'll take a closer look at performance tracing, but to some extent, it will continue being limited due to how Workers runtime provides current time. However, I think measurements around IO boundaries can still be useful.