Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/angular/src/tracing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Router } from '@angular/router';
import { NavigationEnd, NavigationStart, ResolveEnd } from '@angular/router';
import { getCurrentHub, WINDOW } from '@sentry/browser';
import type { Span, Transaction, TransactionContext } from '@sentry/types';
import { logger, stripUrlQueryAndFragment, timestampWithMs } from '@sentry/utils';
import { logger, stripUrlQueryAndFragment, timestampInSeconds } from '@sentry/utils';
import type { Observable } from 'rxjs';
import { Subscription } from 'rxjs';
import { filter, tap } from 'rxjs/operators';
Expand Down Expand Up @@ -258,7 +258,7 @@ export function TraceMethodDecorator(): MethodDecorator {
const originalMethod = descriptor.value;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
descriptor.value = function (...args: any[]): ReturnType<typeof originalMethod> {
const now = timestampWithMs();
const now = timestampInSeconds();
const activeTransaction = getActiveTransaction();
if (activeTransaction) {
activeTransaction.startChild({
Expand Down
10 changes: 5 additions & 5 deletions packages/core/src/tracing/idletransaction.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable max-lines */
import type { TransactionContext } from '@sentry/types';
import { logger, timestampWithMs } from '@sentry/utils';
import { logger, timestampInSeconds } from '@sentry/utils';

import type { Hub } from '../hub';
import type { Span } from './span';
Expand Down Expand Up @@ -46,7 +46,7 @@ export class IdleTransactionSpanRecorder extends SpanRecorder {
if (span.spanId !== this.transactionSpanId) {
// We patch span.finish() to pop an activity after setting an endTimestamp.
span.finish = (endTimestamp?: number) => {
span.endTimestamp = typeof endTimestamp === 'number' ? endTimestamp : timestampWithMs();
span.endTimestamp = typeof endTimestamp === 'number' ? endTimestamp : timestampInSeconds();
this._popActivity(span.spanId);
};

Expand Down Expand Up @@ -128,7 +128,7 @@ export class IdleTransaction extends Transaction {
}

/** {@inheritDoc} */
public finish(endTimestamp: number = timestampWithMs()): string | undefined {
public finish(endTimestamp: number = timestampInSeconds()): string | undefined {
this._finished = true;
this.activities = {};

Expand Down Expand Up @@ -301,13 +301,13 @@ export class IdleTransaction extends Transaction {
}

if (Object.keys(this.activities).length === 0) {
const endTimestamp = timestampWithMs();
const endTimestamp = timestampInSeconds();
if (this._idleTimeoutCanceledPermanently) {
this._finishReason = IDLE_TRANSACTION_FINISH_REASONS[5];
this.finish(endTimestamp);
} else {
// We need to add the timeout here to have the real endtimestamp of the transaction
// Remember timestampWithMs is in seconds, timeout is in ms
// Remember timestampInSeconds is in seconds, timeout is in ms
this._restartIdleTimeout(endTimestamp + this._idleTimeout / 1000);
}
}
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/tracing/span.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type {
TraceContext,
Transaction,
} from '@sentry/types';
import { dropUndefinedKeys, logger, timestampWithMs, uuid4 } from '@sentry/utils';
import { dropUndefinedKeys, logger, timestampInSeconds, uuid4 } from '@sentry/utils';

/**
* Keeps track of finished spans for a given transaction
Expand Down Expand Up @@ -71,7 +71,7 @@ export class Span implements SpanInterface {
/**
* Timestamp in seconds when the span was created.
*/
public startTimestamp: number = timestampWithMs();
public startTimestamp: number = timestampInSeconds();

/**
* Timestamp in seconds when the span ended.
Expand Down Expand Up @@ -257,7 +257,7 @@ export class Span implements SpanInterface {
}
}

this.endTimestamp = typeof endTimestamp === 'number' ? endTimestamp : timestampWithMs();
this.endTimestamp = typeof endTimestamp === 'number' ? endTimestamp : timestampInSeconds();
}

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/ember/addon/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { macroCondition, isDevelopingApp, getOwnConfig } from '@embroider/macros
import { next } from '@ember/runloop';
import { assert, warn } from '@ember/debug';
import Ember from 'ember';
import { timestampWithMs, GLOBAL_OBJ } from '@sentry/utils';
import { timestampInSeconds, GLOBAL_OBJ } from '@sentry/utils';
import { GlobalConfig, OwnConfig } from './types';

function _getSentryInitConfig() {
Expand Down Expand Up @@ -68,7 +68,7 @@ export const getActiveTransaction = () => {

export const instrumentRoutePerformance = (BaseRoute: any) => {
const instrumentFunction = async (op: string, description: string, fn: Function, args: any) => {
const startTimestamp = timestampWithMs();
const startTimestamp = timestampInSeconds();
const result = await fn(...args);

const currentTransaction = getActiveTransaction();
Expand Down
12 changes: 6 additions & 6 deletions packages/ember/addon/instance-initializers/sentry-performance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { ExtendedBackburner } from '@sentry/ember/runloop';
import { Span, Transaction } from '@sentry/types';
import { EmberRunQueues } from '@ember/runloop/-private/types';
import { getActiveTransaction } from '..';
import { browserPerformanceTimeOrigin, GLOBAL_OBJ, timestampWithMs } from '@sentry/utils';
import { browserPerformanceTimeOrigin, GLOBAL_OBJ, timestampInSeconds } from '@sentry/utils';
import { macroCondition, isTesting, getOwnConfig } from '@embroider/macros';
import { EmberSentryConfig, GlobalConfig, OwnConfig } from '../types';
import RouterService from '@ember/routing/router-service';
Expand Down Expand Up @@ -182,14 +182,14 @@ function _instrumentEmberRunloop(config: EmberSentryConfig) {
if (currentQueueSpan) {
currentQueueSpan.finish();
}
currentQueueStart = timestampWithMs();
currentQueueStart = timestampInSeconds();

instrumentedEmberQueues.forEach(queue => {
scheduleOnce(queue, null, () => {
scheduleOnce(queue, null, () => {
// Process this queue using the end of the previous queue.
if (currentQueueStart) {
const now = timestampWithMs();
const now = timestampInSeconds();
const minQueueDuration = minimumRunloopQueueDuration ?? 5;

if ((now - currentQueueStart) * 1000 >= minQueueDuration) {
Expand All @@ -210,7 +210,7 @@ function _instrumentEmberRunloop(config: EmberSentryConfig) {
if (!stillActiveTransaction) {
return;
}
currentQueueStart = timestampWithMs();
currentQueueStart = timestampInSeconds();
});
});
});
Expand Down Expand Up @@ -244,7 +244,7 @@ interface RenderEntries {
function processComponentRenderBefore(payload: Payload, beforeEntries: RenderEntries) {
const info = {
payload,
now: timestampWithMs(),
now: timestampInSeconds(),
};
beforeEntries[payload.object] = info;
}
Expand All @@ -261,7 +261,7 @@ function processComponentRenderAfter(
return;
}

const now = timestampWithMs();
const now = timestampInSeconds();
const componentRenderDuration = now - begin.now;

if (componentRenderDuration * 1000 >= minComponentDuration) {
Expand Down
8 changes: 4 additions & 4 deletions packages/react/src/profiler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import type { Hub } from '@sentry/browser';
import { getCurrentHub } from '@sentry/browser';
import type { Span, Transaction } from '@sentry/types';
import { timestampWithMs } from '@sentry/utils';
import { timestampInSeconds } from '@sentry/utils';
import hoistNonReactStatics from 'hoist-non-react-statics';
import * as React from 'react';

Expand Down Expand Up @@ -82,7 +82,7 @@ class Profiler extends React.Component<ProfilerProps> {
// set as data on the span. We just store the prop keys as the values could be potenially very large.
const changedProps = Object.keys(updateProps).filter(k => updateProps[k] !== this.props.updateProps[k]);
if (changedProps.length > 0) {
const now = timestampWithMs();
const now = timestampInSeconds();
this._updateSpan = this._mountSpan.startChild({
data: {
changedProps,
Expand Down Expand Up @@ -114,7 +114,7 @@ class Profiler extends React.Component<ProfilerProps> {
// next activity as a child to the component mount activity.
this._mountSpan.startChild({
description: `<${name}>`,
endTimestamp: timestampWithMs(),
endTimestamp: timestampInSeconds(),
op: REACT_RENDER_OP,
startTimestamp: this._mountSpan.endTimestamp,
});
Expand Down Expand Up @@ -195,7 +195,7 @@ function useProfiler(
if (mountSpan && options.hasRenderSpan) {
mountSpan.startChild({
description: `<${name}>`,
endTimestamp: timestampWithMs(),
endTimestamp: timestampInSeconds(),
op: REACT_RENDER_OP,
startTimestamp: mountSpan.endTimestamp,
});
Expand Down
4 changes: 2 additions & 2 deletions packages/tracing-internal/src/browser/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export function instrumentRoutingWithDefaults<T extends Transaction>(
if (startTransactionOnPageLoad) {
activeTransaction = customStartTransaction({
name: WINDOW.location.pathname,
// pageload should always start at timeOrigin
startTimestamp: browserPerformanceTimeOrigin,
// pageload should always start at timeOrigin (and needs to be in s, not ms)
startTimestamp: browserPerformanceTimeOrigin ? browserPerformanceTimeOrigin / 1000 : undefined,
op: 'pageload',
metadata: { source: 'url' },
});
Expand Down