Skip to content

Commit

Permalink
Rewrite NPM packages using Rollup
Browse files Browse the repository at this point in the history
  • Loading branch information
arendjr committed Oct 30, 2023
1 parent cef6a72 commit d2d12c5
Show file tree
Hide file tree
Showing 20 changed files with 577 additions and 131 deletions.
8 changes: 7 additions & 1 deletion deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
"strict": true
},
"imports": {
"$std/": "https://deno.land/[email protected]/"
"$std/": "https://deno.land/[email protected]/",
"$otel/api": "npm:@opentelemetry/api@^1.6.0",
"$otel/core": "npm:@opentelemetry/core@^1.17.0",
"$otel/exporter-metrics-otlp-http": "npm:@opentelemetry/exporter-metrics-otlp-http@^0.43.0",
"$otel/exporter-prometheus": "npm:@opentelemetry/exporter-prometheus@^0.43.0",
"$otel/resources": "npm:@opentelemetry/resources@^1.17.0",
"$otel/sdk-metrics": "npm:@opentelemetry/sdk-metrics@^1.17.0"
}
}
382 changes: 381 additions & 1 deletion deno.lock

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions examples/deno-fresh/deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,16 @@
"imports": {
"$autometrics/": "../../packages/autometrics/",
"$fresh/": "https://deno.land/x/[email protected]/",
"$otel/api": "npm:@opentelemetry/api@^1.6.0",
"$otel/core": "npm:@opentelemetry/core@^1.17.0",
"$otel/exporter-metrics-otlp-http": "npm:@opentelemetry/exporter-metrics-otlp-http@^0.43.0",
"$otel/resources": "npm:@opentelemetry/resources@^1.17.0",
"$otel/sdk-metrics": "npm:@opentelemetry/sdk-metrics@^1.17.0",
"$std/": "https://deno.land/[email protected]/",
"preact": "https://esm.sh/[email protected]",
"preact/": "https://esm.sh/[email protected]/",
"preact-render-to-string": "https://esm.sh/*[email protected]",
"@preact/signals": "https://esm.sh/*@preact/[email protected]",
"@preact/signals-core": "https://esm.sh/*@preact/[email protected]",
"$std/": "https://deno.land/[email protected]/"
"@preact/signals-core": "https://esm.sh/*@preact/[email protected]"
}
}
2 changes: 1 addition & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ test_permissions := "--allow-env --allow-net --allow-read --allow-sys"
build: (build-npm "")

build-npm version:
deno run --allow-env --allow-net=deno.land --allow-read --allow-run=yarn --allow-write=dist scripts/build_npm.ts {{version}}
deno run --allow-env --allow-ffi --allow-net=deno.land --allow-read --allow-run --allow-sys --allow-write=dist scripts/build_npm.ts {{version}}

build-examples:
#!/usr/bin/env bash
Expand Down
2 changes: 1 addition & 1 deletion packages/autometrics/src/buildInfo.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { UpDownCounter } from "npm:@opentelemetry/api@^1.6.0";
import type { UpDownCounter } from "$otel/api";

import { BUILD_INFO_DESCRIPTION, BUILD_INFO_NAME } from "./constants.ts";
import { getMeter } from "./instrumentation.ts";
Expand Down
4 changes: 2 additions & 2 deletions packages/autometrics/src/exporter-otlp-http/mod.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {
AggregationTemporalityPreference,
OTLPMetricExporter,
} from "npm:@opentelemetry/exporter-metrics-otlp-http@^0.43.0";
import { PeriodicExportingMetricReader } from "npm:@opentelemetry/sdk-metrics@^1.17.0";
} from "$otel/exporter-metrics-otlp-http";
import { PeriodicExportingMetricReader } from "$otel/sdk-metrics";

import {
BuildInfo,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MetricReader } from "npm:@opentelemetry/sdk-metrics@^1.17.0";
import { MetricReader } from "$otel/sdk-metrics";

import { ExporterOptions, registerExporter } from "../../mod.ts";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PeriodicExportingMetricReader } from "npm:@opentelemetry/sdk-metrics@^1.17.0";
import { PeriodicExportingMetricReader } from "$otel/sdk-metrics";

import {
BuildInfo,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import {
BindOnceFuture,
ExportResult,
ExportResultCode,
} from "npm:@opentelemetry/core@^1.17.0";
import { BindOnceFuture, ExportResult, ExportResultCode } from "$otel/core";
import {
AggregationTemporality,
InstrumentType,
PushMetricExporter,
ResourceMetrics,
} from "npm:@opentelemetry/sdk-metrics@^1.17.0";
} from "$otel/sdk-metrics";

