Skip to content

Commit d0448c3

Browse files
committed
Move the vendor stuff into the package
1 parent 5ca3e27 commit d0448c3

File tree

381 files changed

+87
-18685
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

381 files changed

+87
-18685
lines changed

packages/lib/README.md

+3-19

packages/lib/README.node.md

+35

packages/lib/buildInfo.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { otelApi } from "./deps.ts";
1+
import type { UpDownCounter } from "./vendor/opentelemetry-api/mod.ts";
22

33
import { BUILD_INFO_DESCRIPTION, BUILD_INFO_NAME } from "./constants.ts";
44
import { getBranch, getCommit, getVersion } from "./platform.deno.ts";
@@ -46,7 +46,7 @@ export type BuildInfo = {
4646
* @internal
4747
*/
4848
export let buildInfo: BuildInfo = {};
49-
let buildInfoGauge: otelApi.UpDownCounter;
49+
let buildInfoGauge: UpDownCounter;
5050

5151
/**
5252
* Records the build info for the application.

packages/lib/deps.ts

-6
This file was deleted.

packages/lib/instrumentation.ts

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
import { BuildInfo, buildInfo, recordBuildInfo } from "./buildInfo.ts";
22
import { HISTOGRAM_NAME } from "./constants.ts";
3-
import { otelExporterPrometheus, otelSdkMetrics } from "./deps.ts";
4-
5-
const { PrometheusExporter, PrometheusSerializer } = otelExporterPrometheus;
6-
const {
3+
import {
4+
PrometheusExporter,
5+
PrometheusSerializer,
6+
} from "./vendor/opentelemetry-exporter-prometheus/mod.ts";
7+
import {
78
AggregationTemporality,
89
ExplicitBucketHistogramAggregation,
910
InMemoryMetricExporter,
11+
MetricReader,
1012
MeterProvider,
1113
PeriodicExportingMetricReader,
1214
View,
13-
} = otelSdkMetrics;
15+
} from "./vendor/opentelemetry-sdk-metrics/mod.ts";
1416

1517
let globalShouldEagerlyPush = false;
1618
let pushMetrics = () => {};
17-
let autometricsMeterProvider: otelSdkMetrics.MeterProvider;
18-
let exporter: otelSdkMetrics.MetricReader;
19+
let autometricsMeterProvider: MeterProvider;
20+
let exporter: MetricReader;
1921

20-
type Exporter = otelSdkMetrics.MetricReader;
22+
type Exporter = MetricReader;
2123

2224
/**
2325
* @group Initialization API

packages/lib/tests/buildInfo.test.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1+
import {
2+
AggregationTemporality,
3+
InMemoryMetricExporter,
4+
PeriodicExportingMetricReader,
5+
} from "../vendor/opentelemetry-sdk-metrics/mod.ts";
16
import { assertMatch } from "./deps.ts";
27
import { collectAndSerialize } from "./util.ts";
38
import { getMetricsProvider } from "../instrumentation.ts";
49
import { init } from "../instrumentation.ts";
5-
import { otelSdkMetrics } from "../deps.ts";
610

711
const buildInfo = {
812
version: "1.0.0",
@@ -11,8 +15,8 @@ const buildInfo = {
1115
};
1216

1317
/*Deno.test("Autometrics build info tests", async (t) => {
14-
const exporter = new otelSdkMetrics.PeriodicExportingMetricReader({
15-
exporter: new otelSdkMetrics.InMemoryMetricExporter(otelSdkMetrics.AggregationTemporality.DELTA),
18+
const exporter = new PeriodicExportingMetricReader({
19+
exporter: new InMemoryMetricExporter(AggregationTemporality.DELTA),
1620
});
1721
1822
init({ buildInfo, exporter });

packages/lib/tests/concurrency.test.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1-
import { otelSdkMetrics } from "../deps.ts";
1+
import {
2+
InMemoryMetricExporter,
3+
PeriodicExportingMetricReader,
4+
} from "../vendor/opentelemetry-sdk-metrics/mod.ts";
25
import { assertMatch } from "./deps.ts";
36
import { autometrics, init } from "../mod.ts";
47
import { collectAndSerialize } from "./util.ts";
58
import { getMetricsProvider } from "../instrumentation.ts";
69

710
/*Deno.test("Autometrics concurrency tests", async (t) => {
8-
const exporter = new otelSdkMetrics.PeriodicExportingMetricReader({
11+
const exporter = new PeriodicExportingMetricReader({
912
// 0 - using delta aggregation temporality setting
1013
// to ensure data submitted to the gateway is accurate
11-
exporter: new otelSdkMetrics.InMemoryMetricExporter(0),
14+
exporter: new InMemoryMetricExporter(0),
1215
});
1316
1417
init({ exporter });

packages/lib/tests/integration.test.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1+
import {
2+
AggregationTemporality,
3+
InMemoryMetricExporter,
4+
PeriodicExportingMetricReader,
5+
} from "../vendor/opentelemetry-sdk-metrics/mod.ts";
16
import { Autometrics, autometrics, init } from "../mod.ts";
27
import { assertMatch, assertRejects } from "./deps.ts";
38
import { collectAndSerialize } from "./util.ts";
49
import { getMetricsProvider } from "../instrumentation.ts";
5-
import { otelSdkMetrics } from "../deps.ts";
610

711
/*Deno.test("Autometrics integration test", async (t) => {
8-
const exporter = new otelSdkMetrics.PeriodicExportingMetricReader({
12+
const exporter = new PeriodicExportingMetricReader({
913
// 0 - using delta aggregation temporality setting
1014
// to ensure data submitted to the gateway is accurate
11-
exporter: new otelSdkMetrics.InMemoryMetricExporter(otelSdkMetrics.AggregationTemporality.DELTA),
15+
exporter: new InMemoryMetricExporter(AggregationTemporality.DELTA),
1216
});
1317
1418
init({ exporter });

packages/lib/tests/objectives.test.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
import {
2+
InMemoryMetricExporter,
3+
PeriodicExportingMetricReader,
4+
} from "../vendor/opentelemetry-sdk-metrics/mod.ts";
15
import { assertMatch } from "./deps.ts";
26
import {
37
autometrics,
@@ -7,13 +11,12 @@ import {
711
} from "../mod.ts";
812
import { collectAndSerialize } from "./util.ts";
913
import { getMetricsProvider } from "../instrumentation.ts";
10-
import { otelSdkMetrics } from "../deps.ts";
1114

1215
/*Deno.test("Autometrics objectives test", async (t) => {
13-
const exporter = new otelSdkMetrics.PeriodicExportingMetricReader({
16+
const exporter = new PeriodicExportingMetricReader({
1417
// 0 - using delta aggregation temporality setting
1518
// to ensure data submitted to the gateway is accurate
16-
exporter: new otelSdkMetrics.InMemoryMetricExporter(0),
19+
exporter: new InMemoryMetricExporter(0),
1720
});
1821
1922
init({ exporter });

packages/lib/tests/util.ts

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
import { otelExporterPrometheus, otelSdkMetrics } from "../deps.ts";
1+
import { PeriodicExportingMetricReader } from "../vendor/opentelemetry-sdk-metrics/mod.ts";
2+
import { PrometheusSerializer } from "../vendor/opentelemetry-exporter-prometheus/mod.ts";
23

34
export async function collectAndSerialize(
4-
exporter: otelSdkMetrics.PeriodicExportingMetricReader,
5+
exporter: PeriodicExportingMetricReader,
56
) {
67
const response = await exporter.collect();
78

8-
return new otelExporterPrometheus.PrometheusSerializer().serialize(
9-
response.resourceMetrics,
10-
);
9+
return new PrometheusSerializer().serialize(response.resourceMetrics);
1110
}
File renamed without changes.
File renamed without changes.
File renamed without changes.

packages/lib/wrappers.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { otelApi } from "./deps.ts";
1+
import type { Attributes } from "./vendor/opentelemetry-api/mod.ts";
22
import { setBuildInfo } from "./buildInfo.ts";
33
import {
44
COUNTER_DESCRIPTION,
@@ -216,8 +216,8 @@ export function autometrics<F extends FunctionSig>(
216216
return fn as F;
217217
}
218218

219-
const counterObjectiveAttributes: otelApi.Attributes = {};
220-
const histogramObjectiveAttributes: otelApi.Attributes = {};
219+
const counterObjectiveAttributes: Attributes = {};
220+
const histogramObjectiveAttributes: Attributes = {};
221221

222222
// NOTE - Gravel Gateway will reject two metrics of the same name if one of them has a subset of the attributes of the other
223223
// This means to be able to support functions that have objectives, as well as functions that don't, we need to

scripts/build_npm.ts

+4-12
Original file line numberDiff line numberDiff line change
@@ -51,24 +51,16 @@ for (const [dir, name] of Object.entries(packages)) {
5151
},
5252
mappings: {
5353
"./packages/lib/platform.deno.ts": "./packages/lib/platform.node.ts",
54-
"./vendor/opentelemetry-api/mod.ts": {
54+
"./packages/lib/vendor/opentelemetry-api/mod.ts": {
5555
name: "@opentelemetry/api",
5656
peerDependency: true,
5757
version: "^1.4.0",
5858
},
59-
"./vendor/opentelemetry-core/mod.ts": {
60-
name: "@opentelemetry/core",
61-
version: "^1.15.0",
62-
},
63-
"./vendor/opentelemetry-exporter-prometheus/mod.ts": {
59+
"./packages/lib/vendor/opentelemetry-exporter-prometheus/mod.ts": {
6460
name: "@opentelemetry/exporter-prometheus",
6561
version: "^0.41.0",
6662
},
67-
"./vendor/opentelemetry-resources/mod.ts": {
68-
name: "@opentelemetry/resources",
69-
version: "^1.15.0",
70-
},
71-
"./vendor/opentelemetry-sdk-metrics/mod.ts": {
63+
"./packages/lib/vendor/opentelemetry-sdk-metrics/mod.ts": {
7264
name: "@opentelemetry/sdk-metrics",
7365
version: "^1.15.0",
7466
},
@@ -83,7 +75,7 @@ for (const [dir, name] of Object.entries(packages)) {
8375
// steps to run after building and before running the tests
8476
Deno.copyFileSync("LICENSE", `${OUT_DIR}/${dir}/LICENSE`);
8577
Deno.copyFileSync(
86-
`packages/${dir}/README.md`,
78+
`packages/${dir}/README.node.md`,
8779
`${OUT_DIR}/${dir}/README.md`,
8880
);
8981
},

0 commit comments

Comments
 (0)