Skip to content

Commit

Permalink
Add (tracing) metrics around VCS calls
Browse files Browse the repository at this point in the history
Test Plan: N/A

Pull Request: #336
  • Loading branch information
yamadapc committed Feb 12, 2025
1 parent 03f1f0e commit f091169
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/core/core/src/SymbolPropagation.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import nullthrows from 'nullthrows';
import {setEqual} from '@atlaspack/utils';
import logger from '@atlaspack/logger';
import {md, convertSourceLocationToHighlight} from '@atlaspack/diagnostic';
import {instrument} from '@atlaspack/logger';
import {BundleBehavior, Priority} from './types';
import {fromProjectPathRelative, fromProjectPath} from './projectPath';
import {instrument} from './tracer';

export function propagateSymbols({
options,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/core/src/requests/AssetGraphRequestRust.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import invariant from 'assert';

import ThrowableDiagnostic from '@atlaspack/diagnostic';
import type {Async} from '@atlaspack/types';
import {instrument} from '@atlaspack/logger';

import AssetGraph, {nodeFromAssetGroup} from '../AssetGraph';
import type {AtlaspackV3} from '../atlaspack-v3';
Expand All @@ -15,7 +16,6 @@ import type {
AssetGraphRequestInput,
AssetGraphRequestResult,
} from './AssetGraphRequest';
import {instrument} from '../tracer';

type RunInput = {|
input: AssetGraphRequestInput,
Expand Down
5 changes: 5 additions & 0 deletions packages/core/fs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
"main": {
"includeNodeModules": {
"@atlaspack/build-cache": false,
"@atlaspack/diagnostic": false,
"@atlaspack/feature-flags": false,
"@atlaspack/logger": false,
"@atlaspack/rust": false,
"@atlaspack/types-internal": false,
"@atlaspack/utils": false,
Expand All @@ -33,7 +35,9 @@
"browser": {
"includeNodeModules": {
"@atlaspack/build-cache": false,
"@atlaspack/diagnostic": false,
"@atlaspack/feature-flags": false,
"@atlaspack/logger": false,
"@atlaspack/rust": false,
"@atlaspack/types-internal": false,
"@atlaspack/utils": false,
Expand All @@ -50,6 +54,7 @@
"dependencies": {
"@atlaspack/build-cache": "2.13.0",
"@atlaspack/feature-flags": "2.13.0",
"@atlaspack/logger": "2.13.0",
"@atlaspack/rust": "2.13.0",
"@atlaspack/types-internal": "2.13.0",
"@atlaspack/utils": "2.13.0",
Expand Down
14 changes: 7 additions & 7 deletions packages/core/fs/src/NodeVCSAwareFS.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {getVcsStateSnapshot, getEventsSince} from '@atlaspack/rust';
import type {FilePath} from '@atlaspack/types-internal';
import type {Event, Options as WatcherOptions} from '@parcel/watcher';
import {registerSerializableClass} from '@atlaspack/build-cache';
import {instrument, instrumentAsync} from '@atlaspack/logger';

// $FlowFixMe
import packageJSON from '../package.json';
Expand Down Expand Up @@ -34,14 +35,13 @@ export class NodeVCSAwareFS extends NodeFS {
const snapshotFileContent = snapshotFile.toString();
const {nativeSnapshotPath, vcsState} = JSON.parse(snapshotFileContent);

const watcherEventsSince = await this.watcher().getEventsSince(
dir,
nativeSnapshotPath,
opts,
const watcherEventsSince = await instrumentAsync(
'NodeVCSAwareFS::watchman.getEventsSince',
() => this.watcher().getEventsSince(dir, nativeSnapshotPath, opts),
);
const vcsEventsSince = getEventsSince(
this.#options.gitRepoPath,
vcsState.gitHash,
const vcsEventsSince = instrument(
'NodeVCSAwareFS::rust.getEventsSince',
() => getEventsSince(this.#options.gitRepoPath, vcsState.gitHash),
);
this.#options.logEventDiff(watcherEventsSince, vcsEventsSince);

Expand Down
3 changes: 2 additions & 1 deletion packages/core/logger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
},
"dependencies": {
"@atlaspack/diagnostic": "2.13.0",
"@atlaspack/events": "2.13.0"
"@atlaspack/events": "2.13.0",
"@atlaspack/rust": "2.13.0"
}
}
2 changes: 2 additions & 0 deletions packages/core/logger/src/Logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import {ValueEmitter} from '@atlaspack/events';
import {inspect} from 'util';
import {errorToDiagnostic, anyToDiagnostic} from '@atlaspack/diagnostic';

export {instrument, instrumentAsync} from './tracer';

class Logger {
#logEmitter /*: ValueEmitter<LogEvent> */ = new ValueEmitter();

Expand Down
File renamed without changes.

0 comments on commit f091169

Please sign in to comment.