@pocket-tools/tracing 1.6.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +7 -7
- package/.turbo/turbo-semantic-release.log +67 -67
- package/dist/index.d.mts +2 -3
- package/dist/index.d.ts +2 -3
- package/dist/index.js +37 -12
- package/dist/index.mjs +40 -19
- package/package.json +6 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
[34mESM[39m Build start
|
|
11
11
|
[33mCJS[39m [33mYou have emitDecoratorMetadata enabled but @swc/core was not installed, skipping swc plugin[39m
|
|
12
12
|
[33mESM[39m [33mYou have emitDecoratorMetadata enabled but @swc/core was not installed, skipping swc plugin[39m
|
|
13
|
-
[32mCJS[39m [1mdist/index.js [22m[
|
|
14
|
-
[32mCJS[39m ⚡️ Build success in
|
|
15
|
-
[32mESM[39m [1mdist/index.mjs [22m[
|
|
16
|
-
[32mESM[39m ⚡️ Build success in
|
|
13
|
+
[32mCJS[39m [1mdist/index.js [22m[32m8.24 KB[39m
|
|
14
|
+
[32mCJS[39m ⚡️ Build success in 124ms
|
|
15
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m6.00 KB[39m
|
|
16
|
+
[32mESM[39m ⚡️ Build success in 120ms
|
|
17
17
|
[34mDTS[39m Build start
|
|
18
|
-
[32mDTS[39m ⚡️ Build success in
|
|
19
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[
|
|
20
|
-
[32mDTS[39m [1mdist/index.d.mts [22m[
|
|
18
|
+
[32mDTS[39m ⚡️ Build success in 8668ms
|
|
19
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m623.00 B[39m
|
|
20
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m623.00 B[39m
|
|
@@ -14,79 +14,79 @@
|
|
|
14
14
|
[34mESM[39m Build start
|
|
15
15
|
[33mCJS[39m [33mYou have emitDecoratorMetadata enabled but @swc/core was not installed, skipping swc plugin[39m
|
|
16
16
|
[33mESM[39m [33mYou have emitDecoratorMetadata enabled but @swc/core was not installed, skipping swc plugin[39m
|
|
17
|
-
[
|
|
18
|
-
[
|
|
19
|
-
[
|
|
20
|
-
[
|
|
17
|
+
[32mCJS[39m [1mdist/index.js [22m[32m8.24 KB[39m
|
|
18
|
+
[32mCJS[39m ⚡️ Build success in 139ms
|
|
19
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m6.00 KB[39m
|
|
20
|
+
[32mESM[39m ⚡️ Build success in 140ms
|
|
21
21
|
[34mDTS[39m Build start
|
|
22
|
-
[32mDTS[39m ⚡️ Build success in
|
|
23
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[
|
|
24
|
-
[32mDTS[39m [1mdist/index.d.mts [22m[
|
|
22
|
+
[32mDTS[39m ⚡️ Build success in 4782ms
|
|
23
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m623.00 B[39m
|
|
24
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m623.00 B[39m
|
|
25
25
|
|
|
26
26
|
> @pocket-tools/tracing@0.0.0-development semantic-release /home/runner/work/pocket-monorepo/pocket-monorepo/packages/tracing
|
|
27
27
|
> semantic-release
|
|
28
28
|
|
|
29
|
-
[
|
|
30
|
-
[
|
|
31
|
-
[
|
|
32
|
-
[
|
|
33
|
-
[
|
|
34
|
-
[
|
|
35
|
-
[
|
|
36
|
-
[
|
|
37
|
-
[
|
|
38
|
-
[
|
|
39
|
-
[
|
|
40
|
-
[
|
|
41
|
-
[
|
|
29
|
+
[8:36:37 PM] [semantic-release] › ℹ Running semantic-release version 24.1.0
|
|
30
|
+
[8:36:38 PM] [semantic-release] › ✔ Loaded plugin "verifyConditions" from "@semantic-release/npm"
|
|
31
|
+
[8:36:38 PM] [semantic-release] › ✔ Loaded plugin "verifyConditions" from "@semantic-release/github"
|
|
32
|
+
[8:36:38 PM] [semantic-release] › ✔ Loaded plugin "prepare" from "@semantic-release/npm"
|
|
33
|
+
[8:36:38 PM] [semantic-release] › ✔ Loaded plugin "publish" from "@semantic-release/npm"
|
|
34
|
+
[8:36:38 PM] [semantic-release] › ✔ Loaded plugin "publish" from "@semantic-release/github"
|
|
35
|
+
[8:36:38 PM] [semantic-release] › ✔ Loaded plugin "addChannel" from "@semantic-release/npm"
|
|
36
|
+
[8:36:38 PM] [semantic-release] › ✔ Loaded plugin "addChannel" from "@semantic-release/github"
|
|
37
|
+
[8:36:39 PM] [semantic-release] › ✔ Run automated release from branch main on repository git+https://github.com/Pocket/pocket-monorepo.git
|
|
38
|
+
[8:36:40 PM] [semantic-release] › ✔ Allowed to push to the Git repository
|
|
39
|
+
[8:36:40 PM] [semantic-release] › ℹ Start step "verifyConditions" of plugin "@semantic-release/npm"
|
|
40
|
+
[8:36:40 PM] [semantic-release] [@semantic-release/npm] › ℹ Verify authentication for registry https://registry.npmjs.org/
|
|
41
|
+
[8:36:40 PM] [semantic-release] [@semantic-release/npm] › ℹ Wrote NPM_TOKEN to /tmp/6b33a06555b543124f1a259142503f19/.npmrc
|
|
42
42
|
pocket-npm
|
|
43
|
-
[
|
|
44
|
-
[
|
|
45
|
-
[
|
|
46
|
-
[
|
|
47
|
-
[
|
|
48
|
-
[
|
|
49
|
-
[
|
|
50
|
-
[
|
|
51
|
-
[
|
|
52
|
-
[
|
|
43
|
+
[8:36:40 PM] [semantic-release] › ✔ Completed step "verifyConditions" of plugin "@semantic-release/npm"
|
|
44
|
+
[8:36:40 PM] [semantic-release] › ℹ Start step "verifyConditions" of plugin "@semantic-release/github"
|
|
45
|
+
[8:36:40 PM] [semantic-release] [@semantic-release/github] › ℹ Verify GitHub authentication (https://api.github.com)
|
|
46
|
+
[8:36:40 PM] [semantic-release] › ✔ Completed step "verifyConditions" of plugin "@semantic-release/github"
|
|
47
|
+
[8:36:40 PM] [semantic-release] › ℹ Found git tag @pocket-tools/tracing-v1.6.1 associated with version 1.6.1 on branch main
|
|
48
|
+
[8:36:40 PM] [semantic-release] › ℹ Found 4 commits since last release
|
|
49
|
+
[8:36:40 PM] [semantic-release] › ℹ Start step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
|
|
50
|
+
[8:36:40 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ Start step "analyzeCommits" of plugin "@semantic-release/commit-analyzer"
|
|
51
|
+
[8:36:40 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ Found 1 commits for package @pocket-tools/tracing since last release
|
|
52
|
+
[8:36:40 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ Analyzing commit: feat(otel): adding in basic tracing via otel (#800)
|
|
53
53
|
|
|
54
|
-
* Revert "Revert "feat(otel): adding in basic tracing via otel (#
|
|
54
|
+
* Revert "Revert "feat(otel): adding in basic tracing via otel (#798)" (#799)"
|
|
55
55
|
|
|
56
|
-
This reverts commit
|
|
56
|
+
This reverts commit 57c2a13f78151326975cb174709a549970a06ed3.
|
|
57
57
|
|
|
58
|
-
*
|
|
59
|
-
[
|
|
60
|
-
[
|
|
61
|
-
[
|
|
62
|
-
[
|
|
63
|
-
[
|
|
64
|
-
[
|
|
65
|
-
[
|
|
66
|
-
[
|
|
67
|
-
[
|
|
68
|
-
[
|
|
69
|
-
[
|
|
70
|
-
[
|
|
71
|
-
[
|
|
72
|
-
[
|
|
73
|
-
[
|
|
74
|
-
[
|
|
75
|
-
[
|
|
76
|
-
[
|
|
77
|
-
[
|
|
78
|
-
[
|
|
79
|
-
[
|
|
80
|
-
[
|
|
81
|
-
[
|
|
82
|
-
[
|
|
83
|
-
[
|
|
84
|
-
[
|
|
85
|
-
[
|
|
86
|
-
[
|
|
87
|
-
[
|
|
88
|
-
[
|
|
89
|
-
[
|
|
90
|
-
[
|
|
91
|
-
[
|
|
92
|
-
[
|
|
58
|
+
* fix(collector): move to an otel collector
|
|
59
|
+
[8:36:40 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ The release type for the commit is minor
|
|
60
|
+
[8:36:40 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ Analysis of 1 commits complete: minor release
|
|
61
|
+
[8:36:40 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ Completed step "analyzeCommits" of plugin "@semantic-release/commit-analyzer"
|
|
62
|
+
[8:36:40 PM] [semantic-release] › ✔ Completed step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
|
|
63
|
+
[8:36:40 PM] [semantic-release] › ℹ Start step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
|
|
64
|
+
[8:36:40 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ Plugin "@semantic-release/release-notes-generator" does not provide step "analyzeCommits"
|
|
65
|
+
[8:36:40 PM] [semantic-release] › ✔ Completed step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
|
|
66
|
+
[8:36:40 PM] [semantic-release] › ℹ Start step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
|
|
67
|
+
[8:36:40 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ Plugin "@semantic-release/npm" does not provide step "analyzeCommits"
|
|
68
|
+
[8:36:40 PM] [semantic-release] › ✔ Completed step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
|
|
69
|
+
[8:36:40 PM] [semantic-release] › ℹ Start step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
|
|
70
|
+
[8:36:40 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ Plugin "@semantic-release/github" does not provide step "analyzeCommits"
|
|
71
|
+
[8:36:40 PM] [semantic-release] › ✔ Completed step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
|
|
72
|
+
[8:36:40 PM] [semantic-release] › ℹ Start step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
|
|
73
|
+
[8:36:40 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ No more plugins
|
|
74
|
+
[8:36:40 PM] [semantic-release] › ✔ Completed step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
|
|
75
|
+
[8:36:40 PM] [semantic-release] › ℹ Start step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
|
|
76
|
+
[8:36:40 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ No more plugins
|
|
77
|
+
[8:36:40 PM] [semantic-release] › ✔ Completed step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
|
|
78
|
+
[8:36:40 PM] [semantic-release] › ℹ Start step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
|
|
79
|
+
[8:36:40 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ No more plugins
|
|
80
|
+
[8:36:40 PM] [semantic-release] › ✔ Completed step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
|
|
81
|
+
[8:36:40 PM] [semantic-release] › ℹ Start step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
|
|
82
|
+
[8:36:40 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ No more plugins
|
|
83
|
+
[8:36:40 PM] [semantic-release] › ✔ Completed step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
|
|
84
|
+
[8:36:40 PM] [semantic-release] › ℹ Start step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
|
|
85
|
+
[8:36:40 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ No more plugins
|
|
86
|
+
[8:36:40 PM] [semantic-release] › ✔ Completed step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
|
|
87
|
+
[8:36:40 PM] [semantic-release] › ℹ Start step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
|
|
88
|
+
[8:36:40 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ No more plugins
|
|
89
|
+
[8:36:40 PM] [semantic-release] › ✔ Completed step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
|
|
90
|
+
[8:36:40 PM] [semantic-release] › ℹ The next release version is 1.7.0
|
|
91
|
+
[8:36:40 PM] [semantic-release] › ℹ Start step "generateNotes" of plugin "[Function: semantic-release-monorepo]"
|
|
92
|
+
[8:36:40 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ Plugin "@semantic-release/commit-analyzer" does not provide step "generateNotes"
|
package/dist/index.d.mts
CHANGED
|
@@ -10,9 +10,8 @@ type TracingConfig = {
|
|
|
10
10
|
release: string;
|
|
11
11
|
samplingRatio?: number;
|
|
12
12
|
graphQLDepth?: number;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
host?: string;
|
|
13
|
+
url?: string;
|
|
14
|
+
protocol?: 'GRPC' | 'HTTP';
|
|
16
15
|
logger?: DiagLogger;
|
|
17
16
|
sentry: NodeClient | undefined;
|
|
18
17
|
additionalInstrumentations?: AdditionalInstrumentation[];
|
package/dist/index.d.ts
CHANGED
|
@@ -10,9 +10,8 @@ type TracingConfig = {
|
|
|
10
10
|
release: string;
|
|
11
11
|
samplingRatio?: number;
|
|
12
12
|
graphQLDepth?: number;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
host?: string;
|
|
13
|
+
url?: string;
|
|
14
|
+
protocol?: 'GRPC' | 'HTTP';
|
|
16
15
|
logger?: DiagLogger;
|
|
17
16
|
sentry: NodeClient | undefined;
|
|
18
17
|
additionalInstrumentations?: AdditionalInstrumentation[];
|
package/dist/index.js
CHANGED
|
@@ -39,14 +39,22 @@ var import_process = __toESM(require("process"));
|
|
|
39
39
|
var import_sdk_node = require("@opentelemetry/sdk-node");
|
|
40
40
|
var import_api = require("@opentelemetry/api");
|
|
41
41
|
var import_instrumentation_knex = require("@opentelemetry/instrumentation-knex");
|
|
42
|
+
var import_exporter_trace_otlp_http = require("@opentelemetry/exporter-trace-otlp-http");
|
|
42
43
|
var import_exporter_trace_otlp_grpc = require("@opentelemetry/exporter-trace-otlp-grpc");
|
|
44
|
+
var import_exporter_logs_otlp_http = require("@opentelemetry/exporter-logs-otlp-http");
|
|
45
|
+
var import_exporter_logs_otlp_grpc = require("@opentelemetry/exporter-logs-otlp-grpc");
|
|
43
46
|
var import_instrumentation = require("@prisma/instrumentation");
|
|
44
47
|
var import_resources = require("@opentelemetry/resources");
|
|
45
48
|
var import_semantic_conventions = require("@opentelemetry/semantic-conventions");
|
|
46
49
|
var import_opentelemetry = require("@sentry/opentelemetry");
|
|
50
|
+
var import_sdk_metrics = require("@opentelemetry/sdk-metrics");
|
|
51
|
+
var import_exporter_metrics_otlp_http = require("@opentelemetry/exporter-metrics-otlp-http");
|
|
52
|
+
var import_exporter_metrics_otlp_grpc = require("@opentelemetry/exporter-metrics-otlp-grpc");
|
|
47
53
|
var import_auto_instrumentations_node = require("@opentelemetry/auto-instrumentations-node");
|
|
48
54
|
var import_resources2 = require("@opentelemetry/resources");
|
|
55
|
+
var import_resource_detector_aws = require("@opentelemetry/resource-detector-aws");
|
|
49
56
|
var Sentry = __toESM(require("@sentry/node"));
|
|
57
|
+
var import_ts_logger = require("@pocket-tools/ts-logger");
|
|
50
58
|
var import_sdk_trace_base = require("@opentelemetry/sdk-trace-base");
|
|
51
59
|
var import_propagator_aws_xray = require("@opentelemetry/propagator-aws-xray");
|
|
52
60
|
var import_id_generator_aws_xray = require("@opentelemetry/id-generator-aws-xray");
|
|
@@ -64,10 +72,8 @@ var tracingDefaults = {
|
|
|
64
72
|
release: "unknown",
|
|
65
73
|
sentry: void 0,
|
|
66
74
|
graphQLDepth: 8,
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
host: "localhost",
|
|
70
|
-
logger: new import_api.DiagConsoleLogger(),
|
|
75
|
+
url: "http://localhost:4318",
|
|
76
|
+
protocol: "HTTP",
|
|
71
77
|
additionalInstrumentations: []
|
|
72
78
|
};
|
|
73
79
|
function awaitAttributes(detector) {
|
|
@@ -83,23 +89,38 @@ function awaitAttributes(detector) {
|
|
|
83
89
|
}
|
|
84
90
|
};
|
|
85
91
|
}
|
|
92
|
+
var batchConfig = {
|
|
93
|
+
maxQueueSize: 4096,
|
|
94
|
+
maxExportBatchSize: 1e3,
|
|
95
|
+
scheduledDelayMillis: 1e3,
|
|
96
|
+
exportTimeoutMillis: 5e3
|
|
97
|
+
};
|
|
86
98
|
async function nodeSDKBuilder(config) {
|
|
87
99
|
var _a, _b;
|
|
88
100
|
config = { ...tracingDefaults, ...config };
|
|
89
|
-
import_api.diag.setLogger((_a = config.logger) != null ? _a : new import_api.DiagConsoleLogger(), import_api.DiagLogLevel.WARN);
|
|
90
101
|
const _resource = import_resources.Resource.default().merge(
|
|
91
102
|
new import_resources.Resource({
|
|
92
103
|
[import_semantic_conventions.ATTR_SERVICE_NAME]: config.serviceName,
|
|
93
104
|
[import_semantic_conventions.ATTR_SERVICE_VERSION]: config.release
|
|
94
105
|
})
|
|
95
106
|
);
|
|
96
|
-
const _traceExporter = new
|
|
107
|
+
const _traceExporter = config.protocol === "HTTP" ? new import_exporter_trace_otlp_http.OTLPTraceExporter({
|
|
97
108
|
//collector url
|
|
98
|
-
url:
|
|
109
|
+
url: `${config.url}/v1/traces`
|
|
110
|
+
}) : new import_exporter_trace_otlp_grpc.OTLPTraceExporter({ url: config.url });
|
|
111
|
+
const _metricReader = new import_sdk_metrics.PeriodicExportingMetricReader({
|
|
112
|
+
exporter: config.protocol === "HTTP" ? new import_exporter_metrics_otlp_http.OTLPMetricExporter({
|
|
113
|
+
url: `${config.url}/v1/metrics`
|
|
114
|
+
}) : new import_exporter_metrics_otlp_grpc.OTLPMetricExporter({ url: config.url }),
|
|
115
|
+
// once every 60 seconds, GCP supports 1 every 5 seconds for custom metrics https://cloud.google.com/monitoring/quotas#custom_metrics_quotas
|
|
116
|
+
// But lets just do 60 seconds for now as we figure it out
|
|
117
|
+
exportIntervalMillis: 6e4
|
|
99
118
|
});
|
|
119
|
+
const _logExporter = config.protocol === "HTTP" ? new import_exporter_logs_otlp_http.OTLPLogExporter({ url: `${config.url}/v1/logs` }) : new import_exporter_logs_otlp_grpc.OTLPLogExporter({ url: config.url });
|
|
100
120
|
const instrumentations = [
|
|
101
121
|
(0, import_auto_instrumentations_node.getNodeAutoInstrumentations)({
|
|
102
122
|
"@opentelemetry/instrumentation-fs": {
|
|
123
|
+
// Disabling Filesystem instrumentation because it is very noisey and memory intense.
|
|
103
124
|
enabled: false,
|
|
104
125
|
requireParentSpan: true
|
|
105
126
|
},
|
|
@@ -119,7 +140,7 @@ async function nodeSDKBuilder(config) {
|
|
|
119
140
|
}
|
|
120
141
|
})
|
|
121
142
|
];
|
|
122
|
-
((
|
|
143
|
+
((_a = config.additionalInstrumentations) != null ? _a : []).forEach((instrumentation) => {
|
|
123
144
|
instrumentations.push(
|
|
124
145
|
new additionalInstrumentationConstructors[instrumentation]()
|
|
125
146
|
);
|
|
@@ -131,18 +152,22 @@ async function nodeSDKBuilder(config) {
|
|
|
131
152
|
contextManager: new Sentry.SentryContextManager(),
|
|
132
153
|
resource: _resource,
|
|
133
154
|
idGenerator: new import_id_generator_aws_xray.AWSXRayIdGenerator(),
|
|
134
|
-
spanProcessors: [new import_sdk_trace_base.BatchSpanProcessor(_traceExporter)],
|
|
135
|
-
|
|
136
|
-
|
|
155
|
+
spanProcessors: [new import_sdk_trace_base.BatchSpanProcessor(_traceExporter, batchConfig)],
|
|
156
|
+
metricReader: _metricReader,
|
|
157
|
+
logRecordProcessors: [
|
|
158
|
+
new import_sdk_node.logs.BatchLogRecordProcessor(_logExporter, batchConfig)
|
|
159
|
+
],
|
|
137
160
|
// TODO: Remove after issue is fixed
|
|
138
161
|
// https://github.com/open-telemetry/opentelemetry-js/issues/4638
|
|
139
162
|
resourceDetectors: [
|
|
140
163
|
awaitAttributes(import_resources2.envDetectorSync),
|
|
141
164
|
awaitAttributes(import_resources2.hostDetectorSync),
|
|
142
|
-
awaitAttributes(import_resources2.processDetectorSync)
|
|
165
|
+
awaitAttributes(import_resources2.processDetectorSync),
|
|
166
|
+
awaitAttributes(import_resource_detector_aws.awsEcsDetectorSync)
|
|
143
167
|
]
|
|
144
168
|
});
|
|
145
169
|
sdk.start();
|
|
170
|
+
import_api.diag.setLogger((_b = config.logger) != null ? _b : import_ts_logger.serverLogger, import_api.DiagLogLevel.WARN);
|
|
146
171
|
import_api.diag.info("Tracer successfully started");
|
|
147
172
|
Sentry.validateOpenTelemetrySetup();
|
|
148
173
|
import_process.default.on("SIGTERM", () => {
|
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
// src/tracing.ts
|
|
2
2
|
import process from "process";
|
|
3
|
-
import { NodeSDK } from "@opentelemetry/sdk-node";
|
|
4
|
-
import {
|
|
5
|
-
DiagConsoleLogger,
|
|
6
|
-
DiagLogLevel,
|
|
7
|
-
diag
|
|
8
|
-
} from "@opentelemetry/api";
|
|
3
|
+
import { NodeSDK, logs } from "@opentelemetry/sdk-node";
|
|
4
|
+
import { DiagLogLevel, diag } from "@opentelemetry/api";
|
|
9
5
|
import { KnexInstrumentation } from "@opentelemetry/instrumentation-knex";
|
|
10
|
-
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-
|
|
6
|
+
import { OTLPTraceExporter as HTTPOTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
|
|
7
|
+
import { OTLPTraceExporter as GRPCOTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-grpc";
|
|
8
|
+
import { OTLPLogExporter as HTTPOTLPLogExporter } from "@opentelemetry/exporter-logs-otlp-http";
|
|
9
|
+
import { OTLPLogExporter as GRPCOTLPLogExporter } from "@opentelemetry/exporter-logs-otlp-grpc";
|
|
11
10
|
import { PrismaInstrumentation } from "@prisma/instrumentation";
|
|
12
11
|
import { Resource } from "@opentelemetry/resources";
|
|
13
12
|
import {
|
|
@@ -15,13 +14,18 @@ import {
|
|
|
15
14
|
ATTR_SERVICE_VERSION
|
|
16
15
|
} from "@opentelemetry/semantic-conventions";
|
|
17
16
|
import { SentrySampler } from "@sentry/opentelemetry";
|
|
17
|
+
import { PeriodicExportingMetricReader } from "@opentelemetry/sdk-metrics";
|
|
18
|
+
import { OTLPMetricExporter as HTTPOTLPMetricExporter } from "@opentelemetry/exporter-metrics-otlp-http";
|
|
19
|
+
import { OTLPMetricExporter as GRPCOTLPMetricExporter } from "@opentelemetry/exporter-metrics-otlp-grpc";
|
|
18
20
|
import { getNodeAutoInstrumentations } from "@opentelemetry/auto-instrumentations-node";
|
|
19
21
|
import {
|
|
20
22
|
envDetectorSync,
|
|
21
23
|
hostDetectorSync,
|
|
22
24
|
processDetectorSync
|
|
23
25
|
} from "@opentelemetry/resources";
|
|
26
|
+
import { awsEcsDetectorSync } from "@opentelemetry/resource-detector-aws";
|
|
24
27
|
import * as Sentry from "@sentry/node";
|
|
28
|
+
import { serverLogger } from "@pocket-tools/ts-logger";
|
|
25
29
|
import {
|
|
26
30
|
BatchSpanProcessor,
|
|
27
31
|
ParentBasedSampler
|
|
@@ -42,10 +46,8 @@ var tracingDefaults = {
|
|
|
42
46
|
release: "unknown",
|
|
43
47
|
sentry: void 0,
|
|
44
48
|
graphQLDepth: 8,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
host: "localhost",
|
|
48
|
-
logger: new DiagConsoleLogger(),
|
|
49
|
+
url: "http://localhost:4318",
|
|
50
|
+
protocol: "HTTP",
|
|
49
51
|
additionalInstrumentations: []
|
|
50
52
|
};
|
|
51
53
|
function awaitAttributes(detector) {
|
|
@@ -61,23 +63,38 @@ function awaitAttributes(detector) {
|
|
|
61
63
|
}
|
|
62
64
|
};
|
|
63
65
|
}
|
|
66
|
+
var batchConfig = {
|
|
67
|
+
maxQueueSize: 4096,
|
|
68
|
+
maxExportBatchSize: 1e3,
|
|
69
|
+
scheduledDelayMillis: 1e3,
|
|
70
|
+
exportTimeoutMillis: 5e3
|
|
71
|
+
};
|
|
64
72
|
async function nodeSDKBuilder(config) {
|
|
65
73
|
var _a, _b;
|
|
66
74
|
config = { ...tracingDefaults, ...config };
|
|
67
|
-
diag.setLogger((_a = config.logger) != null ? _a : new DiagConsoleLogger(), DiagLogLevel.WARN);
|
|
68
75
|
const _resource = Resource.default().merge(
|
|
69
76
|
new Resource({
|
|
70
77
|
[ATTR_SERVICE_NAME]: config.serviceName,
|
|
71
78
|
[ATTR_SERVICE_VERSION]: config.release
|
|
72
79
|
})
|
|
73
80
|
);
|
|
74
|
-
const _traceExporter = new
|
|
81
|
+
const _traceExporter = config.protocol === "HTTP" ? new HTTPOTLPTraceExporter({
|
|
75
82
|
//collector url
|
|
76
|
-
url:
|
|
83
|
+
url: `${config.url}/v1/traces`
|
|
84
|
+
}) : new GRPCOTLPTraceExporter({ url: config.url });
|
|
85
|
+
const _metricReader = new PeriodicExportingMetricReader({
|
|
86
|
+
exporter: config.protocol === "HTTP" ? new HTTPOTLPMetricExporter({
|
|
87
|
+
url: `${config.url}/v1/metrics`
|
|
88
|
+
}) : new GRPCOTLPMetricExporter({ url: config.url }),
|
|
89
|
+
// once every 60 seconds, GCP supports 1 every 5 seconds for custom metrics https://cloud.google.com/monitoring/quotas#custom_metrics_quotas
|
|
90
|
+
// But lets just do 60 seconds for now as we figure it out
|
|
91
|
+
exportIntervalMillis: 6e4
|
|
77
92
|
});
|
|
93
|
+
const _logExporter = config.protocol === "HTTP" ? new HTTPOTLPLogExporter({ url: `${config.url}/v1/logs` }) : new GRPCOTLPLogExporter({ url: config.url });
|
|
78
94
|
const instrumentations = [
|
|
79
95
|
getNodeAutoInstrumentations({
|
|
80
96
|
"@opentelemetry/instrumentation-fs": {
|
|
97
|
+
// Disabling Filesystem instrumentation because it is very noisey and memory intense.
|
|
81
98
|
enabled: false,
|
|
82
99
|
requireParentSpan: true
|
|
83
100
|
},
|
|
@@ -97,7 +114,7 @@ async function nodeSDKBuilder(config) {
|
|
|
97
114
|
}
|
|
98
115
|
})
|
|
99
116
|
];
|
|
100
|
-
((
|
|
117
|
+
((_a = config.additionalInstrumentations) != null ? _a : []).forEach((instrumentation) => {
|
|
101
118
|
instrumentations.push(
|
|
102
119
|
new additionalInstrumentationConstructors[instrumentation]()
|
|
103
120
|
);
|
|
@@ -109,18 +126,22 @@ async function nodeSDKBuilder(config) {
|
|
|
109
126
|
contextManager: new Sentry.SentryContextManager(),
|
|
110
127
|
resource: _resource,
|
|
111
128
|
idGenerator: new AWSXRayIdGenerator(),
|
|
112
|
-
spanProcessors: [new BatchSpanProcessor(_traceExporter)],
|
|
113
|
-
|
|
114
|
-
|
|
129
|
+
spanProcessors: [new BatchSpanProcessor(_traceExporter, batchConfig)],
|
|
130
|
+
metricReader: _metricReader,
|
|
131
|
+
logRecordProcessors: [
|
|
132
|
+
new logs.BatchLogRecordProcessor(_logExporter, batchConfig)
|
|
133
|
+
],
|
|
115
134
|
// TODO: Remove after issue is fixed
|
|
116
135
|
// https://github.com/open-telemetry/opentelemetry-js/issues/4638
|
|
117
136
|
resourceDetectors: [
|
|
118
137
|
awaitAttributes(envDetectorSync),
|
|
119
138
|
awaitAttributes(hostDetectorSync),
|
|
120
|
-
awaitAttributes(processDetectorSync)
|
|
139
|
+
awaitAttributes(processDetectorSync),
|
|
140
|
+
awaitAttributes(awsEcsDetectorSync)
|
|
121
141
|
]
|
|
122
142
|
});
|
|
123
143
|
sdk.start();
|
|
144
|
+
diag.setLogger((_b = config.logger) != null ? _b : serverLogger, DiagLogLevel.WARN);
|
|
124
145
|
diag.info("Tracer successfully started");
|
|
125
146
|
Sentry.validateOpenTelemetrySetup();
|
|
126
147
|
process.on("SIGTERM", () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pocket-tools/tracing",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "Utilities for tracing",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"tracing"
|
|
@@ -69,12 +69,16 @@
|
|
|
69
69
|
"@opentelemetry/auto-instrumentations-node": "0.50.0",
|
|
70
70
|
"@opentelemetry/context-async-hooks": "1.26.0",
|
|
71
71
|
"@opentelemetry/core": "1.26.0",
|
|
72
|
+
"@opentelemetry/exporter-logs-otlp-grpc": "0.53.0",
|
|
73
|
+
"@opentelemetry/exporter-logs-otlp-http": "0.53.0",
|
|
72
74
|
"@opentelemetry/exporter-metrics-otlp-grpc": "0.53.0",
|
|
75
|
+
"@opentelemetry/exporter-metrics-otlp-http": "0.53.0",
|
|
73
76
|
"@opentelemetry/exporter-trace-otlp-grpc": "0.53.0",
|
|
74
77
|
"@opentelemetry/exporter-trace-otlp-http": "0.53.0",
|
|
75
78
|
"@opentelemetry/id-generator-aws-xray": "1.2.2",
|
|
76
79
|
"@opentelemetry/instrumentation-knex": "0.40.0",
|
|
77
80
|
"@opentelemetry/propagator-aws-xray": "1.26.0",
|
|
81
|
+
"@opentelemetry/resource-detector-aws": "1.6.1",
|
|
78
82
|
"@opentelemetry/resources": "1.26.0",
|
|
79
83
|
"@opentelemetry/sdk-metrics": "1.26.0",
|
|
80
84
|
"@opentelemetry/sdk-node": "0.53.0",
|
|
@@ -82,6 +86,7 @@
|
|
|
82
86
|
"@opentelemetry/sdk-trace-node": "1.26.0",
|
|
83
87
|
"@opentelemetry/semantic-conventions": "1.27.0",
|
|
84
88
|
"@opentelemetry/winston-transport": "0.6.0",
|
|
89
|
+
"@pocket-tools/ts-logger": "workspace:*",
|
|
85
90
|
"@prisma/instrumentation": "5.19.1",
|
|
86
91
|
"@sentry/node": "8.33.0",
|
|
87
92
|
"@sentry/opentelemetry": "8.33.0",
|