import { amLogger } from "../../mod.ts";
import { PrometheusSerializer } from "../exporter-prometheus/PrometheusSerializer.ts";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
Aggregation,
AggregationTemporality,
MetricReader,
} from "npm:@opentelemetry/sdk-metrics@^1.17.0";
} from "$otel/sdk-metrics";

import { amLogger } from "../../mod.ts";
import { PrometheusSerializer } from "./PrometheusSerializer.ts";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
* limitations under the License.
*/

import type { AttributeValue, Attributes } from "npm:@opentelemetry/api@^1.6.0";
import { hrTimeToMilliseconds } from "npm:@opentelemetry/core@^1.17.0";
import type { IResource } from "npm:@opentelemetry/resources@^1.17.0";
import type { AttributeValue, Attributes } from "$otel/api";
import { hrTimeToMilliseconds } from "$otel/core";
import type { IResource } from "$otel/resources";
import {
DataPoint,
DataPointType,
Expand All @@ -25,7 +25,7 @@ import {
MetricData,
ResourceMetrics,
ScopeMetrics,
} from "npm:@opentelemetry/sdk-metrics@^1.17.0";
} from "$otel/sdk-metrics";

import { amLogger } from "../../mod.ts";

Expand Down
2 changes: 1 addition & 1 deletion packages/autometrics/src/exporter-prometheus/mod.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MetricReader } from "npm:@opentelemetry/sdk-metrics@^1.17.0";
import { MetricReader } from "$otel/sdk-metrics";

import {
BuildInfo,
Expand Down
5 changes: 1 addition & 4 deletions packages/autometrics/src/histograms.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import {
ExplicitBucketHistogramAggregation,
View,
} from "npm:@opentelemetry/sdk-metrics@^1.17.0";
import { ExplicitBucketHistogramAggregation, View } from "$otel/sdk-metrics";

import { HISTOGRAM_NAME } from "./constants.ts";

Expand Down
7 changes: 2 additions & 5 deletions packages/autometrics/src/instrumentation.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import type { Meter } from "npm:@opentelemetry/api@^1.6.0";
import {
MeterProvider,
MetricReader,
} from "npm:@opentelemetry/sdk-metrics@^1.17.0";
import type { Meter } from "$otel/api";
import { MeterProvider, MetricReader } from "$otel/sdk-metrics";

import { createDefaultHistogramView } from "./histograms.ts";
import { TemporaryMeter } from "./temporaryMeter.ts";
Expand Down
2 changes: 1 addition & 1 deletion packages/autometrics/src/temporaryMeter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
ObservableUpDownCounter,
UpDownCounter,
createNoopMeter,
} from "npm:@opentelemetry/api@^1.6.0";
} from "$otel/api";

import { warn } from "./logger.ts";

Expand Down
7 changes: 2 additions & 5 deletions packages/autometrics/src/wrappers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Attributes, ValueType } from "npm:@opentelemetry/api@^1.6.0";
import { Attributes, ValueType } from "$otel/api";

import { amLogger } from "../mod.ts";
import {
COUNTER_DESCRIPTION,
COUNTER_NAME,
Expand Down Expand Up @@ -517,9 +516,7 @@ export function Autometrics<T extends FunctionSig>(
}

default:
amLogger.warn(
"Autometrics decorator can only be used on classes and methods",
);
warn("Autometrics decorator can only be used on classes and methods");
}
};
}
Expand Down
2 changes: 1 addition & 1 deletion packages/autometrics/tests/temporality.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { assertEquals } from "$std/assert/mod.ts";

import { MetricData } from "npm:@opentelemetry/sdk-metrics@^1.17.0";
import { MetricData } from "$otel/sdk-metrics";
import { autometrics } from "../mod.ts";
import { COUNTER_NAME } from "../src/constants.ts";
import {
Expand Down
2 changes: 1 addition & 1 deletion packages/autometrics/tests/testUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
InMemoryMetricExporter,
MetricReader,
PeriodicExportingMetricReader,
} from "npm:@opentelemetry/sdk-metrics@^1.17.0";
} from "$otel/sdk-metrics";

import { registerExporter } from "../mod.ts";
import { PrometheusSerializer } from "../src/exporter-prometheus/PrometheusSerializer.ts";
Expand Down
Loading

0 comments on commit d2d12c5

Please sign in to comment.