@pocket-tools/tracing 1.6.1 → 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 +20 -0
- package/.turbo/turbo-semantic-release.log +69 -66
- package/README.md +1 -1
- package/dist/index.d.mts +6 -22
- package/dist/index.d.ts +6 -22
- package/dist/index.js +77 -150
- package/dist/index.mjs +86 -168
- package/package.json +9 -9
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
|
|
2
|
+
> @pocket-tools/tracing@0.0.0-development build /home/runner/work/pocket-monorepo/pocket-monorepo/packages/tracing
|
|
3
|
+
> tsup src/index.ts --format cjs,esm --dts
|
|
4
|
+
|
|
5
|
+
[34mCLI[39m Building entry: src/index.ts
|
|
6
|
+
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
|
+
[34mCLI[39m tsup v8.2.4
|
|
8
|
+
[34mCLI[39m Target: es2019
|
|
9
|
+
[34mCJS[39m Build start
|
|
10
|
+
[34mESM[39m Build start
|
|
11
|
+
[33mCJS[39m [33mYou have emitDecoratorMetadata enabled but @swc/core was not installed, skipping swc plugin[39m
|
|
12
|
+
[33mESM[39m [33mYou have emitDecoratorMetadata enabled but @swc/core was not installed, skipping swc plugin[39m
|
|
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
|
+
[34mDTS[39m Build start
|
|
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,76 +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
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
-
[
|
|
54
|
+
* Revert "Revert "feat(otel): adding in basic tracing via otel (#798)" (#799)"
|
|
55
|
+
|
|
56
|
+
This reverts commit 57c2a13f78151326975cb174709a549970a06ed3.
|
|
57
|
+
|
|
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/README.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { SentrySpanProcessor, SentrySampler } from '@sentry/opentelemetry';
|
|
1
|
+
import { DiagLogger } from '@opentelemetry/api';
|
|
2
|
+
import { NodeClient } from '@sentry/node';
|
|
4
3
|
|
|
5
4
|
declare enum AdditionalInstrumentation {
|
|
6
5
|
KNEX = "KNEX",
|
|
@@ -11,27 +10,12 @@ type TracingConfig = {
|
|
|
11
10
|
release: string;
|
|
12
11
|
samplingRatio?: number;
|
|
13
12
|
graphQLDepth?: number;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
host?: string;
|
|
13
|
+
url?: string;
|
|
14
|
+
protocol?: 'GRPC' | 'HTTP';
|
|
17
15
|
logger?: DiagLogger;
|
|
18
|
-
|
|
16
|
+
sentry: NodeClient | undefined;
|
|
19
17
|
additionalInstrumentations?: AdditionalInstrumentation[];
|
|
20
18
|
};
|
|
21
19
|
declare function nodeSDKBuilder(config: TracingConfig): Promise<void>;
|
|
22
|
-
declare class CustomAWSXraySpanProcessor extends BatchSpanProcessor {
|
|
23
|
-
sampler: ParentBasedSampler;
|
|
24
|
-
contextMap: Map<string, Context>;
|
|
25
|
-
constructor(_exporter: SpanExporter, ratio: number, config: BufferConfig);
|
|
26
|
-
onStart(span: Span, parentContext: Context): void;
|
|
27
|
-
onEnd(span: ReadableSpan): void;
|
|
28
|
-
}
|
|
29
|
-
declare class CustomSentrySpanProcessor extends SentrySpanProcessor {
|
|
30
|
-
sampler: SentrySampler;
|
|
31
|
-
contextMap: Map<string, Context>;
|
|
32
|
-
constructor();
|
|
33
|
-
onStart(span: Span, parentContext: Context): void;
|
|
34
|
-
onEnd(span: Span & ReadableSpan): void;
|
|
35
|
-
}
|
|
36
20
|
|
|
37
|
-
export { AdditionalInstrumentation,
|
|
21
|
+
export { AdditionalInstrumentation, type TracingConfig, nodeSDKBuilder };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { SentrySpanProcessor, SentrySampler } from '@sentry/opentelemetry';
|
|
1
|
+
import { DiagLogger } from '@opentelemetry/api';
|
|
2
|
+
import { NodeClient } from '@sentry/node';
|
|
4
3
|
|
|
5
4
|
declare enum AdditionalInstrumentation {
|
|
6
5
|
KNEX = "KNEX",
|
|
@@ -11,27 +10,12 @@ type TracingConfig = {
|
|
|
11
10
|
release: string;
|
|
12
11
|
samplingRatio?: number;
|
|
13
12
|
graphQLDepth?: number;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
host?: string;
|
|
13
|
+
url?: string;
|
|
14
|
+
protocol?: 'GRPC' | 'HTTP';
|
|
17
15
|
logger?: DiagLogger;
|
|
18
|
-
|
|
16
|
+
sentry: NodeClient | undefined;
|
|
19
17
|
additionalInstrumentations?: AdditionalInstrumentation[];
|
|
20
18
|
};
|
|
21
19
|
declare function nodeSDKBuilder(config: TracingConfig): Promise<void>;
|
|
22
|
-
declare class CustomAWSXraySpanProcessor extends BatchSpanProcessor {
|
|
23
|
-
sampler: ParentBasedSampler;
|
|
24
|
-
contextMap: Map<string, Context>;
|
|
25
|
-
constructor(_exporter: SpanExporter, ratio: number, config: BufferConfig);
|
|
26
|
-
onStart(span: Span, parentContext: Context): void;
|
|
27
|
-
onEnd(span: ReadableSpan): void;
|
|
28
|
-
}
|
|
29
|
-
declare class CustomSentrySpanProcessor extends SentrySpanProcessor {
|
|
30
|
-
sampler: SentrySampler;
|
|
31
|
-
contextMap: Map<string, Context>;
|
|
32
|
-
constructor();
|
|
33
|
-
onStart(span: Span, parentContext: Context): void;
|
|
34
|
-
onEnd(span: Span & ReadableSpan): void;
|
|
35
|
-
}
|
|
36
20
|
|
|
37
|
-
export { AdditionalInstrumentation,
|
|
21
|
+
export { AdditionalInstrumentation, type TracingConfig, nodeSDKBuilder };
|
package/dist/index.js
CHANGED
|
@@ -30,8 +30,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
var src_exports = {};
|
|
31
31
|
__export(src_exports, {
|
|
32
32
|
AdditionalInstrumentation: () => AdditionalInstrumentation,
|
|
33
|
-
CustomAWSXraySpanProcessor: () => CustomAWSXraySpanProcessor,
|
|
34
|
-
CustomSentrySpanProcessor: () => CustomSentrySpanProcessor,
|
|
35
33
|
nodeSDKBuilder: () => nodeSDKBuilder
|
|
36
34
|
});
|
|
37
35
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -39,28 +37,27 @@ module.exports = __toCommonJS(src_exports);
|
|
|
39
37
|
// src/tracing.ts
|
|
40
38
|
var import_process = __toESM(require("process"));
|
|
41
39
|
var import_sdk_node = require("@opentelemetry/sdk-node");
|
|
42
|
-
var import_core = require("@opentelemetry/core");
|
|
43
|
-
var import_instrumentation_graphql = require("@opentelemetry/instrumentation-graphql");
|
|
44
|
-
var import_instrumentation_aws_sdk = require("@opentelemetry/instrumentation-aws-sdk");
|
|
45
|
-
var import_id_generator_aws_xray = require("@opentelemetry/id-generator-aws-xray");
|
|
46
|
-
var import_propagator_aws_xray = require("@opentelemetry/propagator-aws-xray");
|
|
47
|
-
var import_sdk_trace_base = require("@opentelemetry/sdk-trace-base");
|
|
48
|
-
var import_instrumentation_dataloader = require("@opentelemetry/instrumentation-dataloader");
|
|
49
40
|
var import_api = require("@opentelemetry/api");
|
|
50
|
-
var import_instrumentation_express = require("@opentelemetry/instrumentation-express");
|
|
51
|
-
var import_instrumentation_http = require("@opentelemetry/instrumentation-http");
|
|
52
41
|
var import_instrumentation_knex = require("@opentelemetry/instrumentation-knex");
|
|
53
|
-
var
|
|
54
|
-
var import_instrumentation_net = require("@opentelemetry/instrumentation-net");
|
|
42
|
+
var import_exporter_trace_otlp_http = require("@opentelemetry/exporter-trace-otlp-http");
|
|
55
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");
|
|
56
46
|
var import_instrumentation = require("@prisma/instrumentation");
|
|
57
47
|
var import_resources = require("@opentelemetry/resources");
|
|
58
48
|
var import_semantic_conventions = require("@opentelemetry/semantic-conventions");
|
|
59
|
-
var import_ExpressLayerType = require("@opentelemetry/instrumentation-express/build/src/enums/ExpressLayerType");
|
|
60
49
|
var import_opentelemetry = require("@sentry/opentelemetry");
|
|
61
|
-
var
|
|
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");
|
|
53
|
+
var import_auto_instrumentations_node = require("@opentelemetry/auto-instrumentations-node");
|
|
62
54
|
var import_resources2 = require("@opentelemetry/resources");
|
|
55
|
+
var import_resource_detector_aws = require("@opentelemetry/resource-detector-aws");
|
|
63
56
|
var Sentry = __toESM(require("@sentry/node"));
|
|
57
|
+
var import_ts_logger = require("@pocket-tools/ts-logger");
|
|
58
|
+
var import_sdk_trace_base = require("@opentelemetry/sdk-trace-base");
|
|
59
|
+
var import_propagator_aws_xray = require("@opentelemetry/propagator-aws-xray");
|
|
60
|
+
var import_id_generator_aws_xray = require("@opentelemetry/id-generator-aws-xray");
|
|
64
61
|
var AdditionalInstrumentation = /* @__PURE__ */ ((AdditionalInstrumentation2) => {
|
|
65
62
|
AdditionalInstrumentation2["KNEX"] = "KNEX";
|
|
66
63
|
AdditionalInstrumentation2["PRISMA"] = "PRISMA";
|
|
@@ -70,9 +67,15 @@ var additionalInstrumentationConstructors = {
|
|
|
70
67
|
KNEX: import_instrumentation_knex.KnexInstrumentation,
|
|
71
68
|
PRISMA: import_instrumentation.PrismaInstrumentation
|
|
72
69
|
};
|
|
73
|
-
var
|
|
74
|
-
|
|
75
|
-
|
|
70
|
+
var tracingDefaults = {
|
|
71
|
+
serviceName: "unknown",
|
|
72
|
+
release: "unknown",
|
|
73
|
+
sentry: void 0,
|
|
74
|
+
graphQLDepth: 8,
|
|
75
|
+
url: "http://localhost:4318",
|
|
76
|
+
protocol: "HTTP",
|
|
77
|
+
additionalInstrumentations: []
|
|
78
|
+
};
|
|
76
79
|
function awaitAttributes(detector) {
|
|
77
80
|
return {
|
|
78
81
|
/**
|
|
@@ -86,171 +89,95 @@ function awaitAttributes(detector) {
|
|
|
86
89
|
}
|
|
87
90
|
};
|
|
88
91
|
}
|
|
92
|
+
var batchConfig = {
|
|
93
|
+
maxQueueSize: 4096,
|
|
94
|
+
maxExportBatchSize: 1e3,
|
|
95
|
+
scheduledDelayMillis: 1e3,
|
|
96
|
+
exportTimeoutMillis: 5e3
|
|
97
|
+
};
|
|
89
98
|
async function nodeSDKBuilder(config) {
|
|
90
|
-
var _a, _b
|
|
91
|
-
|
|
99
|
+
var _a, _b;
|
|
100
|
+
config = { ...tracingDefaults, ...config };
|
|
92
101
|
const _resource = import_resources.Resource.default().merge(
|
|
93
102
|
new import_resources.Resource({
|
|
94
|
-
[import_semantic_conventions.
|
|
95
|
-
[import_semantic_conventions.
|
|
103
|
+
[import_semantic_conventions.ATTR_SERVICE_NAME]: config.serviceName,
|
|
104
|
+
[import_semantic_conventions.ATTR_SERVICE_VERSION]: config.release
|
|
96
105
|
})
|
|
97
106
|
);
|
|
98
|
-
const _traceExporter = new
|
|
107
|
+
const _traceExporter = config.protocol === "HTTP" ? new import_exporter_trace_otlp_http.OTLPTraceExporter({
|
|
99
108
|
//collector url
|
|
100
|
-
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
|
|
101
118
|
});
|
|
102
|
-
const
|
|
103
|
-
new CustomAWSXraySpanProcessor(
|
|
104
|
-
_traceExporter,
|
|
105
|
-
(_b = config.samplingRatio) != null ? _b : 0.01,
|
|
106
|
-
{
|
|
107
|
-
// only force 100ms between 2 batch exports.
|
|
108
|
-
// Default is 5000ms which is 5 seconds and causes us to lose spans
|
|
109
|
-
scheduledDelayMillis: 100
|
|
110
|
-
}
|
|
111
|
-
)
|
|
112
|
-
];
|
|
113
|
-
if (config.addSentry) {
|
|
114
|
-
_spanProcessors.push(new CustomSentrySpanProcessor());
|
|
115
|
-
}
|
|
116
|
-
const _idGenerator = new import_id_generator_aws_xray.AWSXRayIdGenerator();
|
|
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 });
|
|
117
120
|
const instrumentations = [
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
121
|
+
(0, import_auto_instrumentations_node.getNodeAutoInstrumentations)({
|
|
122
|
+
"@opentelemetry/instrumentation-fs": {
|
|
123
|
+
// Disabling Filesystem instrumentation because it is very noisey and memory intense.
|
|
124
|
+
enabled: false,
|
|
125
|
+
requireParentSpan: true
|
|
126
|
+
},
|
|
127
|
+
"@opentelemetry/instrumentation-undici": {
|
|
128
|
+
headersToSpanAttributes: {
|
|
129
|
+
requestHeaders: [
|
|
130
|
+
"sentry-trace",
|
|
131
|
+
"baggage",
|
|
132
|
+
"x-amzn-trace-id",
|
|
133
|
+
"encodedid",
|
|
134
|
+
"applicationname"
|
|
135
|
+
]
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
"@opentelemetry/instrumentation-http": {
|
|
139
|
+
ignoreIncomingPaths: ["/.well-known/apollo/server-health"]
|
|
140
|
+
}
|
|
141
|
+
})
|
|
136
142
|
];
|
|
137
|
-
((
|
|
143
|
+
((_a = config.additionalInstrumentations) != null ? _a : []).forEach((instrumentation) => {
|
|
138
144
|
instrumentations.push(
|
|
139
145
|
new additionalInstrumentationConstructors[instrumentation]()
|
|
140
146
|
);
|
|
141
147
|
});
|
|
142
148
|
const sdk = new import_sdk_node.NodeSDK({
|
|
143
|
-
textMapPropagator:
|
|
144
|
-
propagators: [new import_propagator_aws_xray.AWSXRayPropagator(), new import_opentelemetry.SentryPropagator()]
|
|
145
|
-
}) : new import_propagator_aws_xray.AWSXRayPropagator(),
|
|
149
|
+
textMapPropagator: new import_propagator_aws_xray.AWSXRayPropagator(),
|
|
146
150
|
instrumentations,
|
|
147
|
-
|
|
151
|
+
sampler: config.sentry ? new import_sdk_trace_base.ParentBasedSampler({ root: new import_opentelemetry.SentrySampler(config.sentry) }) : void 0,
|
|
152
|
+
contextManager: new Sentry.SentryContextManager(),
|
|
148
153
|
resource: _resource,
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
154
|
+
idGenerator: new import_id_generator_aws_xray.AWSXRayIdGenerator(),
|
|
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
|
+
],
|
|
152
160
|
// TODO: Remove after issue is fixed
|
|
153
161
|
// https://github.com/open-telemetry/opentelemetry-js/issues/4638
|
|
154
162
|
resourceDetectors: [
|
|
155
163
|
awaitAttributes(import_resources2.envDetectorSync),
|
|
156
164
|
awaitAttributes(import_resources2.hostDetectorSync),
|
|
157
|
-
awaitAttributes(import_resources2.processDetectorSync)
|
|
165
|
+
awaitAttributes(import_resources2.processDetectorSync),
|
|
166
|
+
awaitAttributes(import_resource_detector_aws.awsEcsDetectorSync)
|
|
158
167
|
]
|
|
159
168
|
});
|
|
160
169
|
sdk.start();
|
|
170
|
+
import_api.diag.setLogger((_b = config.logger) != null ? _b : import_ts_logger.serverLogger, import_api.DiagLogLevel.WARN);
|
|
161
171
|
import_api.diag.info("Tracer successfully started");
|
|
172
|
+
Sentry.validateOpenTelemetrySetup();
|
|
162
173
|
import_process.default.on("SIGTERM", () => {
|
|
163
174
|
sdk.shutdown().then(() => import_api.diag.info("Tracing and Metrics terminated")).catch(
|
|
164
175
|
(error) => import_api.diag.error("Error terminating tracing and metrics", error)
|
|
165
176
|
).finally(() => import_process.default.exit(0));
|
|
166
177
|
});
|
|
167
178
|
}
|
|
168
|
-
var CustomAWSXraySpanProcessor = class extends import_sdk_trace_base.BatchSpanProcessor {
|
|
169
|
-
constructor(_exporter, ratio, config) {
|
|
170
|
-
super(_exporter, config);
|
|
171
|
-
this.contextMap = /* @__PURE__ */ new Map();
|
|
172
|
-
this.sampler = new import_sdk_trace_base.ParentBasedSampler({
|
|
173
|
-
root: new import_sdk_trace_base.TraceIdRatioBasedSampler(ratio)
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
onStart(span, parentContext) {
|
|
177
|
-
this.contextMap.set(span.spanContext().traceId, parentContext);
|
|
178
|
-
const sampleResult = this.sampler.shouldSample(
|
|
179
|
-
parentContext,
|
|
180
|
-
span.spanContext().traceId,
|
|
181
|
-
span.name,
|
|
182
|
-
span.kind,
|
|
183
|
-
span.attributes,
|
|
184
|
-
span.links
|
|
185
|
-
);
|
|
186
|
-
if (sampleResult.decision === import_sdk_trace_base.SamplingDecision.RECORD_AND_SAMPLED) {
|
|
187
|
-
super.onStart(span, parentContext);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
onEnd(span) {
|
|
191
|
-
const context = this.contextMap.get(span.spanContext().traceId);
|
|
192
|
-
if (context) {
|
|
193
|
-
const sampleResult = this.sampler.shouldSample(
|
|
194
|
-
context,
|
|
195
|
-
span.spanContext().traceId,
|
|
196
|
-
span.name,
|
|
197
|
-
span.kind,
|
|
198
|
-
span.attributes,
|
|
199
|
-
span.links
|
|
200
|
-
);
|
|
201
|
-
this.contextMap.delete(span.spanContext().traceId);
|
|
202
|
-
if (sampleResult.decision === import_sdk_trace_base.SamplingDecision.RECORD_AND_SAMPLED) {
|
|
203
|
-
super.onEnd(span);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
};
|
|
208
|
-
var CustomSentrySpanProcessor = class extends import_opentelemetry.SentrySpanProcessor {
|
|
209
|
-
constructor() {
|
|
210
|
-
super();
|
|
211
|
-
this.contextMap = /* @__PURE__ */ new Map();
|
|
212
|
-
const sentryClient = Sentry.getClient();
|
|
213
|
-
if (!sentryClient) {
|
|
214
|
-
throw new Error("Sentry client is not initialized");
|
|
215
|
-
}
|
|
216
|
-
this.sampler = new import_opentelemetry.SentrySampler(sentryClient);
|
|
217
|
-
}
|
|
218
|
-
onStart(span, parentContext) {
|
|
219
|
-
this.contextMap.set(span.spanContext().traceId, parentContext);
|
|
220
|
-
const sampleResult = this.sampler.shouldSample(
|
|
221
|
-
parentContext,
|
|
222
|
-
span.spanContext().traceId,
|
|
223
|
-
span.name,
|
|
224
|
-
span.kind,
|
|
225
|
-
span.attributes,
|
|
226
|
-
span.links
|
|
227
|
-
);
|
|
228
|
-
if (sampleResult.decision === import_sdk_trace_base.SamplingDecision.RECORD_AND_SAMPLED) {
|
|
229
|
-
super.onStart(span, parentContext);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
onEnd(span) {
|
|
233
|
-
const context = this.contextMap.get(span.spanContext().traceId);
|
|
234
|
-
if (context) {
|
|
235
|
-
const sampleResult = this.sampler.shouldSample(
|
|
236
|
-
context,
|
|
237
|
-
span.spanContext().traceId,
|
|
238
|
-
span.name,
|
|
239
|
-
span.kind,
|
|
240
|
-
span.attributes,
|
|
241
|
-
span.links
|
|
242
|
-
);
|
|
243
|
-
this.contextMap.delete(span.spanContext().traceId);
|
|
244
|
-
if (sampleResult.decision === import_sdk_trace_base.SamplingDecision.RECORD_AND_SAMPLED) {
|
|
245
|
-
super.onEnd(span);
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
};
|
|
250
179
|
// Annotate the CommonJS export names for ESM import in node:
|
|
251
180
|
0 && (module.exports = {
|
|
252
181
|
AdditionalInstrumentation,
|
|
253
|
-
CustomAWSXraySpanProcessor,
|
|
254
|
-
CustomSentrySpanProcessor,
|
|
255
182
|
nodeSDKBuilder
|
|
256
183
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -1,49 +1,37 @@
|
|
|
1
1
|
// src/tracing.ts
|
|
2
2
|
import process from "process";
|
|
3
|
-
import { NodeSDK } from "@opentelemetry/sdk-node";
|
|
4
|
-
import {
|
|
5
|
-
import { GraphQLInstrumentation } from "@opentelemetry/instrumentation-graphql";
|
|
6
|
-
import { AwsInstrumentation } from "@opentelemetry/instrumentation-aws-sdk";
|
|
7
|
-
import { AWSXRayIdGenerator } from "@opentelemetry/id-generator-aws-xray";
|
|
8
|
-
import { AWSXRayPropagator } from "@opentelemetry/propagator-aws-xray";
|
|
9
|
-
import {
|
|
10
|
-
BatchSpanProcessor,
|
|
11
|
-
SamplingDecision,
|
|
12
|
-
TraceIdRatioBasedSampler,
|
|
13
|
-
ParentBasedSampler
|
|
14
|
-
} from "@opentelemetry/sdk-trace-base";
|
|
15
|
-
import { DataloaderInstrumentation } from "@opentelemetry/instrumentation-dataloader";
|
|
16
|
-
import {
|
|
17
|
-
DiagConsoleLogger,
|
|
18
|
-
DiagLogLevel,
|
|
19
|
-
diag
|
|
20
|
-
} from "@opentelemetry/api";
|
|
21
|
-
import { ExpressInstrumentation } from "@opentelemetry/instrumentation-express";
|
|
22
|
-
import { HttpInstrumentation } from "@opentelemetry/instrumentation-http";
|
|
3
|
+
import { NodeSDK, logs } from "@opentelemetry/sdk-node";
|
|
4
|
+
import { DiagLogLevel, diag } from "@opentelemetry/api";
|
|
23
5
|
import { KnexInstrumentation } from "@opentelemetry/instrumentation-knex";
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
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";
|
|
27
10
|
import { PrismaInstrumentation } from "@prisma/instrumentation";
|
|
28
11
|
import { Resource } from "@opentelemetry/resources";
|
|
29
12
|
import {
|
|
30
|
-
|
|
31
|
-
|
|
13
|
+
ATTR_SERVICE_NAME,
|
|
14
|
+
ATTR_SERVICE_VERSION
|
|
32
15
|
} from "@opentelemetry/semantic-conventions";
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
wrapContextManagerClass
|
|
39
|
-
} from "@sentry/opentelemetry";
|
|
40
|
-
import { AsyncLocalStorageContextManager } from "@opentelemetry/context-async-hooks";
|
|
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";
|
|
20
|
+
import { getNodeAutoInstrumentations } from "@opentelemetry/auto-instrumentations-node";
|
|
41
21
|
import {
|
|
42
22
|
envDetectorSync,
|
|
43
23
|
hostDetectorSync,
|
|
44
24
|
processDetectorSync
|
|
45
25
|
} from "@opentelemetry/resources";
|
|
26
|
+
import { awsEcsDetectorSync } from "@opentelemetry/resource-detector-aws";
|
|
46
27
|
import * as Sentry from "@sentry/node";
|
|
28
|
+
import { serverLogger } from "@pocket-tools/ts-logger";
|
|
29
|
+
import {
|
|
30
|
+
BatchSpanProcessor,
|
|
31
|
+
ParentBasedSampler
|
|
32
|
+
} from "@opentelemetry/sdk-trace-base";
|
|
33
|
+
import { AWSXRayPropagator } from "@opentelemetry/propagator-aws-xray";
|
|
34
|
+
import { AWSXRayIdGenerator } from "@opentelemetry/id-generator-aws-xray";
|
|
47
35
|
var AdditionalInstrumentation = /* @__PURE__ */ ((AdditionalInstrumentation2) => {
|
|
48
36
|
AdditionalInstrumentation2["KNEX"] = "KNEX";
|
|
49
37
|
AdditionalInstrumentation2["PRISMA"] = "PRISMA";
|
|
@@ -53,9 +41,15 @@ var additionalInstrumentationConstructors = {
|
|
|
53
41
|
KNEX: KnexInstrumentation,
|
|
54
42
|
PRISMA: PrismaInstrumentation
|
|
55
43
|
};
|
|
56
|
-
var
|
|
57
|
-
|
|
58
|
-
|
|
44
|
+
var tracingDefaults = {
|
|
45
|
+
serviceName: "unknown",
|
|
46
|
+
release: "unknown",
|
|
47
|
+
sentry: void 0,
|
|
48
|
+
graphQLDepth: 8,
|
|
49
|
+
url: "http://localhost:4318",
|
|
50
|
+
protocol: "HTTP",
|
|
51
|
+
additionalInstrumentations: []
|
|
52
|
+
};
|
|
59
53
|
function awaitAttributes(detector) {
|
|
60
54
|
return {
|
|
61
55
|
/**
|
|
@@ -69,170 +63,94 @@ function awaitAttributes(detector) {
|
|
|
69
63
|
}
|
|
70
64
|
};
|
|
71
65
|
}
|
|
66
|
+
var batchConfig = {
|
|
67
|
+
maxQueueSize: 4096,
|
|
68
|
+
maxExportBatchSize: 1e3,
|
|
69
|
+
scheduledDelayMillis: 1e3,
|
|
70
|
+
exportTimeoutMillis: 5e3
|
|
71
|
+
};
|
|
72
72
|
async function nodeSDKBuilder(config) {
|
|
73
|
-
var _a, _b
|
|
74
|
-
|
|
73
|
+
var _a, _b;
|
|
74
|
+
config = { ...tracingDefaults, ...config };
|
|
75
75
|
const _resource = Resource.default().merge(
|
|
76
76
|
new Resource({
|
|
77
|
-
[
|
|
78
|
-
[
|
|
77
|
+
[ATTR_SERVICE_NAME]: config.serviceName,
|
|
78
|
+
[ATTR_SERVICE_VERSION]: config.release
|
|
79
79
|
})
|
|
80
80
|
);
|
|
81
|
-
const _traceExporter = new
|
|
81
|
+
const _traceExporter = config.protocol === "HTTP" ? new HTTPOTLPTraceExporter({
|
|
82
82
|
//collector url
|
|
83
|
-
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
|
|
84
92
|
});
|
|
85
|
-
const
|
|
86
|
-
new CustomAWSXraySpanProcessor(
|
|
87
|
-
_traceExporter,
|
|
88
|
-
(_b = config.samplingRatio) != null ? _b : 0.01,
|
|
89
|
-
{
|
|
90
|
-
// only force 100ms between 2 batch exports.
|
|
91
|
-
// Default is 5000ms which is 5 seconds and causes us to lose spans
|
|
92
|
-
scheduledDelayMillis: 100
|
|
93
|
-
}
|
|
94
|
-
)
|
|
95
|
-
];
|
|
96
|
-
if (config.addSentry) {
|
|
97
|
-
_spanProcessors.push(new CustomSentrySpanProcessor());
|
|
98
|
-
}
|
|
99
|
-
const _idGenerator = new AWSXRayIdGenerator();
|
|
93
|
+
const _logExporter = config.protocol === "HTTP" ? new HTTPOTLPLogExporter({ url: `${config.url}/v1/logs` }) : new GRPCOTLPLogExporter({ url: config.url });
|
|
100
94
|
const instrumentations = [
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
95
|
+
getNodeAutoInstrumentations({
|
|
96
|
+
"@opentelemetry/instrumentation-fs": {
|
|
97
|
+
// Disabling Filesystem instrumentation because it is very noisey and memory intense.
|
|
98
|
+
enabled: false,
|
|
99
|
+
requireParentSpan: true
|
|
100
|
+
},
|
|
101
|
+
"@opentelemetry/instrumentation-undici": {
|
|
102
|
+
headersToSpanAttributes: {
|
|
103
|
+
requestHeaders: [
|
|
104
|
+
"sentry-trace",
|
|
105
|
+
"baggage",
|
|
106
|
+
"x-amzn-trace-id",
|
|
107
|
+
"encodedid",
|
|
108
|
+
"applicationname"
|
|
109
|
+
]
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
"@opentelemetry/instrumentation-http": {
|
|
113
|
+
ignoreIncomingPaths: ["/.well-known/apollo/server-health"]
|
|
114
|
+
}
|
|
115
|
+
})
|
|
119
116
|
];
|
|
120
|
-
((
|
|
117
|
+
((_a = config.additionalInstrumentations) != null ? _a : []).forEach((instrumentation) => {
|
|
121
118
|
instrumentations.push(
|
|
122
119
|
new additionalInstrumentationConstructors[instrumentation]()
|
|
123
120
|
);
|
|
124
121
|
});
|
|
125
122
|
const sdk = new NodeSDK({
|
|
126
|
-
textMapPropagator:
|
|
127
|
-
propagators: [new AWSXRayPropagator(), new SentryPropagator()]
|
|
128
|
-
}) : new AWSXRayPropagator(),
|
|
123
|
+
textMapPropagator: new AWSXRayPropagator(),
|
|
129
124
|
instrumentations,
|
|
130
|
-
|
|
125
|
+
sampler: config.sentry ? new ParentBasedSampler({ root: new SentrySampler(config.sentry) }) : void 0,
|
|
126
|
+
contextManager: new Sentry.SentryContextManager(),
|
|
131
127
|
resource: _resource,
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
128
|
+
idGenerator: new AWSXRayIdGenerator(),
|
|
129
|
+
spanProcessors: [new BatchSpanProcessor(_traceExporter, batchConfig)],
|
|
130
|
+
metricReader: _metricReader,
|
|
131
|
+
logRecordProcessors: [
|
|
132
|
+
new logs.BatchLogRecordProcessor(_logExporter, batchConfig)
|
|
133
|
+
],
|
|
135
134
|
// TODO: Remove after issue is fixed
|
|
136
135
|
// https://github.com/open-telemetry/opentelemetry-js/issues/4638
|
|
137
136
|
resourceDetectors: [
|
|
138
137
|
awaitAttributes(envDetectorSync),
|
|
139
138
|
awaitAttributes(hostDetectorSync),
|
|
140
|
-
awaitAttributes(processDetectorSync)
|
|
139
|
+
awaitAttributes(processDetectorSync),
|
|
140
|
+
awaitAttributes(awsEcsDetectorSync)
|
|
141
141
|
]
|
|
142
142
|
});
|
|
143
143
|
sdk.start();
|
|
144
|
+
diag.setLogger((_b = config.logger) != null ? _b : serverLogger, DiagLogLevel.WARN);
|
|
144
145
|
diag.info("Tracer successfully started");
|
|
146
|
+
Sentry.validateOpenTelemetrySetup();
|
|
145
147
|
process.on("SIGTERM", () => {
|
|
146
148
|
sdk.shutdown().then(() => diag.info("Tracing and Metrics terminated")).catch(
|
|
147
149
|
(error) => diag.error("Error terminating tracing and metrics", error)
|
|
148
150
|
).finally(() => process.exit(0));
|
|
149
151
|
});
|
|
150
152
|
}
|
|
151
|
-
var CustomAWSXraySpanProcessor = class extends BatchSpanProcessor {
|
|
152
|
-
constructor(_exporter, ratio, config) {
|
|
153
|
-
super(_exporter, config);
|
|
154
|
-
this.contextMap = /* @__PURE__ */ new Map();
|
|
155
|
-
this.sampler = new ParentBasedSampler({
|
|
156
|
-
root: new TraceIdRatioBasedSampler(ratio)
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
onStart(span, parentContext) {
|
|
160
|
-
this.contextMap.set(span.spanContext().traceId, parentContext);
|
|
161
|
-
const sampleResult = this.sampler.shouldSample(
|
|
162
|
-
parentContext,
|
|
163
|
-
span.spanContext().traceId,
|
|
164
|
-
span.name,
|
|
165
|
-
span.kind,
|
|
166
|
-
span.attributes,
|
|
167
|
-
span.links
|
|
168
|
-
);
|
|
169
|
-
if (sampleResult.decision === SamplingDecision.RECORD_AND_SAMPLED) {
|
|
170
|
-
super.onStart(span, parentContext);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
onEnd(span) {
|
|
174
|
-
const context = this.contextMap.get(span.spanContext().traceId);
|
|
175
|
-
if (context) {
|
|
176
|
-
const sampleResult = this.sampler.shouldSample(
|
|
177
|
-
context,
|
|
178
|
-
span.spanContext().traceId,
|
|
179
|
-
span.name,
|
|
180
|
-
span.kind,
|
|
181
|
-
span.attributes,
|
|
182
|
-
span.links
|
|
183
|
-
);
|
|
184
|
-
this.contextMap.delete(span.spanContext().traceId);
|
|
185
|
-
if (sampleResult.decision === SamplingDecision.RECORD_AND_SAMPLED) {
|
|
186
|
-
super.onEnd(span);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
};
|
|
191
|
-
var CustomSentrySpanProcessor = class extends SentrySpanProcessor {
|
|
192
|
-
constructor() {
|
|
193
|
-
super();
|
|
194
|
-
this.contextMap = /* @__PURE__ */ new Map();
|
|
195
|
-
const sentryClient = Sentry.getClient();
|
|
196
|
-
if (!sentryClient) {
|
|
197
|
-
throw new Error("Sentry client is not initialized");
|
|
198
|
-
}
|
|
199
|
-
this.sampler = new SentrySampler(sentryClient);
|
|
200
|
-
}
|
|
201
|
-
onStart(span, parentContext) {
|
|
202
|
-
this.contextMap.set(span.spanContext().traceId, parentContext);
|
|
203
|
-
const sampleResult = this.sampler.shouldSample(
|
|
204
|
-
parentContext,
|
|
205
|
-
span.spanContext().traceId,
|
|
206
|
-
span.name,
|
|
207
|
-
span.kind,
|
|
208
|
-
span.attributes,
|
|
209
|
-
span.links
|
|
210
|
-
);
|
|
211
|
-
if (sampleResult.decision === SamplingDecision.RECORD_AND_SAMPLED) {
|
|
212
|
-
super.onStart(span, parentContext);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
onEnd(span) {
|
|
216
|
-
const context = this.contextMap.get(span.spanContext().traceId);
|
|
217
|
-
if (context) {
|
|
218
|
-
const sampleResult = this.sampler.shouldSample(
|
|
219
|
-
context,
|
|
220
|
-
span.spanContext().traceId,
|
|
221
|
-
span.name,
|
|
222
|
-
span.kind,
|
|
223
|
-
span.attributes,
|
|
224
|
-
span.links
|
|
225
|
-
);
|
|
226
|
-
this.contextMap.delete(span.spanContext().traceId);
|
|
227
|
-
if (sampleResult.decision === SamplingDecision.RECORD_AND_SAMPLED) {
|
|
228
|
-
super.onEnd(span);
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
};
|
|
233
153
|
export {
|
|
234
154
|
AdditionalInstrumentation,
|
|
235
|
-
CustomAWSXraySpanProcessor,
|
|
236
|
-
CustomSentrySpanProcessor,
|
|
237
155
|
nodeSDKBuilder
|
|
238
156
|
};
|
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"
|
|
@@ -66,27 +66,27 @@
|
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
68
|
"@opentelemetry/api": "1.9.0",
|
|
69
|
+
"@opentelemetry/auto-instrumentations-node": "0.50.0",
|
|
69
70
|
"@opentelemetry/context-async-hooks": "1.26.0",
|
|
70
71
|
"@opentelemetry/core": "1.26.0",
|
|
72
|
+
"@opentelemetry/exporter-logs-otlp-grpc": "0.53.0",
|
|
73
|
+
"@opentelemetry/exporter-logs-otlp-http": "0.53.0",
|
|
74
|
+
"@opentelemetry/exporter-metrics-otlp-grpc": "0.53.0",
|
|
75
|
+
"@opentelemetry/exporter-metrics-otlp-http": "0.53.0",
|
|
71
76
|
"@opentelemetry/exporter-trace-otlp-grpc": "0.53.0",
|
|
72
77
|
"@opentelemetry/exporter-trace-otlp-http": "0.53.0",
|
|
73
78
|
"@opentelemetry/id-generator-aws-xray": "1.2.2",
|
|
74
|
-
"@opentelemetry/instrumentation": "0.53.0",
|
|
75
|
-
"@opentelemetry/instrumentation-aws-sdk": "0.44.0",
|
|
76
|
-
"@opentelemetry/instrumentation-dataloader": "0.12.0",
|
|
77
|
-
"@opentelemetry/instrumentation-express": "0.42.0",
|
|
78
|
-
"@opentelemetry/instrumentation-graphql": "0.43.0",
|
|
79
|
-
"@opentelemetry/instrumentation-http": "0.53.0",
|
|
80
79
|
"@opentelemetry/instrumentation-knex": "0.40.0",
|
|
81
|
-
"@opentelemetry/instrumentation-mysql2": "0.41.0",
|
|
82
|
-
"@opentelemetry/instrumentation-net": "0.39.0",
|
|
83
80
|
"@opentelemetry/propagator-aws-xray": "1.26.0",
|
|
84
81
|
"@opentelemetry/resource-detector-aws": "1.6.1",
|
|
85
82
|
"@opentelemetry/resources": "1.26.0",
|
|
83
|
+
"@opentelemetry/sdk-metrics": "1.26.0",
|
|
86
84
|
"@opentelemetry/sdk-node": "0.53.0",
|
|
87
85
|
"@opentelemetry/sdk-trace-base": "1.26.0",
|
|
88
86
|
"@opentelemetry/sdk-trace-node": "1.26.0",
|
|
89
87
|
"@opentelemetry/semantic-conventions": "1.27.0",
|
|
88
|
+
"@opentelemetry/winston-transport": "0.6.0",
|
|
89
|
+
"@pocket-tools/ts-logger": "workspace:*",
|
|
90
90
|
"@prisma/instrumentation": "5.19.1",
|
|
91
91
|
"@sentry/node": "8.33.0",
|
|
92
92
|
"@sentry/opentelemetry": "8.33.0",
|