Skip to content

Commit d7875a5

Browse files
authored
Prepare for release 1.0.1 (#151)
* Add a troubleshooting section to the Contributing > Common Commands doc * Do not rely on global biome in justfile * Modify autometrics/src/platform.node.ts to work in deno test env (import process) * Add a test for infinite looping when readClosest cannot find a file in node.js * Format files to appease biome * Clean node modules from parcle transformer * HACK - fix type issues with parcel-transformer when building * Fix build-all and add utility for reloading deno cache * Update changelog * Bump version and update yarn lockfiles for examples * Remove clean-all from build-all because ci does not have bash extensions we need * Update contributing doc troubleshooting
1 parent fd7a386 commit d7875a5

File tree

11 files changed

+87
-17
lines changed

11 files changed

+87
-17
lines changed

CHANGELOG.md

+10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Changelog
22

3+
## [v1.0.1]
4+
5+
This release fixes two issues. Thanks to @benjibuiltit for his contributions!
6+
7+
### Fixed
8+
9+
- #149 - Fixed an issue where autometrics in a Node.js environment would fail if it was not running inside a git repository
10+
- #150 - Fixed rendering of a function name and module when using the `relfect-metadata` package
11+
12+
313
## [v1.0.0]
414

515
This release features full compliance with the

CONTRIBUTING.md

+9
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ The `justfile` has several commands that are useful during development:
3333

3434
Run `just -l` for a list of all available commands.
3535

36+
#### Troubleshooting
37+
38+
If you run into dependency-related issues with the `justfile` build commands, you may need to do one or any of the following:
39+
40+
- Remove `node_modules` (`just clean-all`)
41+
- Reload all cached deno dependencies (`just reload-all`)
42+
43+
Note that you'll need several tools installed to run the examples. This includes `bun` and `deno`.
44+
3645
### Overview
3746

3847
#### `packages/autometrics`

examples/fastify/yarn.lock

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ __metadata:
55
version: 6
66
cacheKey: 8
77

8-
"@autometrics/[email protected].0, @autometrics/autometrics@workspace:../../dist/autometrics":
8+
"@autometrics/[email protected].1, @autometrics/autometrics@workspace:../../dist/autometrics":
99
version: 0.0.0-use.local
1010
resolution: "@autometrics/autometrics@workspace:../../dist/autometrics"
1111
dependencies:
@@ -28,7 +28,7 @@ __metadata:
2828
version: 0.0.0-use.local
2929
resolution: "@autometrics/exporter-prometheus@portal:../../dist/exporter-prometheus::locator=fastify-example%40workspace%3A."
3030
dependencies:
31-
"@autometrics/autometrics": 1.0.0
31+
"@autometrics/autometrics": 1.0.1
3232
"@opentelemetry/api": 1.7.0
3333
"@opentelemetry/exporter-prometheus": 0.45.0
3434
"@opentelemetry/sdk-metrics": 1.18.0
@@ -39,7 +39,7 @@ __metadata:
3939
version: 0.0.0-use.local
4040
resolution: "@autometrics/exporter-prometheus@workspace:../../dist/exporter-prometheus"
4141
dependencies:
42-
"@autometrics/autometrics": 1.0.0
42+
"@autometrics/autometrics": 1.0.1
4343
"@opentelemetry/api": 1.7.0
4444
"@opentelemetry/exporter-prometheus": 0.45.0
4545
"@opentelemetry/sdk-metrics": 1.18.0

examples/react-app-experimental/yarn.lock

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ __metadata:
1515
languageName: node
1616
linkType: hard
1717

18-
"@autometrics/[email protected].0, @autometrics/autometrics@workspace:../../dist/autometrics":
18+
"@autometrics/[email protected].1, @autometrics/autometrics@workspace:../../dist/autometrics":
1919
version: 0.0.0-use.local
2020
resolution: "@autometrics/autometrics@workspace:../../dist/autometrics"
2121
dependencies:
@@ -38,7 +38,7 @@ __metadata:
3838
version: 0.0.0-use.local
3939
resolution: "@autometrics/exporter-otlp-http@portal:../../dist/exporter-otlp-http::locator=react-app-example%40workspace%3A."
4040
dependencies:
41-
"@autometrics/autometrics": 1.0.0
41+
"@autometrics/autometrics": 1.0.1
4242
"@opentelemetry/api": 1.7.0
4343
"@opentelemetry/exporter-metrics-otlp-http": 0.45.0
4444
"@opentelemetry/sdk-metrics": 1.18.0
@@ -49,7 +49,7 @@ __metadata:
4949
version: 0.0.0-use.local
5050
resolution: "@autometrics/exporter-prometheus@workspace:../../dist/exporter-prometheus"
5151
dependencies:
52-
"@autometrics/autometrics": 1.0.0
52+
"@autometrics/autometrics": 1.0.1
5353
"@opentelemetry/api": 1.7.0
5454
"@opentelemetry/exporter-prometheus": 0.45.0
5555
"@opentelemetry/sdk-metrics": 1.18.0

justfile

+22-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
alias b := build
22
alias l := lint
33
alias t := test
4+
alias reload-all := reload-all-deno-cache
45

56
examples := "deno-fresh express faas-experimental fastify hono-bun react-app-experimental"
67

78
lib_packages := "autometrics exporter-otlp-http exporter-prometheus exporter-prometheus-push-gateway"
89

910
test_permissions := "--allow-env --allow-net --allow-read --allow-sys --allow-write"
1011

12+
biome_permissions := "--allow-env --allow-read --allow-run --allow-write"
13+
1114
build: (build-npm "")
1215

1316
build-npm version:
@@ -22,13 +25,17 @@ build-examples:
2225
popd
2326
done
2427

28+
# NOTE - You may need to run `just clean` in the project root before running this command
2529
build-parcel-transformer:
2630
cd packages/parcel-transformer-autometrics; just build
2731

32+
# NOTE - You may need to run `just clean` in the project root before running this command
2833
build-typescript-plugin:
2934
cd packages/typescript-plugin; just build
3035

31-
build-all: build build-examples build-parcel-transformer build-typescript-plugin
36+
# NOTE - Build the non-deno things first, then the deno things (this order is important)
37+
# NOTE - If this fails, try running `clean-all` then run this command again
38+
build-all: build-parcel-transformer build-typescript-plugin build build-examples
3239

3340
test:
3441
deno test {{test_permissions}} packages/autometrics
@@ -87,14 +94,25 @@ clean-typescript-plugin:
8794

8895
clean-all: clean clean-examples clean-parcel-transformer clean-typescript-plugin
8996

97+
reload-all-deno-cache:
98+
#!/usr/bin/env bash
99+
set -euxo pipefail
100+
for package in {{lib_packages}}; do
101+
pushd "packages/$package"
102+
# Ignore directories named `tests` or `dist` or `node_modules`
103+
# Then reload the Deno cache for any imports in files that end in .ts or .js
104+
find . \( -type d \( -name "tests" -o -name "dist" -o -name "node_modules" \) -prune \) -o \( -type f \( -name "*.ts" \) -exec deno cache --reload {} + \)
105+
popd
106+
done
107+
90108
fix:
91-
biome check --apply-unsafe packages
109+
deno run {{biome_permissions}} npm:@biomejs/biome check --apply-unsafe packages
92110

93111
format:
94-
biome format --write packages
112+
deno run {{biome_permissions}} npm:@biomejs/biome format --write packages
95113

96114
lint:
97-
biome ci packages
115+
deno run {{biome_permissions}} npm:@biomejs/biome ci packages
98116

99117
release-lib:
100118
#!/usr/bin/env bash

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"private": true,
33
"name": "autometrics-monorepo",
44
"packageManager": "[email protected]",
5-
"version": "1.0.0",
5+
"version": "1.0.1",
66
"workspaces": [
77
"dist/autometrics",
88
"dist/exporter-otlp-http",

packages/autometrics/src/platform.node.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import { AsyncLocalStorage } from "node:async_hooks";
66
import { readFileSync } from "node:fs";
77
import { dirname, join, parse } from "node:path";
8+
import * as process from "node:process";
89

910
import { AUTOMETRICS_DEFAULT_SERVICE_NAME } from "./constants.ts";
1011
import { getGitRepositoryUrl, getPackageStringField } from "./platformUtils.ts";
@@ -118,7 +119,7 @@ export function getALSInstance() {
118119
* @internal
119120
*/
120121
export function isRootPath(pathToCheck: string): boolean {
121-
return pathToCheck == parse(getCwd()).root;
122+
return pathToCheck === parse(getCwd()).root;
122123
}
123124

124125
function detectPackageName(): string | undefined {
@@ -142,7 +143,7 @@ function detectRepositoryUrl(): string | undefined {
142143
} catch {}
143144
}
144145

145-
function readClosest(path: string): Uint8Array {
146+
export function readClosest(path: string): Uint8Array {
146147
let basePath = getCwd();
147148
while (basePath.length > 0) {
148149
try {

packages/autometrics/src/temporaryMeter.ts

+12-3
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,10 @@ class TemporaryCounter<AttributesTypes extends Attributes = Attributes>
293293
> = [];
294294
private _counter: Counter<AttributesTypes> | undefined;
295295

296-
constructor(public name: string, public options?: MetricOptions) {}
296+
constructor(
297+
public name: string,
298+
public options?: MetricOptions,
299+
) {}
297300

298301
add(value: number, attributes?: AttributesTypes, context?: Context): void {
299302
if (this._counter) {
@@ -321,7 +324,10 @@ class TemporaryHistogram<AttributesTypes extends Attributes = Attributes>
321324
[number, AttributesTypes | undefined, Context | undefined]
322325
> = [];
323326

324-
constructor(public name: string, public options?: MetricOptions) {}
327+
constructor(
328+
public name: string,
329+
public options?: MetricOptions,
330+
) {}
325331

326332
record(value: number, attributes?: AttributesTypes, context?: Context): void {
327333
if (this._histogram) {
@@ -350,7 +356,10 @@ class TemporaryObservable<AttributesTypes extends Attributes = Attributes>
350356
private _listeners: Array<ObservableCallback<AttributesTypes>> = [];
351357
private _observable: Observable<AttributesTypes> | undefined;
352358

353-
constructor(public name: string, public options?: MetricOptions) {}
359+
constructor(
360+
public name: string,
361+
public options?: MetricOptions,
362+
) {}
354363

355364
addCallback(callback: ObservableCallback<AttributesTypes>): void {
356365
if (this._observable) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { assertThrows } from "$std/assert/mod.ts";
2+
import { readClosest } from "../src/platform.node.ts";
3+
4+
Deno.test("Node.js platform tests", async (t) => {
5+
// NOTE: Added this test as a quick way to cover the fix from #149 - fix an infinite loop which happens when autometrics is initialized in a node service without a git repository
6+
await t.step(
7+
"readClosest does not loop infinitely on nonexistent file",
8+
() => {
9+
assertThrows(
10+
() => readClosest("nonexistent.file"),
11+
Error,
12+
"Could not read nonexistent.file",
13+
);
14+
},
15+
);
16+
});

packages/parcel-transformer-autometrics/justfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ type-check:
1111
yarn tsc -p tsconfig.json --noEmit
1212

1313
clean:
14-
rm -Rf dist
14+
rm -Rf dist node_modules
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
11
declare module "@parcel/profiler" {
22
type TraceMeasurement = {};
33
}
4+
5+
declare module "@parcel/watcher" {
6+
type Event = {};
7+
type EventType = {};
8+
type AsyncSubscription = {};
9+
type Options = {};
10+
}

0 commit comments

Comments
 (0)