@pocket-tools/tracing 1.6.1 → 1.7.1

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.
@@ -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
+ CLI Building entry: src/index.ts
6
+ CLI Using tsconfig: tsconfig.json
7
+ CLI tsup v8.2.4
8
+ CLI Target: es2019
9
+ CJS Build start
10
+ ESM Build start
11
+ CJS You have emitDecoratorMetadata enabled but @swc/core was not installed, skipping swc plugin
12
+ ESM You have emitDecoratorMetadata enabled but @swc/core was not installed, skipping swc plugin
13
+ CJS dist/index.js 8.39 KB
14
+ CJS ⚡️ Build success in 184ms
15
+ ESM dist/index.mjs 6.15 KB
16
+ ESM ⚡️ Build success in 185ms
17
+ DTS Build start
18
+ DTS ⚡️ Build success in 8723ms
19
+ DTS dist/index.d.ts 623.00 B
20
+ DTS dist/index.d.mts 623.00 B
@@ -14,76 +14,74 @@
14
14
  ESM Build start
15
15
  CJS You have emitDecoratorMetadata enabled but @swc/core was not installed, skipping swc plugin
16
16
  ESM You have emitDecoratorMetadata enabled but @swc/core was not installed, skipping swc plugin
17
- ESM dist/index.mjs 7.79 KB
18
- ESM ⚡️ Build success in 197ms
19
- CJS dist/index.js 10.35 KB
20
- CJS ⚡️ Build success in 199ms
17
+ ESM dist/index.mjs 6.15 KB
18
+ ESM ⚡️ Build success in 139ms
19
+ CJS dist/index.js 8.39 KB
20
+ CJS ⚡️ Build success in 140ms
21
21
  DTS Build start
22
- DTS ⚡️ Build success in 7190ms
23
- DTS dist/index.d.ts 1.41 KB
24
- DTS dist/index.d.mts 1.41 KB
22
+ DTS ⚡️ Build success in 6987ms
23
+ DTS dist/index.d.ts 623.00 B
24
+ DTS dist/index.d.mts 623.00 B
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
- [7:25:34 PM] [semantic-release] › ℹ Running semantic-release version 24.1.0
30
- [7:25:36 PM] [semantic-release] › ✔ Loaded plugin "verifyConditions" from "@semantic-release/npm"
31
- [7:25:36 PM] [semantic-release] › ✔ Loaded plugin "verifyConditions" from "@semantic-release/github"
32
- [7:25:36 PM] [semantic-release] › ✔ Loaded plugin "prepare" from "@semantic-release/npm"
33
- [7:25:36 PM] [semantic-release] › ✔ Loaded plugin "publish" from "@semantic-release/npm"
34
- [7:25:36 PM] [semantic-release] › ✔ Loaded plugin "publish" from "@semantic-release/github"
35
- [7:25:36 PM] [semantic-release] › ✔ Loaded plugin "addChannel" from "@semantic-release/npm"
36
- [7:25:36 PM] [semantic-release] › ✔ Loaded plugin "addChannel" from "@semantic-release/github"
37
- [7:25:39 PM] [semantic-release] › ✔ Run automated release from branch main on repository git+https://github.com/Pocket/pocket-monorepo.git
38
- [7:25:39 PM] [semantic-release] › ✔ Allowed to push to the Git repository
39
- [7:25:39 PM] [semantic-release] › ℹ Start step "verifyConditions" of plugin "@semantic-release/npm"
40
- [7:25:39 PM] [semantic-release] [@semantic-release/npm] › ℹ Verify authentication for registry https://registry.npmjs.org/
41
- [7:25:39 PM] [semantic-release] [@semantic-release/npm] › ℹ Wrote NPM_TOKEN to /tmp/cb2d65bae8b2278cca2c9045e6c89137/.npmrc
29
+ [5:46:16 PM] [semantic-release] › ℹ Running semantic-release version 24.1.0
30
+ [5:46:16 PM] [semantic-release] › ✔ Loaded plugin "verifyConditions" from "@semantic-release/npm"
31
+ [5:46:16 PM] [semantic-release] › ✔ Loaded plugin "verifyConditions" from "@semantic-release/github"
32
+ [5:46:16 PM] [semantic-release] › ✔ Loaded plugin "prepare" from "@semantic-release/npm"
33
+ [5:46:16 PM] [semantic-release] › ✔ Loaded plugin "publish" from "@semantic-release/npm"
34
+ [5:46:16 PM] [semantic-release] › ✔ Loaded plugin "publish" from "@semantic-release/github"
35
+ [5:46:16 PM] [semantic-release] › ✔ Loaded plugin "addChannel" from "@semantic-release/npm"
36
+ [5:46:16 PM] [semantic-release] › ✔ Loaded plugin "addChannel" from "@semantic-release/github"
37
+ [5:46:19 PM] [semantic-release] › ✔ Run automated release from branch main on repository git+https://github.com/Pocket/pocket-monorepo.git
38
+ [5:46:20 PM] [semantic-release] › ✔ Allowed to push to the Git repository
39
+ [5:46:20 PM] [semantic-release] › ℹ Start step "verifyConditions" of plugin "@semantic-release/npm"
40
+ [5:46:20 PM] [semantic-release] [@semantic-release/npm] › ℹ Verify authentication for registry https://registry.npmjs.org/
41
+ [5:46:20 PM] [semantic-release] [@semantic-release/npm] › ℹ Wrote NPM_TOKEN to /tmp/1b9732fbbf7482ab859cd833093ec597/.npmrc
42
42
  pocket-npm
