@pocket-tools/tracing 1.3.1 → 1.3.5
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 +68 -75
- package/dist/index.d.mts +19 -2
- package/dist/index.d.ts +19 -2
- package/dist/index.js +110 -17
- package/dist/index.mjs +122 -21
- package/package.json +7 -3
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
|
-
[
|
|
14
|
-
[
|
|
15
|
-
[
|
|
16
|
-
[
|
|
13
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m7.08 KB[39m
|
|
14
|
+
[32mESM[39m ⚡️ Build success in 165ms
|
|
15
|
+
[32mCJS[39m [1mdist/index.js [22m[32m9.61 KB[39m
|
|
16
|
+
[32mCJS[39m ⚡️ Build success in 172ms
|
|
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 10593ms
|
|
19
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m1.41 KB[39m
|
|
20
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m1.41 KB[39m
|
|
@@ -2,83 +2,76 @@
|
|
|
2
2
|
> @pocket-tools/tracing@0.0.0-development semantic-release /home/runner/work/pocket-monorepo/pocket-monorepo/packages/tracing
|
|
3
3
|
> semantic-release
|
|
4
4
|
|
|
5
|
-
[
|
|
6
|
-
[
|
|
7
|
-
[
|
|
8
|
-
[
|
|
9
|
-
[
|
|
10
|
-
[
|
|
11
|
-
[
|
|
12
|
-
[
|
|
13
|
-
[
|
|
14
|
-
[
|
|
15
|
-
[
|
|
16
|
-
[
|
|
17
|
-
[
|
|
5
|
+
[6:39:33 PM] [semantic-release] › ℹ Running semantic-release version 23.0.7
|
|
6
|
+
[6:39:35 PM] [semantic-release] › ✔ Loaded plugin "verifyConditions" from "@semantic-release/npm"
|
|
7
|
+
[6:39:35 PM] [semantic-release] › ✔ Loaded plugin "verifyConditions" from "@semantic-release/github"
|
|
8
|
+
[6:39:35 PM] [semantic-release] › ✔ Loaded plugin "prepare" from "@semantic-release/npm"
|
|
9
|
+
[6:39:35 PM] [semantic-release] › ✔ Loaded plugin "publish" from "@semantic-release/npm"
|
|
10
|
+
[6:39:35 PM] [semantic-release] › ✔ Loaded plugin "publish" from "@semantic-release/github"
|
|
11
|
+
[6:39:35 PM] [semantic-release] › ✔ Loaded plugin "addChannel" from "@semantic-release/npm"
|
|
12
|
+
[6:39:35 PM] [semantic-release] › ✔ Loaded plugin "addChannel" from "@semantic-release/github"
|
|
13
|
+
[6:39:46 PM] [semantic-release] › ✔ Run automated release from branch main on repository git+https://github.com/Pocket/pocket-monorepo.git
|
|
14
|
+
[6:39:47 PM] [semantic-release] › ✔ Allowed to push to the Git repository
|
|
15
|
+
[6:39:47 PM] [semantic-release] › ℹ Start step "verifyConditions" of plugin "@semantic-release/npm"
|
|
16
|
+
[6:39:47 PM] [semantic-release] [@semantic-release/npm] › ℹ Verify authentication for registry https://registry.npmjs.org/
|
|
17
|
+
[6:39:47 PM] [semantic-release] [@semantic-release/npm] › ℹ Reading npm config from /home/runner/work/_temp/.npmrc
|
|
18
18
|
pocket-npm
|
|
19
|
-
[
|
|
20
|
-
[
|
|
21
|
-
[
|
|
22
|
-
[
|
|
23
|
-
[
|
|
24
|
-
[
|
|
25
|
-
[
|
|
26
|
-
[
|
|
27
|
-
[
|
|
28
|
-
[
|
|
19
|
+
[6:39:48 PM] [semantic-release] › ✔ Completed step "verifyConditions" of plugin "@semantic-release/npm"
|
|
20
|
+
[6:39:48 PM] [semantic-release] › ℹ Start step "verifyConditions" of plugin "@semantic-release/github"
|
|
21
|
+
[6:39:48 PM] [semantic-release] [@semantic-release/github] › ℹ Verify GitHub authentication (https://api.github.com)
|
|
22
|
+
[6:39:48 PM] [semantic-release] › ✔ Completed step "verifyConditions" of plugin "@semantic-release/github"
|
|
23
|
+
[6:39:48 PM] [semantic-release] › ℹ Found git tag @pocket-tools/tracing-v1.3.4 associated with version 1.3.4 on branch main
|
|
24
|
+
[6:39:48 PM] [semantic-release] › ℹ Found 13 commits since last release
|
|
25
|
+
[6:39:48 PM] [semantic-release] › ℹ Start step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
|
|
26
|
+
[6:39:48 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ Start step "analyzeCommits" of plugin "@semantic-release/commit-analyzer"
|
|
27
|
+
[6:39:49 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ Found 1 commits for package @pocket-tools/tracing since last release
|
|
28
|
+
[6:39:49 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ Analyzing commit: fix(sentry): updating sentry to 8.5.0 (#579)
|
|
29
29
|
|
|
30
|
-
* chore(
|
|
30
|
+
* chore(sentry): updating sentry to 8.5.0
|
|
31
31
|
|
|
32
|
-
*
|
|
32
|
+
* fix(sentry-otel): moving sentry to use our open telemetry setup
|
|
33
33
|
|
|
34
|
-
*
|
|
34
|
+
* fix(otel): ensuring correct startup order for otel and sentry top play nice
|
|
35
35
|
|
|
36
|
-
*
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
[
|
|
46
|
-
[
|
|
47
|
-
[
|
|
48
|
-
[
|
|
49
|
-
[
|
|
50
|
-
[
|
|
51
|
-
[
|
|
52
|
-
[
|
|
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
|
-
[10:33:52 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ Plugin "@semantic-release/commit-analyzer" does not provide step "generateNotes"
|
|
79
|
-
[10:33:52 PM] [semantic-release] › ✔ Completed step "generateNotes" of plugin "[Function: semantic-release-monorepo]"
|
|
80
|
-
[10:33:52 PM] [semantic-release] › ℹ Start step "generateNotes" of plugin "[Function: semantic-release-monorepo]"
|
|
81
|
-
[10:33:52 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ Start step "generateNotes" of plugin "@semantic-release/release-notes-generator"
|
|
82
|
-
[10:33:52 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ Found 1 commits for package @pocket-tools/tracing since last release
|
|
83
|
-
[10:33:52 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ Completed step "generateNotes" of plugin "@semantic-release/release-notes-generator"
|
|
84
|
-
[10:33:52 PM] [semantic-release] › ✔ Completed step "generateNotes" of plugin "[Function: semantic-release-monorepo]"
|
|
36
|
+
* fix(lambda): updating lambdas sentry dsn infra
|
|
37
|
+
[6:39:49 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ The release type for the commit is patch
|
|
38
|
+
[6:39:49 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ Analysis of 1 commits complete: patch release
|
|
39
|
+
[6:39:49 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ Completed step "analyzeCommits" of plugin "@semantic-release/commit-analyzer"
|
|
40
|
+
[6:39:49 PM] [semantic-release] › ✔ Completed step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
|
|
41
|
+
[6:39:49 PM] [semantic-release] › ℹ Start step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
|
|
42
|
+
[6:39:49 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ Plugin "@semantic-release/release-notes-generator" does not provide step "analyzeCommits"
|
|
43
|
+
[6:39:49 PM] [semantic-release] › ✔ Completed step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
|
|
44
|
+
[6:39:49 PM] [semantic-release] › ℹ Start step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
|
|
45
|
+
[6:39:49 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ Plugin "@semantic-release/npm" does not provide step "analyzeCommits"
|
|
46
|
+
[6:39:49 PM] [semantic-release] › ✔ Completed step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
|
|
47
|
+
[6:39:49 PM] [semantic-release] › ℹ Start step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
|
|
48
|
+
[6:39:49 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ Plugin "@semantic-release/github" does not provide step "analyzeCommits"
|
|
49
|
+
[6:39:49 PM] [semantic-release] › ✔ Completed step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
|
|
50
|
+
[6:39:49 PM] [semantic-release] › ℹ Start step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
|
|
51
|
+
[6:39:49 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ No more plugins
|
|
52
|
+
[6:39:49 PM] [semantic-release] › ✔ Completed step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
|
|
53
|
+
[6:39:49 PM] [semantic-release] › ℹ Start step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
|
|
54
|
+
[6:39:49 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ No more plugins
|
|
55
|
+
[6:39:49 PM] [semantic-release] › ✔ Completed step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
|
|
56
|
+
[6:39:49 PM] [semantic-release] › ℹ Start step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
|
|
57
|
+
[6:39:49 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ No more plugins
|
|
58
|
+
[6:39:49 PM] [semantic-release] › ✔ Completed step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
|
|
59
|
+
[6:39:49 PM] [semantic-release] › ℹ Start step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
|
|
60
|
+
[6:39:49 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ No more plugins
|
|
61
|
+
[6:39:49 PM] [semantic-release] › ✔ Completed step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
|
|
62
|
+
[6:39:49 PM] [semantic-release] › ℹ Start step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
|
|
63
|
+
[6:39:49 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ No more plugins
|
|
64
|
+
[6:39:49 PM] [semantic-release] › ✔ Completed step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
|
|
65
|
+
[6:39:49 PM] [semantic-release] › ℹ Start step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
|
|
66
|
+
[6:39:49 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ No more plugins
|
|
67
|
+
[6:39:49 PM] [semantic-release] › ✔ Completed step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
|
|
68
|
+
[6:39:49 PM] [semantic-release] › ℹ The next release version is 1.3.5
|
|
69
|
+
[6:39:49 PM] [semantic-release] › ℹ Start step "generateNotes" of plugin "[Function: semantic-release-monorepo]"
|
|
70
|
+
[6:39:49 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ Plugin "@semantic-release/commit-analyzer" does not provide step "generateNotes"
|
|
71
|
+
[6:39:49 PM] [semantic-release] › ✔ Completed step "generateNotes" of plugin "[Function: semantic-release-monorepo]"
|
|
72
|
+
[6:39:49 PM] [semantic-release] › ℹ Start step "generateNotes" of plugin "[Function: semantic-release-monorepo]"
|
|
73
|
+
[6:39:49 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ Start step "generateNotes" of plugin "@semantic-release/release-notes-generator"
|
|
74
|
+
[6:39:49 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ Found 1 commits for package @pocket-tools/tracing since last release
|
|
75
|
+
[6:39:49 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ Completed step "generateNotes" of plugin "@semantic-release/release-notes-generator"
|
|
76
|
+
[6:39:49 PM] [semantic-release] › ✔ Completed step "generateNotes" of plugin "[Function: semantic-release-monorepo]"
|
|
77
|
+
[6:39:49 PM] [semantic-release] › ℹ Start step "generateNotes" of plugin "[Function: semantic-release-monorepo]"
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BatchSpanProcessor, ParentBasedSampler, SpanExporter, BufferConfig, Span, ReadableSpan } from '@opentelemetry/sdk-trace-base';
|
|
2
|
+
import { DiagLogger, Context } from '@opentelemetry/api';
|
|
3
|
+
import { SentrySpanProcessor, SentrySampler } from '@sentry/opentelemetry';
|
|
2
4
|
|
|
3
5
|
declare enum AdditionalInstrumentation {
|
|
4
6
|
KNEX = "KNEX",
|
|
@@ -13,8 +15,23 @@ type TracingConfig = {
|
|
|
13
15
|
httpDefaultPort?: number;
|
|
14
16
|
host?: string;
|
|
15
17
|
logger?: DiagLogger;
|
|
18
|
+
addSentry?: boolean;
|
|
16
19
|
additionalInstrumentations?: AdditionalInstrumentation[];
|
|
17
20
|
};
|
|
18
21
|
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
|
+
}
|
|
19
36
|
|
|
20
|
-
export { AdditionalInstrumentation, type TracingConfig, nodeSDKBuilder };
|
|
37
|
+
export { AdditionalInstrumentation, CustomAWSXraySpanProcessor, CustomSentrySpanProcessor, type TracingConfig, nodeSDKBuilder };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BatchSpanProcessor, ParentBasedSampler, SpanExporter, BufferConfig, Span, ReadableSpan } from '@opentelemetry/sdk-trace-base';
|
|
2
|
+
import { DiagLogger, Context } from '@opentelemetry/api';
|
|
3
|
+
import { SentrySpanProcessor, SentrySampler } from '@sentry/opentelemetry';
|
|
2
4
|
|
|
3
5
|
declare enum AdditionalInstrumentation {
|
|
4
6
|
KNEX = "KNEX",
|
|
@@ -13,8 +15,23 @@ type TracingConfig = {
|
|
|
13
15
|
httpDefaultPort?: number;
|
|
14
16
|
host?: string;
|
|
15
17
|
logger?: DiagLogger;
|
|
18
|
+
addSentry?: boolean;
|
|
16
19
|
additionalInstrumentations?: AdditionalInstrumentation[];
|
|
17
20
|
};
|
|
18
21
|
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
|
+
}
|
|
19
36
|
|
|
20
|
-
export { AdditionalInstrumentation, type TracingConfig, nodeSDKBuilder };
|
|
37
|
+
export { AdditionalInstrumentation, CustomAWSXraySpanProcessor, CustomSentrySpanProcessor, type TracingConfig, nodeSDKBuilder };
|
package/dist/index.js
CHANGED
|
@@ -30,6 +30,8 @@ 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,
|
|
33
35
|
nodeSDKBuilder: () => nodeSDKBuilder
|
|
34
36
|
});
|
|
35
37
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -37,6 +39,7 @@ module.exports = __toCommonJS(src_exports);
|
|
|
37
39
|
// src/tracing.ts
|
|
38
40
|
var import_process = __toESM(require("process"));
|
|
39
41
|
var import_sdk_node = require("@opentelemetry/sdk-node");
|
|
42
|
+
var import_core = require("@opentelemetry/core");
|
|
40
43
|
var import_instrumentation_graphql = require("@opentelemetry/instrumentation-graphql");
|
|
41
44
|
var import_instrumentation_aws_sdk = require("@opentelemetry/instrumentation-aws-sdk");
|
|
42
45
|
var import_id_generator_aws_xray = require("@opentelemetry/id-generator-aws-xray");
|
|
@@ -53,8 +56,10 @@ var import_exporter_trace_otlp_grpc = require("@opentelemetry/exporter-trace-otl
|
|
|
53
56
|
var import_instrumentation = require("@prisma/instrumentation");
|
|
54
57
|
var import_resources = require("@opentelemetry/resources");
|
|
55
58
|
var import_semantic_conventions = require("@opentelemetry/semantic-conventions");
|
|
56
|
-
var import_sdk_trace_node = require("@opentelemetry/sdk-trace-node");
|
|
57
59
|
var import_ExpressLayerType = require("@opentelemetry/instrumentation-express/build/src/enums/ExpressLayerType");
|
|
60
|
+
var import_opentelemetry = require("@sentry/opentelemetry");
|
|
61
|
+
var import_context_async_hooks = require("@opentelemetry/context-async-hooks");
|
|
62
|
+
var Sentry = __toESM(require("@sentry/node"));
|
|
58
63
|
var AdditionalInstrumentation = /* @__PURE__ */ ((AdditionalInstrumentation2) => {
|
|
59
64
|
AdditionalInstrumentation2["KNEX"] = "KNEX";
|
|
60
65
|
AdditionalInstrumentation2["PRISMA"] = "PRISMA";
|
|
@@ -67,32 +72,41 @@ var additionalInstrumentationConstructors = {
|
|
|
67
72
|
var tracingDefaults = {
|
|
68
73
|
serviceName: "unknown",
|
|
69
74
|
release: "unknown",
|
|
70
|
-
samplingRatio:
|
|
75
|
+
samplingRatio: 1,
|
|
71
76
|
graphQLDepth: 8,
|
|
72
77
|
grpcDefaultPort: 4317,
|
|
73
78
|
httpDefaultPort: 4318,
|
|
74
79
|
host: "otlpcollector",
|
|
75
80
|
logger: new import_api.DiagConsoleLogger(),
|
|
81
|
+
addSentry: false,
|
|
76
82
|
additionalInstrumentations: []
|
|
77
83
|
};
|
|
84
|
+
var SentryContextManager = (0, import_opentelemetry.wrapContextManagerClass)(
|
|
85
|
+
import_context_async_hooks.AsyncLocalStorageContextManager
|
|
86
|
+
);
|
|
78
87
|
async function nodeSDKBuilder(config) {
|
|
79
88
|
config = { ...tracingDefaults, ...config };
|
|
80
89
|
import_api.diag.setLogger(config.logger, import_api.DiagLogLevel.WARN);
|
|
81
90
|
const _resource = import_resources.Resource.default().merge(
|
|
82
91
|
new import_resources.Resource({
|
|
83
|
-
[import_semantic_conventions.
|
|
84
|
-
[import_semantic_conventions.
|
|
92
|
+
[import_semantic_conventions.SEMRESATTRS_SERVICE_NAME]: config.serviceName,
|
|
93
|
+
[import_semantic_conventions.SEMRESATTRS_SERVICE_VERSION]: config.release
|
|
85
94
|
})
|
|
86
95
|
);
|
|
87
96
|
const _traceExporter = new import_exporter_trace_otlp_grpc.OTLPTraceExporter({
|
|
88
97
|
//collector url
|
|
89
98
|
url: `http://${config.host}:${config.grpcDefaultPort}`
|
|
90
99
|
});
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
100
|
+
const _spanProcessors = [
|
|
101
|
+
new CustomAWSXraySpanProcessor(_traceExporter, config.samplingRatio, {
|
|
102
|
+
// only force 100ms between 2 batch exports.
|
|
103
|
+
// Default is 5000ms which is 5 seconds and causes us to lose spans
|
|
104
|
+
scheduledDelayMillis: 100
|
|
105
|
+
})
|
|
106
|
+
];
|
|
107
|
+
if (config.addSentry) {
|
|
108
|
+
_spanProcessors.push(new CustomSentrySpanProcessor());
|
|
109
|
+
}
|
|
96
110
|
const _idGenerator = new import_id_generator_aws_xray.AWSXRayIdGenerator();
|
|
97
111
|
const instrumentations = [
|
|
98
112
|
new import_instrumentation_aws_sdk.AwsInstrumentation({
|
|
@@ -120,26 +134,105 @@ async function nodeSDKBuilder(config) {
|
|
|
120
134
|
);
|
|
121
135
|
});
|
|
122
136
|
const sdk = new import_sdk_node.NodeSDK({
|
|
123
|
-
textMapPropagator: new
|
|
137
|
+
textMapPropagator: config.addSentry ? new import_core.CompositePropagator({
|
|
138
|
+
propagators: [new import_propagator_aws_xray.AWSXRayPropagator(), new import_opentelemetry.SentryPropagator()]
|
|
139
|
+
}) : new import_propagator_aws_xray.AWSXRayPropagator(),
|
|
124
140
|
instrumentations,
|
|
141
|
+
contextManager: config.addSentry ? new SentryContextManager() : void 0,
|
|
125
142
|
resource: _resource,
|
|
126
|
-
|
|
143
|
+
spanProcessors: _spanProcessors,
|
|
127
144
|
traceExporter: _traceExporter,
|
|
128
|
-
idGenerator: _idGenerator
|
|
129
|
-
sampler: new import_sdk_trace_node.ParentBasedSampler({
|
|
130
|
-
//set at 20% sampling rate
|
|
131
|
-
root: new import_sdk_trace_node.TraceIdRatioBasedSampler(config.samplingRatio)
|
|
132
|
-
})
|
|
145
|
+
idGenerator: _idGenerator
|
|
133
146
|
});
|
|
134
|
-
|
|
147
|
+
sdk.start();
|
|
135
148
|
import_process.default.on("SIGTERM", () => {
|
|
136
149
|
sdk.shutdown().then(() => import_api.diag.info("Tracing and Metrics terminated")).catch(
|
|
137
150
|
(error) => import_api.diag.error("Error terminating tracing and metrics", error)
|
|
138
151
|
).finally(() => import_process.default.exit(0));
|
|
139
152
|
});
|
|
140
153
|
}
|
|
154
|
+
var CustomAWSXraySpanProcessor = class extends import_sdk_trace_base.BatchSpanProcessor {
|
|
155
|
+
constructor(_exporter, ratio, config) {
|
|
156
|
+
super(_exporter, config);
|
|
157
|
+
this.contextMap = /* @__PURE__ */ new Map();
|
|
158
|
+
this.sampler = new import_sdk_trace_base.ParentBasedSampler({
|
|
159
|
+
root: new import_sdk_trace_base.TraceIdRatioBasedSampler(ratio)
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
onStart(span, parentContext) {
|
|
163
|
+
this.contextMap.set(span.spanContext().traceId, parentContext);
|
|
164
|
+
const sampleResult = this.sampler.shouldSample(
|
|
165
|
+
parentContext,
|
|
166
|
+
span.spanContext().traceId,
|
|
167
|
+
span.name,
|
|
168
|
+
span.kind,
|
|
169
|
+
span.attributes,
|
|
170
|
+
span.links
|
|
171
|
+
);
|
|
172
|
+
if (sampleResult.decision == import_sdk_trace_base.SamplingDecision.RECORD_AND_SAMPLED) {
|
|
173
|
+
super.onStart(span, parentContext);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
onEnd(span) {
|
|
177
|
+
const context = this.contextMap.get(span.spanContext().traceId);
|
|
178
|
+
if (context) {
|
|
179
|
+
const sampleResult = this.sampler.shouldSample(
|
|
180
|
+
context,
|
|
181
|
+
span.spanContext().traceId,
|
|
182
|
+
span.name,
|
|
183
|
+
span.kind,
|
|
184
|
+
span.attributes,
|
|
185
|
+
span.links
|
|
186
|
+
);
|
|
187
|
+
this.contextMap.delete(span.spanContext().traceId);
|
|
188
|
+
if (sampleResult.decision == import_sdk_trace_base.SamplingDecision.RECORD_AND_SAMPLED) {
|
|
189
|
+
super.onEnd(span);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
var CustomSentrySpanProcessor = class extends import_opentelemetry.SentrySpanProcessor {
|
|
195
|
+
constructor() {
|
|
196
|
+
super();
|
|
197
|
+
this.contextMap = /* @__PURE__ */ new Map();
|
|
198
|
+
this.sampler = new import_opentelemetry.SentrySampler(Sentry.getClient());
|
|
199
|
+
}
|
|
200
|
+
onStart(span, parentContext) {
|
|
201
|
+
this.contextMap.set(span.spanContext().traceId, parentContext);
|
|
202
|
+
const sampleResult = this.sampler.shouldSample(
|
|
203
|
+
parentContext,
|
|
204
|
+
span.spanContext().traceId,
|
|
205
|
+
span.name,
|
|
206
|
+
span.kind,
|
|
207
|
+
span.attributes,
|
|
208
|
+
span.links
|
|
209
|
+
);
|
|
210
|
+
if (sampleResult.decision == import_sdk_trace_base.SamplingDecision.RECORD_AND_SAMPLED) {
|
|
211
|
+
super.onStart(span, parentContext);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
onEnd(span) {
|
|
215
|
+
const context = this.contextMap.get(span.spanContext().traceId);
|
|
216
|
+
if (context) {
|
|
217
|
+
const sampleResult = this.sampler.shouldSample(
|
|
218
|
+
context,
|
|
219
|
+
span.spanContext().traceId,
|
|
220
|
+
span.name,
|
|
221
|
+
span.kind,
|
|
222
|
+
span.attributes,
|
|
223
|
+
span.links
|
|
224
|
+
);
|
|
225
|
+
this.contextMap.delete(span.spanContext().traceId);
|
|
226
|
+
if (sampleResult.decision == import_sdk_trace_base.SamplingDecision.RECORD_AND_SAMPLED) {
|
|
227
|
+
super.onEnd(span);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
};
|
|
141
232
|
// Annotate the CommonJS export names for ESM import in node:
|
|
142
233
|
0 && (module.exports = {
|
|
143
234
|
AdditionalInstrumentation,
|
|
235
|
+
CustomAWSXraySpanProcessor,
|
|
236
|
+
CustomSentrySpanProcessor,
|
|
144
237
|
nodeSDKBuilder
|
|
145
238
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
// src/tracing.ts
|
|
2
2
|
import process from "process";
|
|
3
3
|
import { NodeSDK } from "@opentelemetry/sdk-node";
|
|
4
|
+
import { CompositePropagator } from "@opentelemetry/core";
|
|
4
5
|
import { GraphQLInstrumentation } from "@opentelemetry/instrumentation-graphql";
|
|
5
6
|
import { AwsInstrumentation } from "@opentelemetry/instrumentation-aws-sdk";
|
|
6
7
|
import { AWSXRayIdGenerator } from "@opentelemetry/id-generator-aws-xray";
|
|
7
8
|
import { AWSXRayPropagator } from "@opentelemetry/propagator-aws-xray";
|
|
8
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
BatchSpanProcessor,
|
|
11
|
+
SamplingDecision,
|
|
12
|
+
TraceIdRatioBasedSampler,
|
|
13
|
+
ParentBasedSampler
|
|
14
|
+
} from "@opentelemetry/sdk-trace-base";
|
|
9
15
|
import { DataloaderInstrumentation } from "@opentelemetry/instrumentation-dataloader";
|
|
10
16
|
import {
|
|
11
17
|
DiagConsoleLogger,
|
|
@@ -20,12 +26,19 @@ import { NetInstrumentation } from "@opentelemetry/instrumentation-net";
|
|
|
20
26
|
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-grpc";
|
|
21
27
|
import { PrismaInstrumentation } from "@prisma/instrumentation";
|
|
22
28
|
import { Resource } from "@opentelemetry/resources";
|
|
23
|
-
import { SemanticResourceAttributes } from "@opentelemetry/semantic-conventions";
|
|
24
29
|
import {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
} from "@opentelemetry/
|
|
30
|
+
SEMRESATTRS_SERVICE_NAME,
|
|
31
|
+
SEMRESATTRS_SERVICE_VERSION
|
|
32
|
+
} from "@opentelemetry/semantic-conventions";
|
|
28
33
|
import { ExpressLayerType } from "@opentelemetry/instrumentation-express/build/src/enums/ExpressLayerType";
|
|
34
|
+
import {
|
|
35
|
+
SentrySpanProcessor,
|
|
36
|
+
SentryPropagator,
|
|
37
|
+
SentrySampler,
|
|
38
|
+
wrapContextManagerClass
|
|
39
|
+
} from "@sentry/opentelemetry";
|
|
40
|
+
import { AsyncLocalStorageContextManager } from "@opentelemetry/context-async-hooks";
|
|
41
|
+
import * as Sentry from "@sentry/node";
|
|
29
42
|
var AdditionalInstrumentation = /* @__PURE__ */ ((AdditionalInstrumentation2) => {
|
|
30
43
|
AdditionalInstrumentation2["KNEX"] = "KNEX";
|
|
31
44
|
AdditionalInstrumentation2["PRISMA"] = "PRISMA";
|
|
@@ -38,32 +51,41 @@ var additionalInstrumentationConstructors = {
|
|
|
38
51
|
var tracingDefaults = {
|
|
39
52
|
serviceName: "unknown",
|
|
40
53
|
release: "unknown",
|
|
41
|
-
samplingRatio:
|
|
54
|
+
samplingRatio: 1,
|
|
42
55
|
graphQLDepth: 8,
|
|
43
56
|
grpcDefaultPort: 4317,
|
|
44
57
|
httpDefaultPort: 4318,
|
|
45
58
|
host: "otlpcollector",
|
|
46
59
|
logger: new DiagConsoleLogger(),
|
|
60
|
+
addSentry: false,
|
|
47
61
|
additionalInstrumentations: []
|
|
48
62
|
};
|
|
63
|
+
var SentryContextManager = wrapContextManagerClass(
|
|
64
|
+
AsyncLocalStorageContextManager
|
|
65
|
+
);
|
|
49
66
|
async function nodeSDKBuilder(config) {
|
|
50
67
|
config = { ...tracingDefaults, ...config };
|
|
51
68
|
diag.setLogger(config.logger, DiagLogLevel.WARN);
|
|
52
69
|
const _resource = Resource.default().merge(
|
|
53
70
|
new Resource({
|
|
54
|
-
[
|
|
55
|
-
[
|
|
71
|
+
[SEMRESATTRS_SERVICE_NAME]: config.serviceName,
|
|
72
|
+
[SEMRESATTRS_SERVICE_VERSION]: config.release
|
|
56
73
|
})
|
|
57
74
|
);
|
|
58
75
|
const _traceExporter = new OTLPTraceExporter({
|
|
59
76
|
//collector url
|
|
60
77
|
url: `http://${config.host}:${config.grpcDefaultPort}`
|
|
61
78
|
});
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
79
|
+
const _spanProcessors = [
|
|
80
|
+
new CustomAWSXraySpanProcessor(_traceExporter, config.samplingRatio, {
|
|
81
|
+
// only force 100ms between 2 batch exports.
|
|
82
|
+
// Default is 5000ms which is 5 seconds and causes us to lose spans
|
|
83
|
+
scheduledDelayMillis: 100
|
|
84
|
+
})
|
|
85
|
+
];
|
|
86
|
+
if (config.addSentry) {
|
|
87
|
+
_spanProcessors.push(new CustomSentrySpanProcessor());
|
|
88
|
+
}
|
|
67
89
|
const _idGenerator = new AWSXRayIdGenerator();
|
|
68
90
|
const instrumentations = [
|
|
69
91
|
new AwsInstrumentation({
|
|
@@ -91,25 +113,104 @@ async function nodeSDKBuilder(config) {
|
|
|
91
113
|
);
|
|
92
114
|
});
|
|
93
115
|
const sdk = new NodeSDK({
|
|
94
|
-
textMapPropagator: new
|
|
116
|
+
textMapPropagator: config.addSentry ? new CompositePropagator({
|
|
117
|
+
propagators: [new AWSXRayPropagator(), new SentryPropagator()]
|
|
118
|
+
}) : new AWSXRayPropagator(),
|
|
95
119
|
instrumentations,
|
|
120
|
+
contextManager: config.addSentry ? new SentryContextManager() : void 0,
|
|
96
121
|
resource: _resource,
|
|
97
|
-
|
|
122
|
+
spanProcessors: _spanProcessors,
|
|
98
123
|
traceExporter: _traceExporter,
|
|
99
|
-
idGenerator: _idGenerator
|
|
100
|
-
sampler: new ParentBasedSampler({
|
|
101
|
-
//set at 20% sampling rate
|
|
102
|
-
root: new TraceIdRatioBasedSampler(config.samplingRatio)
|
|
103
|
-
})
|
|
124
|
+
idGenerator: _idGenerator
|
|
104
125
|
});
|
|
105
|
-
|
|
126
|
+
sdk.start();
|
|
106
127
|
process.on("SIGTERM", () => {
|
|
107
128
|
sdk.shutdown().then(() => diag.info("Tracing and Metrics terminated")).catch(
|
|
108
129
|
(error) => diag.error("Error terminating tracing and metrics", error)
|
|
109
130
|
).finally(() => process.exit(0));
|
|
110
131
|
});
|
|
111
132
|
}
|
|
133
|
+
var CustomAWSXraySpanProcessor = class extends BatchSpanProcessor {
|
|
134
|
+
constructor(_exporter, ratio, config) {
|
|
135
|
+
super(_exporter, config);
|
|
136
|
+
this.contextMap = /* @__PURE__ */ new Map();
|
|
137
|
+
this.sampler = new ParentBasedSampler({
|
|
138
|
+
root: new TraceIdRatioBasedSampler(ratio)
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
onStart(span, parentContext) {
|
|
142
|
+
this.contextMap.set(span.spanContext().traceId, parentContext);
|
|
143
|
+
const sampleResult = this.sampler.shouldSample(
|
|
144
|
+
parentContext,
|
|
145
|
+
span.spanContext().traceId,
|
|
146
|
+
span.name,
|
|
147
|
+
span.kind,
|
|
148
|
+
span.attributes,
|
|
149
|
+
span.links
|
|
150
|
+
);
|
|
151
|
+
if (sampleResult.decision == SamplingDecision.RECORD_AND_SAMPLED) {
|
|
152
|
+
super.onStart(span, parentContext);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
onEnd(span) {
|
|
156
|
+
const context = this.contextMap.get(span.spanContext().traceId);
|
|
157
|
+
if (context) {
|
|
158
|
+
const sampleResult = this.sampler.shouldSample(
|
|
159
|
+
context,
|
|
160
|
+
span.spanContext().traceId,
|
|
161
|
+
span.name,
|
|
162
|
+
span.kind,
|
|
163
|
+
span.attributes,
|
|
164
|
+
span.links
|
|
165
|
+
);
|
|
166
|
+
this.contextMap.delete(span.spanContext().traceId);
|
|
167
|
+
if (sampleResult.decision == SamplingDecision.RECORD_AND_SAMPLED) {
|
|
168
|
+
super.onEnd(span);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
var CustomSentrySpanProcessor = class extends SentrySpanProcessor {
|
|
174
|
+
constructor() {
|
|
175
|
+
super();
|
|
176
|
+
this.contextMap = /* @__PURE__ */ new Map();
|
|
177
|
+
this.sampler = new SentrySampler(Sentry.getClient());
|
|
178
|
+
}
|
|
179
|
+
onStart(span, parentContext) {
|
|
180
|
+
this.contextMap.set(span.spanContext().traceId, parentContext);
|
|
181
|
+
const sampleResult = this.sampler.shouldSample(
|
|
182
|
+
parentContext,
|
|
183
|
+
span.spanContext().traceId,
|
|
184
|
+
span.name,
|
|
185
|
+
span.kind,
|
|
186
|
+
span.attributes,
|
|
187
|
+
span.links
|
|
188
|
+
);
|
|
189
|
+
if (sampleResult.decision == SamplingDecision.RECORD_AND_SAMPLED) {
|
|
190
|
+
super.onStart(span, parentContext);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
onEnd(span) {
|
|
194
|
+
const context = this.contextMap.get(span.spanContext().traceId);
|
|
195
|
+
if (context) {
|
|
196
|
+
const sampleResult = this.sampler.shouldSample(
|
|
197
|
+
context,
|
|
198
|
+
span.spanContext().traceId,
|
|
199
|
+
span.name,
|
|
200
|
+
span.kind,
|
|
201
|
+
span.attributes,
|
|
202
|
+
span.links
|
|
203
|
+
);
|
|
204
|
+
this.contextMap.delete(span.spanContext().traceId);
|
|
205
|
+
if (sampleResult.decision == SamplingDecision.RECORD_AND_SAMPLED) {
|
|
206
|
+
super.onEnd(span);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
};
|
|
112
211
|
export {
|
|
113
212
|
AdditionalInstrumentation,
|
|
213
|
+
CustomAWSXraySpanProcessor,
|
|
214
|
+
CustomSentrySpanProcessor,
|
|
114
215
|
nodeSDKBuilder
|
|
115
216
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pocket-tools/tracing",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.5",
|
|
4
4
|
"description": "Utilities for tracing",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"tracing"
|
|
@@ -65,6 +65,8 @@
|
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
67
|
"@opentelemetry/api": "1.8.0",
|
|
68
|
+
"@opentelemetry/context-async-hooks": "1.24.1",
|
|
69
|
+
"@opentelemetry/core": "1.24.1",
|
|
68
70
|
"@opentelemetry/exporter-trace-otlp-grpc": "0.51.1",
|
|
69
71
|
"@opentelemetry/exporter-trace-otlp-http": "0.51.1",
|
|
70
72
|
"@opentelemetry/id-generator-aws-xray": "1.2.2",
|
|
@@ -84,7 +86,10 @@
|
|
|
84
86
|
"@opentelemetry/sdk-trace-base": "1.24.1",
|
|
85
87
|
"@opentelemetry/sdk-trace-node": "1.24.1",
|
|
86
88
|
"@opentelemetry/semantic-conventions": "1.24.1",
|
|
87
|
-
"@prisma/instrumentation": "5.
|
|
89
|
+
"@prisma/instrumentation": "5.14.0",
|
|
90
|
+
"@sentry/node": "8.5.0",
|
|
91
|
+
"@sentry/opentelemetry": "8.5.0",
|
|
92
|
+
"tslib": "2.6.2"
|
|
88
93
|
},
|
|
89
94
|
"devDependencies": {
|
|
90
95
|
"@jest/globals": "29.7.0",
|
|
@@ -97,7 +102,6 @@
|
|
|
97
102
|
"ts-jest": "29.1.2",
|
|
98
103
|
"ts-node": "10.9.2",
|
|
99
104
|
"tsconfig": "workspace:*",
|
|
100
|
-
"tslib": "2.6.2",
|
|
101
105
|
"tsup": "8.0.2",
|
|
102
106
|
"typescript": "5.4.4"
|
|
103
107
|
}
|