43
- [7:25:40 PM] [semantic-release] › ✔ Completed step "verifyConditions" of plugin "@semantic-release/npm"
44
- [7:25:40 PM] [semantic-release] › ℹ Start step "verifyConditions" of plugin "@semantic-release/github"
45
- [7:25:40 PM] [semantic-release] [@semantic-release/github] › ℹ Verify GitHub authentication (https://api.github.com)
46
- [7:25:40 PM] [semantic-release] › ✔ Completed step "verifyConditions" of plugin "@semantic-release/github"
47
- [7:25:40 PM] [semantic-release] › ℹ Found git tag @pocket-tools/tracing-v1.6.0 associated with version 1.6.0 on branch main
48
- [7:25:41 PM] [semantic-release] › ℹ Found 1 commits since last release
49
- [7:25:41 PM] [semantic-release] › ℹ Start step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
50
- [7:25:41 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ Start step "analyzeCommits" of plugin "@semantic-release/commit-analyzer"
51
- [7:25:41 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ Found 1 commits for package @pocket-tools/tracing since last release
52
- [7:25:41 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ Analyzing commit: Revert "feat(otel): adding in basic tracing via otel (#798)" (#799)
53
-
54
- This reverts commit dbbe47179f7ed36c12fe9c1a76c72b93a4eb8af5.
55
- [7:25:41 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ The release type for the commit is patch
56
- [7:25:41 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ Analysis of 1 commits complete: patch release
57
- [7:25:41 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ Completed step "analyzeCommits" of plugin "@semantic-release/commit-analyzer"
58
- [7:25:41 PM] [semantic-release] › ✔ Completed step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
59
- [7:25:41 PM] [semantic-release] › Start step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
60
- [7:25:41 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ Plugin "@semantic-release/release-notes-generator" does not provide step "analyzeCommits"
61
- [7:25:41 PM] [semantic-release] › ✔ Completed step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
62
- [7:25:41 PM] [semantic-release] › Start step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
63
- [7:25:41 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ Plugin "@semantic-release/npm" does not provide step "analyzeCommits"
64
- [7:25:41 PM] [semantic-release] › ✔ Completed step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
65
- [7:25:41 PM] [semantic-release] › Start step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
66
- [7:25:41 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ Plugin "@semantic-release/github" does not provide step "analyzeCommits"
67
- [7:25:41 PM] [semantic-release] › ✔ Completed step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
68
- [7:25:41 PM] [semantic-release] › Start step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
69
- [7:25:41 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ No more plugins
70
- [7:25:41 PM] [semantic-release] › ✔ Completed step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
71
- [7:25:41 PM] [semantic-release] › Start step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
72
- [7:25:41 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ No more plugins
73
- [7:25:41 PM] [semantic-release] › ✔ Completed step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
74
- [7:25:41 PM] [semantic-release] › Start step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
75
- [7:25:41 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ No more plugins
76
- [7:25:41 PM] [semantic-release] › ✔ Completed step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
77
- [7:25:41 PM] [semantic-release] › Start step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
78
- [7:25:41 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ No more plugins
79
- [7:25:41 PM] [semantic-release] › ✔ Completed step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
80
- [7:25:41 PM] [semantic-release] › Start step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
81
- [7:25:41 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ No more plugins
82
- [7:25:41 PM] [semantic-release] › ✔ Completed step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
83
- [7:25:41 PM] [semantic-release] › Start step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
84
- [7:25:41 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ No more plugins
85
- [7:25:41 PM] [semantic-release] › Completed step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
86
- [7:25:41 PM] [semantic-release] › ℹ The next release version is 1.6.1
87
- [7:25:41 PM] [semantic-release] › Start step "generateNotes" of plugin "[Function: semantic-release-monorepo]"
88
- [7:25:41 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ Plugin "@semantic-release/commit-analyzer" does not provide step "generateNotes"
89
- [7:25:41 PM] [semantic-release] › ✔ Completed step "generateNotes" of plugin "[Function: semantic-release-monorepo]"
43
+ [5:46:20 PM] [semantic-release] › ✔ Completed step "verifyConditions" of plugin "@semantic-release/npm"
44
+ [5:46:20 PM] [semantic-release] › ℹ Start step "verifyConditions" of plugin "@semantic-release/github"
45
+ [5:46:20 PM] [semantic-release] [@semantic-release/github] › ℹ Verify GitHub authentication (https://api.github.com)
46
+ [5:46:20 PM] [semantic-release] › ✔ Completed step "verifyConditions" of plugin "@semantic-release/github"
47
+ [5:46:20 PM] [semantic-release] › ℹ Found git tag @pocket-tools/tracing-v1.7.0 associated with version 1.7.0 on branch main
48
+ [5:46:20 PM] [semantic-release] › ℹ Found 1 commits since last release
49
+ [5:46:20 PM] [semantic-release] › ℹ Start step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
50
+ [5:46:20 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ Start step "analyzeCommits" of plugin "@semantic-release/commit-analyzer"
51
+ [5:46:20 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ Found 1 commits for package @pocket-tools/tracing since last release
52
+ [5:46:20 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ Analyzing commit: fix(otel): adjusting otel processing settings (#803)
53
+ [5:46:20 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ The release type for the commit is patch
54
+ [5:46:20 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ Analysis of 1 commits complete: patch release
55
+ [5:46:20 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ Completed step "analyzeCommits" of plugin "@semantic-release/commit-analyzer"
56
+ [5:46:20 PM] [semantic-release] › ✔ Completed step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
57
+ [5:46:20 PM] [semantic-release] › ℹ Start step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
58
+ [5:46:20 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ Plugin "@semantic-release/release-notes-generator" does not provide step "analyzeCommits"
59
+ [5:46:20 PM] [semantic-release] › Completed step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
60
+ [5:46:20 PM] [semantic-release] › ℹ Start step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
61
+ [5:46:20 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ Plugin "@semantic-release/npm" does not provide step "analyzeCommits"
62
+ [5:46:20 PM] [semantic-release] › Completed step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
63
+ [5:46:20 PM] [semantic-release] › ℹ Start step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
64
+ [5:46:20 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ Plugin "@semantic-release/github" does not provide step "analyzeCommits"
65
+ [5:46:20 PM] [semantic-release] › Completed step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
66
+ [5:46:20 PM] [semantic-release] › ℹ Start step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
67
+ [5:46:20 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ No more plugins
68
+ [5:46:20 PM] [semantic-release] › Completed step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
69
+ [5:46:20 PM] [semantic-release] › ℹ Start step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
70
+ [5:46:20 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ No more plugins
71
+ [5:46:20 PM] [semantic-release] › Completed step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
72
+ [5:46:20 PM] [semantic-release] › ℹ Start step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
73
+ [5:46:20 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ No more plugins
74
+ [5:46:20 PM] [semantic-release] › Completed step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
75
+ [5:46:20 PM] [semantic-release] › ℹ Start step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
76
+ [5:46:20 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ No more plugins
77
+ [5:46:20 PM] [semantic-release] › Completed step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
78
+ [5:46:20 PM] [semantic-release] › ℹ Start step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
79
+ [5:46:20 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ No more plugins
80
+ [5:46:20 PM] [semantic-release] › Completed step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
81
+ [5:46:20 PM] [semantic-release] › ℹ Start step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
82
+ [5:46:20 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ No more plugins
83
+ [5:46:20 PM] [semantic-release] › Completed step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
84
+ [5:46:20 PM] [semantic-release] › ℹ The next release version is 1.7.1
85
+ [5:46:20 PM] [semantic-release] › Start step "generateNotes" of plugin "[Function: semantic-release-monorepo]"
86
+ [5:46:20 PM] [semantic-release] [[Function: semantic-release-monorepo]] › ℹ Plugin "@semantic-release/commit-analyzer" does not provide step "generateNotes"
87
+ [5:46:20 PM] [semantic-release] › Completed step "generateNotes" of plugin "[Function: semantic-release-monorepo]"
package/README.md CHANGED
@@ -1,3 +1,3 @@
1
1
  # Tracing
2
2
 
3
- We use this package to implement tracing within our servers
3
+ We use this package to implement tracing within our servers. Requires Sentry as our trace propogator.
package/dist/index.d.mts CHANGED
@@ -1,6 +1,5 @@
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';
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
- grpcDefaultPort?: number;
15
- httpDefaultPort?: number;
16
- host?: string;
13
+ url?: string;
14
+ protocol?: 'GRPC' | 'HTTP';
17
15
  logger?: DiagLogger;
18
- addSentry?: boolean;
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, CustomAWSXraySpanProcessor, CustomSentrySpanProcessor, type TracingConfig, nodeSDKBuilder };
21
+ export { AdditionalInstrumentation, type TracingConfig, nodeSDKBuilder };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,5 @@
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';
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
- grpcDefaultPort?: number;
15
- httpDefaultPort?: number;
16
- host?: string;
13
+ url?: string;
14
+ protocol?: 'GRPC' | 'HTTP';
17
15
  logger?: DiagLogger;
18
- addSentry?: boolean;
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, CustomAWSXraySpanProcessor, CustomSentrySpanProcessor, type TracingConfig, nodeSDKBuilder };
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 import_instrumentation_mysql2 = require("@opentelemetry/instrumentation-mysql2");
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 import_context_async_hooks = require("@opentelemetry/context-async-hooks");
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 SentryContextManager = (0, import_opentelemetry.wrapContextManagerClass)(
74
- import_context_async_hooks.AsyncLocalStorageContextManager
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
  /**
@@ -82,175 +85,103 @@ function awaitAttributes(detector) {
82
85
  var _a;
83
86
  const resource = detector.detect(config);
84
87
  await ((_a = resource.waitForAsyncAttributes) == null ? void 0 : _a.call(resource));
88
+ console.log("Detected resource: ", resource);
85
89
  return resource;
86
90
  }
87
91
  };
88
92
  }
93
+ var batchConfig = {
94
+ maxQueueSize: 4096,
95
+ maxExportBatchSize: 1e3,
96
+ scheduledDelayMillis: 1e3,
97
+ exportTimeoutMillis: 5e3
98
+ };
89
99
  async function nodeSDKBuilder(config) {
90
- var _a, _b, _c;
91
- import_api.diag.setLogger((_a = config.logger) != null ? _a : new import_api.DiagConsoleLogger(), import_api.DiagLogLevel.WARN);
100
+ var _a, _b;
101
+ config = { ...tracingDefaults, ...config };
92
102
  const _resource = import_resources.Resource.default().merge(
93
103
  new import_resources.Resource({
94
- [import_semantic_conventions.SEMRESATTRS_SERVICE_NAME]: config.serviceName,
95
- [import_semantic_conventions.SEMRESATTRS_SERVICE_VERSION]: config.release
104
+ [import_semantic_conventions.ATTR_SERVICE_NAME]: config.serviceName,
105
+ [import_semantic_conventions.ATTR_SERVICE_VERSION]: config.release
96
106
  })
97
107
  );
98
- const _traceExporter = new import_exporter_trace_otlp_grpc.OTLPTraceExporter({
108
+ const _traceExporter = config.protocol === "HTTP" ? new import_exporter_trace_otlp_http.OTLPTraceExporter({
99
109
  //collector url
100
- url: `http://${config.host}:${config.grpcDefaultPort}`
110
+ url: `${config.url}/v1/traces`
111
+ }) : new import_exporter_trace_otlp_grpc.OTLPTraceExporter({ url: config.url });
112
+ const _metricReader = new import_sdk_metrics.PeriodicExportingMetricReader({
113
+ exporter: config.protocol === "HTTP" ? new import_exporter_metrics_otlp_http.OTLPMetricExporter({
114
+ url: `${config.url}/v1/metrics`
115
+ }) : new import_exporter_metrics_otlp_grpc.OTLPMetricExporter({ url: config.url }),
116
+ // once every 60 seconds, GCP supports 1 every 5 seconds for custom metrics https://cloud.google.com/monitoring/quotas#custom_metrics_quotas
117
+ // But lets just do 60 seconds for now as we figure it out
118
+ exportIntervalMillis: 6e4
101
119
  });
102
- const _spanProcessors = [
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();
120
+ 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
121
  const instrumentations = [
118
- new import_instrumentation_aws_sdk.AwsInstrumentation({
119
- suppressInternalInstrumentation: true
120
- }),
121
- new import_instrumentation_dataloader.DataloaderInstrumentation({}),
122
- new import_instrumentation_express.ExpressInstrumentation({
123
- ignoreLayersType: [import_ExpressLayerType.ExpressLayerType.MIDDLEWARE]
124
- }),
125
- new import_instrumentation_graphql.GraphQLInstrumentation({
126
- // optional params
127
- depth: config.graphQLDepth,
128
- //query depth
129
- allowValues: true
130
- }),
131
- new import_instrumentation_http.HttpInstrumentation({
132
- ignoreIncomingPaths: ["/.well-known/apollo/server-health"]
133
- }),
134
- new import_instrumentation_mysql2.MySQL2Instrumentation({}),
135
- new import_instrumentation_net.NetInstrumentation({})
122
+ (0, import_auto_instrumentations_node.getNodeAutoInstrumentations)({
123
+ "@opentelemetry/instrumentation-fs": {
124
+ // Disabling Filesystem instrumentation because it is very noisey and memory intense.
125
+ enabled: false,
126
+ requireParentSpan: true
127
+ },
128
+ "@opentelemetry/instrumentation-undici": {
129
+ headersToSpanAttributes: {
130
+ requestHeaders: [
131
+ "sentry-trace",
132
+ "baggage",
133
+ "x-amzn-trace-id",
134
+ "encodedid",
135
+ "applicationname"
136
+ ]
137
+ }
138
+ },
139
+ "@opentelemetry/instrumentation-http": {
140
+ ignoreIncomingPaths: ["/.well-known/apollo/server-health"]
141
+ },
142
+ "@opentelemetry/instrumentation-graphql": {
143
+ ignoreTrivialResolveSpans: true
144
+ }
145
+ })
136
146
  ];
137
- ((_c = config.additionalInstrumentations) != null ? _c : []).forEach((instrumentation) => {
147
+ ((_a = config.additionalInstrumentations) != null ? _a : []).forEach((instrumentation) => {
138
148
  instrumentations.push(
139
149
  new additionalInstrumentationConstructors[instrumentation]()
140
150
  );
141
151
  });
142
152
  const sdk = new import_sdk_node.NodeSDK({
143
- textMapPropagator: config.addSentry ? new import_core.CompositePropagator({
144
- propagators: [new import_propagator_aws_xray.AWSXRayPropagator(), new import_opentelemetry.SentryPropagator()]
145
- }) : new import_propagator_aws_xray.AWSXRayPropagator(),
153
+ textMapPropagator: new import_propagator_aws_xray.AWSXRayPropagator(),
146
154
  instrumentations,
147
- contextManager: config.addSentry ? new SentryContextManager() : void 0,
155
+ sampler: config.sentry ? new import_sdk_trace_base.ParentBasedSampler({ root: new import_opentelemetry.SentrySampler(config.sentry) }) : void 0,
156
+ contextManager: new Sentry.SentryContextManager(),
148
157
  resource: _resource,
149
- spanProcessors: _spanProcessors,
150
- traceExporter: _traceExporter,
151
- idGenerator: _idGenerator,
158
+ idGenerator: new import_id_generator_aws_xray.AWSXRayIdGenerator(),
159
+ spanProcessors: [new import_sdk_trace_base.BatchSpanProcessor(_traceExporter, batchConfig)],
160
+ metricReader: _metricReader,
161
+ logRecordProcessors: [
162
+ new import_sdk_node.logs.BatchLogRecordProcessor(_logExporter, batchConfig)
163
+ ],
152
164
  // TODO: Remove after issue is fixed
153
165
  // https://github.com/open-telemetry/opentelemetry-js/issues/4638
154
166
  resourceDetectors: [
155
167
  awaitAttributes(import_resources2.envDetectorSync),
156
168
  awaitAttributes(import_resources2.hostDetectorSync),
157
- awaitAttributes(import_resources2.processDetectorSync)
169
+ awaitAttributes(import_resources2.processDetectorSync),
170
+ awaitAttributes(import_resource_detector_aws.awsEcsDetectorSync)
158
171
  ]
159
172
  });
160
173
  sdk.start();
174
+ import_api.diag.setLogger((_b = config.logger) != null ? _b : import_ts_logger.serverLogger, import_api.DiagLogLevel.WARN);
161
175
  import_api.diag.info("Tracer successfully started");
176
+ Sentry.validateOpenTelemetrySetup();
162
177
  import_process.default.on("SIGTERM", () => {
163
178
  sdk.shutdown().then(() => import_api.diag.info("Tracing and Metrics terminated")).catch(
164
179
  (error) => import_api.diag.error("Error terminating tracing and metrics", error)
165
180
  ).finally(() => import_process.default.exit(0));
166
181
  });
167
182
  }
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
183
  // Annotate the CommonJS export names for ESM import in node:
251
184
  0 && (module.exports = {
252
185
  AdditionalInstrumentation,
253
- CustomAWSXraySpanProcessor,
254
- CustomSentrySpanProcessor,
255
186
  nodeSDKBuilder
256
187
  });
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 { CompositePropagator } from "@opentelemetry/core";
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 { MySQL2Instrumentation } from "@opentelemetry/instrumentation-mysql2";
25
- import { NetInstrumentation } from "@opentelemetry/instrumentation-net";
26
- import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-grpc";
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
- SEMRESATTRS_SERVICE_NAME,
31
- SEMRESATTRS_SERVICE_VERSION
13
+ ATTR_SERVICE_NAME,
14
+ ATTR_SERVICE_VERSION
32
15
  } from "@opentelemetry/semantic-conventions";
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";
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 SentryContextManager = wrapContextManagerClass(
57
- AsyncLocalStorageContextManager
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
  /**
@@ -65,174 +59,102 @@ function awaitAttributes(detector) {
65
59
  var _a;
66
60
  const resource = detector.detect(config);
67
61
  await ((_a = resource.waitForAsyncAttributes) == null ? void 0 : _a.call(resource));
62
+ console.log("Detected resource: ", resource);
68
63
  return resource;
69
64
  }
70
65
  };
71
66
  }
67
+ var batchConfig = {
68
+ maxQueueSize: 4096,
69
+ maxExportBatchSize: 1e3,
70
+ scheduledDelayMillis: 1e3,
71
+ exportTimeoutMillis: 5e3
72
+ };
72
73
  async function nodeSDKBuilder(config) {
73
- var _a, _b, _c;
74
- diag.setLogger((_a = config.logger) != null ? _a : new DiagConsoleLogger(), DiagLogLevel.WARN);
74
+ var _a, _b;
75
+ config = { ...tracingDefaults, ...config };
75
76
  const _resource = Resource.default().merge(
76
77
  new Resource({
77
- [SEMRESATTRS_SERVICE_NAME]: config.serviceName,
78
- [SEMRESATTRS_SERVICE_VERSION]: config.release
78
+ [ATTR_SERVICE_NAME]: config.serviceName,
79
+ [ATTR_SERVICE_VERSION]: config.release
79
80
  })
80
81
  );
81
- const _traceExporter = new OTLPTraceExporter({
82
+ const _traceExporter = config.protocol === "HTTP" ? new HTTPOTLPTraceExporter({
82
83
  //collector url
83
- url: `http://${config.host}:${config.grpcDefaultPort}`
84
+ url: `${config.url}/v1/traces`
85
+ }) : new GRPCOTLPTraceExporter({ url: config.url });
86
+ const _metricReader = new PeriodicExportingMetricReader({
87
+ exporter: config.protocol === "HTTP" ? new HTTPOTLPMetricExporter({
88
+ url: `${config.url}/v1/metrics`
89
+ }) : new GRPCOTLPMetricExporter({ url: config.url }),
90
+ // once every 60 seconds, GCP supports 1 every 5 seconds for custom metrics https://cloud.google.com/monitoring/quotas#custom_metrics_quotas
91
+ // But lets just do 60 seconds for now as we figure it out
92
+ exportIntervalMillis: 6e4
84
93
  });
85
- const _spanProcessors = [
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();
94
+ const _logExporter = config.protocol === "HTTP" ? new HTTPOTLPLogExporter({ url: `${config.url}/v1/logs` }) : new GRPCOTLPLogExporter({ url: config.url });
100
95
  const instrumentations = [
101
- new AwsInstrumentation({
102
- suppressInternalInstrumentation: true
103
- }),
104
- new DataloaderInstrumentation({}),
105
- new ExpressInstrumentation({
106
- ignoreLayersType: [ExpressLayerType.MIDDLEWARE]
107
- }),
108
- new GraphQLInstrumentation({
109
- // optional params
110
- depth: config.graphQLDepth,
111
- //query depth
112
- allowValues: true
113
- }),
114
- new HttpInstrumentation({
115
- ignoreIncomingPaths: ["/.well-known/apollo/server-health"]
116
- }),
117
- new MySQL2Instrumentation({}),
118
- new NetInstrumentation({})
96
+ getNodeAutoInstrumentations({
97
+ "@opentelemetry/instrumentation-fs": {
98
+ // Disabling Filesystem instrumentation because it is very noisey and memory intense.
99
+ enabled: false,
100
+ requireParentSpan: true
101
+ },
102
+ "@opentelemetry/instrumentation-undici": {
103
+ headersToSpanAttributes: {
104
+ requestHeaders: [
105
+ "sentry-trace",
106
+ "baggage",
107
+ "x-amzn-trace-id",
108
+ "encodedid",
109
+ "applicationname"
110
+ ]
111
+ }
112
+ },
113
+ "@opentelemetry/instrumentation-http": {
114
+ ignoreIncomingPaths: ["/.well-known/apollo/server-health"]
115
+ },
116
+ "@opentelemetry/instrumentation-graphql": {
117
+ ignoreTrivialResolveSpans: true
118
+ }
119
+ })
119
120
  ];
120
- ((_c = config.additionalInstrumentations) != null ? _c : []).forEach((instrumentation) => {
121
+ ((_a = config.additionalInstrumentations) != null ? _a : []).forEach((instrumentation) => {
121
122
  instrumentations.push(
122
123
  new additionalInstrumentationConstructors[instrumentation]()
123
124
  );
124
125
  });
125
126
  const sdk = new NodeSDK({
126
- textMapPropagator: config.addSentry ? new CompositePropagator({
127
- propagators: [new AWSXRayPropagator(), new SentryPropagator()]
128
- }) : new AWSXRayPropagator(),
127
+ textMapPropagator: new AWSXRayPropagator(),
129
128
  instrumentations,
130
- contextManager: config.addSentry ? new SentryContextManager() : void 0,
129
+ sampler: config.sentry ? new ParentBasedSampler({ root: new SentrySampler(config.sentry) }) : void 0,
130
+ contextManager: new Sentry.SentryContextManager(),
131
131
  resource: _resource,
132
- spanProcessors: _spanProcessors,
133
- traceExporter: _traceExporter,
134
- idGenerator: _idGenerator,
132
+ idGenerator: new AWSXRayIdGenerator(),
133
+ spanProcessors: [new BatchSpanProcessor(_traceExporter, batchConfig)],
134
+ metricReader: _metricReader,
135
+ logRecordProcessors: [
136
+ new logs.BatchLogRecordProcessor(_logExporter, batchConfig)
137
+ ],
135
138
  // TODO: Remove after issue is fixed
136
139
  // https://github.com/open-telemetry/opentelemetry-js/issues/4638
137
140
  resourceDetectors: [
138
141
  awaitAttributes(envDetectorSync),
139
142
  awaitAttributes(hostDetectorSync),
140
- awaitAttributes(processDetectorSync)
143
+ awaitAttributes(processDetectorSync),
144
+ awaitAttributes(awsEcsDetectorSync)
141
145
  ]
142
146
  });
143
147
  sdk.start();
148
+ diag.setLogger((_b = config.logger) != null ? _b : serverLogger, DiagLogLevel.WARN);
144
149
  diag.info("Tracer successfully started");
150
+ Sentry.validateOpenTelemetrySetup();
145
151
  process.on("SIGTERM", () => {
146
152
  sdk.shutdown().then(() => diag.info("Tracing and Metrics terminated")).catch(
147
153
  (error) => diag.error("Error terminating tracing and metrics", error)
148
154
  ).finally(() => process.exit(0));
149
155
  });
150
156
  }
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
157
  export {
234
158
  AdditionalInstrumentation,
235
- CustomAWSXraySpanProcessor,
236
- CustomSentrySpanProcessor,
237
159
  nodeSDKBuilder
238
160
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pocket-tools/tracing",
3
- "version": "1.6.1",
3
+ "version": "1.7.1",
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",