@faststore/diagnostics 4.5.1-dev.4 → 4.6.0-dev.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/README.md CHANGED
@@ -17,18 +17,18 @@
17
17
  </a>
18
18
  </p>
19
19
 
20
- `@faststore/diagnostics` initializes OpenTelemetry tracing, logging, and metrics for FastStore server-side instrumentation. It is a thin wrapper around `@vtex/diagnostics-nodejs` and is consumed by `@faststore/core` via Next.js instrumentation when telemetry is enabled.
20
+ `@faststore/diagnostics` initializes OpenTelemetry tracing and logging for FastStore server-side instrumentation.
21
21
 
22
22
  ## Package structure
23
23
 
24
24
  ```text
25
25
  src/
26
- ├── globals.ts # Initializes the global fsDiagnostics state (telemetry client map, IS_DEV flag)
27
- ├── start.ts # getTelemetryClient() and getTraceClient() implementations
28
- └── index.ts # Public exports
29
- configs/
30
- ├── dev.json # Telemetry client config for development
31
- └── prod.json # Telemetry client config for production
26
+ ├── globals.ts # Initializes the global fsDiagnostics state (endpoints, sample rate, IS_DEV flag)
27
+ ├── credentials.ts # gRPC channel credentials shared by both exporters
28
+ ├── tracer.ts # Span processor and sampler
29
+ ├── logger.ts # Log record processor and the logger() emitter
30
+ ├── start.ts # getTelemetryClient() implementation
31
+ └── index.ts # Public exports
32
32
  ```
33
33
 
34
34
  ## How it works
@@ -48,26 +48,43 @@ await getTelemetryClient({
48
48
  })
49
49
  ```
50
50
 
51
- This initializes traces, logs, and metrics clients and registers HTTP instrumentation. Telemetry data is exported to an OTLP endpoint.
51
+ This starts a single `NodeSDK` per process, which registers the global tracer and logger providers and installs HTTP and Undici instrumentation. Telemetry is exported to an OTLP gRPC endpoint.
52
+
53
+ Application code emits logs through `logger()`, which resolves the provider on each call and is a no-op until the SDK has started:
54
+
55
+ ```ts
56
+ import { logger } from '@faststore/diagnostics'
57
+
58
+ const log = logger('@faststore/core')
59
+
60
+ // printf-style: arguments are only formatted when telemetry is enabled
61
+ log('error', 'Request failed: %s', reason)
62
+ ```
52
63
 
53
64
  ## Configuration
54
65
 
55
66
  | Variable | Default | Description |
56
67
  | :--- | :--- | :--- |
57
- | `OTLP_TRACES_ENDPOINT` | `localhost:4317` | OTLP gRPC endpoint for trace export |
58
- | `NODE_ENV` | — | `production` disables dev mode and uses `configs/prod.json` |
68
+ | `OTLP_TRACES_ENDPOINT` | VTEX traces collector | OTLP gRPC endpoint for trace export |
69
+ | `OTLP_LOGGER_ENDPOINT` | VTEX logs collector | OTLP gRPC endpoint for log export |
70
+ | `OTLP_TRACES_SAMPLE_RATE` | `0.3` | Fraction of traces exported outside development (development always samples everything) |
71
+ | `OTEL_EXPORTER_OTLP_COMPRESSION` | — | Set to `gzip` to compress exported payloads |
72
+ | `NODE_ENV` | — | Any value other than `production` enables dev mode |
73
+
74
+ Endpoints connect over plaintext gRPC unless the configured URL starts with `https://`.
59
75
 
60
- To enable telemetry in a store, set `analytics.otelEnabled: true` in `discovery.config.js`.
76
+ Telemetry is off until the feature is released: `@faststore/core` gates SDK startup behind `instrumentationEnabled` in `src/instrumentation.ts` and resolver spans behind `OTEL_ENABLED` in `src/server/options.ts`. See the [observability runbook](../../docs/observability.md#enabling).
61
77
 
62
78
  ## How to develop
63
79
 
64
- All logic lives in `src/start.ts` and `src/globals.ts`. To make changes:
80
+ To make changes:
65
81
 
66
82
  1. Edit the relevant file in `src/`
67
83
  2. Run `pnpm build` to compile
68
- 3. Verify via `@faststore/core` — since it's a workspace dependency, `instrumentation.ts` picks up your local build automatically
84
+ 3. Run `pnpm test` for the unit tests
85
+ 4. Verify via `@faststore/core` — since it's a workspace dependency, `instrumentation.ts` picks up your local build automatically
69
86
 
70
- > Changes are validated by running `@faststore/core` with `analytics.otelEnabled: true` and checking that traces reach the configured OTLP endpoint.
87
+ > Changes are validated by running `@faststore/core` with both gating flags set to `true` and checking that traces and logs reach the configured OTLP endpoints.
71
88
 
72
89
  ## How to run
73
90
 
@@ -92,7 +109,5 @@ Versioning and publishing are managed at the monorepo root by Lerna. Do not publ
92
109
 
93
110
  ## Documentation
94
111
 
95
- - **Sampling config (dev):** [`configs/dev.json`](./configs/dev.json) — 100% sample rate
96
- - **Sampling config (prod):** [`configs/prod.json`](./configs/prod.json) — 1% default, 30% for `trace_all`
97
- - **Upstream library:** [@vtex/diagnostics-nodejs](https://www.npmjs.com/package/@vtex/diagnostics-nodejs)
112
+ - **Observability runbook:** [`docs/observability.md`](../../docs/observability.md)
98
113
  - **OpenTelemetry:** [opentelemetry.io](https://opentelemetry.io)
package/dist/cjs/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("@opentelemetry/api"),a=require("@vtex/diagnostics-nodejs/dist/exporters/index.js"),i=require("@vtex/diagnostics-nodejs/dist/telemetry/client.js"),c=require("@opentelemetry/instrumentation-http"),l=require("resolve-pkg");function g(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,s.get?s:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const E=g(r);globalThis.fsDiagnostics??={IS_DEV:process.env.NODE_ENV!=="production",TELEMETRY_CLIENTS:new Map,TRACE_CLIENTS:new Map};const T="@faststore/diagnostics";async function u(){const e=process.env.OTLP_TRACES_ENDPOINT||"localhost:4317",t=a.CreateTracesExporterConfig({endpoint:e,insecure:global.fsDiagnostics.IS_DEV??!1}),n=a.CreateExporter(t,"otlp");return await n.initialize(),n}async function f(e){if(global.fsDiagnostics.TELEMETRY_CLIENTS.has(e.packageName))return global.fsDiagnostics.TELEMETRY_CLIENTS.get(e.packageName);const t=await i.NewTelemetryClient(T,e.clientName,e.serviceName,{additionalAttrs:{"@faststore_version":e.version,"@faststore_package_name":e.packageName,"@faststore_account_name":e.account??"unknown","@faststore_environment":process.env.NODE_ENV??"development"},config:{configPath:l(`@faststore/diagnostics/configs/${global.fsDiagnostics.IS_DEV?"dev":"prod"}.json`,{cwd:process.env.PWD??process.cwd()})}}),n=await u(),s=await t.newLogsClient(),o=await t.newMetricsClient();return global.fsDiagnostics.TRACE_CLIENTS.set(e.packageName,await t.newTracesClient({setGlobalProvider:!0,exporter:n})),t.registerInstrumentations([new c.HttpInstrumentation]),await s.shutdown(),await o.shutdown(),global.fsDiagnostics.IS_DEV&&console.log("TELEMETRY CLIENT STARTED",e),global.fsDiagnostics.TELEMETRY_CLIENTS.set(e.packageName,t),t}function _(e){return global.fsDiagnostics.TRACE_CLIENTS.get(e)}exports.OTELAPI=E;exports.getTelemetryClient=f;exports.getTraceClient=_;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("@opentelemetry/api"),s=require("@opentelemetry/api-logs"),u=require("@opentelemetry/exporter-logs-otlp-grpc"),E=require("@opentelemetry/sdk-logs"),T=require("node:util"),i=require("@grpc/grpc-js"),g=require("@opentelemetry/instrumentation-http"),p=require("@opentelemetry/instrumentation-undici"),m=require("@opentelemetry/resources"),_=require("@opentelemetry/sdk-node"),d=require("@opentelemetry/exporter-trace-otlp-grpc"),n=require("@opentelemetry/sdk-trace-node");function N(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,o.get?o:{enumerable:!0,get:()=>e[t]})}}return r.default=e,Object.freeze(r)}const L=N(l),f="traces-grpc-faststore-pvl.opentelemetry-collector.vtex.systems:80",O="logs-developer-fluentd-faststore-pvl.opentelemetry-collector.vtex.systems",R=.3,S=(e,r)=>{if(!e)return r;const t=Number(e);return Number.isFinite(t)&&t>=0&&t<=1?t:r};globalThis.fsDiagnostics??={IS_DEV:process.env.NODE_ENV!=="production",TELEMETRY_CLIENT:void 0,OTLP_TRACES_ENDPOINT:process.env.OTLP_TRACES_ENDPOINT||f,OTLP_LOGGER_ENDPOINT:process.env.OTLP_LOGGER_ENDPOINT||O,OTLP_TRACES_SAMPLE_RATE:S(process.env.OTLP_TRACES_SAMPLE_RATE,R)};function a(e){return e.startsWith("https://")?i.credentials.createSsl():i.credentials.createInsecure()}function D(){const e=globalThis.fsDiagnostics.OTLP_LOGGER_ENDPOINT;return new E.BatchLogRecordProcessor(new u.OTLPLogExporter({credentials:a(e),url:e}))}const c={error:{number:s.SeverityNumber.ERROR,text:"ERROR"},warn:{number:s.SeverityNumber.WARN,text:"WARN"},info:{number:s.SeverityNumber.INFO,text:"INFO"},debug:{number:s.SeverityNumber.DEBUG,text:"DEBUG"}};function b(e){return(r,...t)=>{globalThis.fsDiagnostics.TELEMETRY_CLIENT&&s.logs.getLogger(e).emit({severityNumber:c[r].number,severityText:c[r].text,body:T.format(...t)})}}function P(){const e=globalThis.fsDiagnostics.OTLP_TRACES_ENDPOINT,r=new d.OTLPTraceExporter({credentials:a(e),url:e});return new n.BatchSpanProcessor(r,{maxQueueSize:2048,maxExportBatchSize:512,scheduledDelayMillis:5e3,exportTimeoutMillis:3e4})}function v(){const e=globalThis.fsDiagnostics.IS_DEV?1:globalThis.fsDiagnostics.OTLP_TRACES_SAMPLE_RATE;return new n.ParentBasedSampler({root:new n.TraceIdRatioBasedSampler(e)})}async function I(e){if(globalThis.fsDiagnostics.TELEMETRY_CLIENT)return globalThis.fsDiagnostics.TELEMETRY_CLIENT;const r=m.resourceFromAttributes({"service.name":e.serviceName,"service.version":e.version,"vtex.account.name":e.account??"unknown","vtex.application.id":e.serviceName,"vtex.diagnostics.name":"faststore_custom","@faststore_version":e.version,"@faststore_package_name":e.packageName,"@faststore_account_name":e.account??"unknown","@faststore_environment":process.env.NODE_ENV??"development"}),t=new _.NodeSDK({resource:r,sampler:v(),spanProcessors:[P()],logRecordProcessors:[D()],instrumentations:[new g.HttpInstrumentation,new p.UndiciInstrumentation]});return t.start(),globalThis.fsDiagnostics.TELEMETRY_CLIENT=t,A(t),globalThis.fsDiagnostics.IS_DEV&&console.log("TELEMETRY CLIENT STARTED",e),t}function A(e){process.once("SIGTERM",()=>{e.shutdown().catch(r=>console.error("Error shutting down OTel SDK",r)).finally(()=>process.kill(process.pid,"SIGTERM"))})}exports.OTELAPI=L;exports.getTelemetryClient=I;exports.logger=b;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/globals.ts","../../src/start.ts"],"sourcesContent":["globalThis.fsDiagnostics ??= {\n IS_DEV: import.meta.env.DEV === true || process.env.NODE_ENV !== 'production',\n TELEMETRY_CLIENTS: new Map(),\n TRACE_CLIENTS: new Map(),\n}\n","import {\n CreateTracesExporterConfig,\n CreateExporter,\n} from '@vtex/diagnostics-nodejs/dist/exporters/index.js'\nimport { NewTelemetryClient } from '@vtex/diagnostics-nodejs/dist/telemetry/client.js'\nimport { HttpInstrumentation } from '@opentelemetry/instrumentation-http'\nimport resolvePackage from 'resolve-pkg'\n\nimport { name as currentPkgName } from '../package.json' with { type: 'json' }\n\nasync function setupTracesExporter() {\n const OTLP_TRACES_ENDPOINT =\n process.env.OTLP_TRACES_ENDPOINT || 'localhost:4317'\n\n const tracesConfig = CreateTracesExporterConfig({\n endpoint: OTLP_TRACES_ENDPOINT,\n insecure: global.fsDiagnostics.IS_DEV ?? false,\n })\n\n const tracesExporter = CreateExporter(tracesConfig, 'otlp')\n await tracesExporter.initialize()\n return tracesExporter\n}\n\nexport async function getTelemetryClient(opt: {\n serviceName: string\n version: string\n clientName: string\n account: string\n packageName: string\n}) {\n if (global.fsDiagnostics.TELEMETRY_CLIENTS.has(opt.packageName))\n return global.fsDiagnostics.TELEMETRY_CLIENTS.get(opt.packageName)\n\n const client = await NewTelemetryClient(\n currentPkgName,\n opt.clientName,\n opt.serviceName,\n {\n additionalAttrs: {\n '@faststore_version': opt.version,\n '@faststore_package_name': opt.packageName,\n '@faststore_account_name': opt.account ?? 'unknown',\n '@faststore_environment': process.env.NODE_ENV ?? 'development',\n },\n // debug: global.fsDiagnostics.IS_DEV,\n config: {\n configPath: resolvePackage(\n `@faststore/diagnostics/configs/${global.fsDiagnostics.IS_DEV ? 'dev' : 'prod'}.json`,\n {\n cwd: process.env.PWD ?? process.cwd(),\n }\n ),\n },\n }\n )\n\n const tracesExporter = await setupTracesExporter()\n const logger = await client.newLogsClient()\n const metrics = await client.newMetricsClient()\n\n global.fsDiagnostics.TRACE_CLIENTS.set(\n opt.packageName,\n await client.newTracesClient({\n setGlobalProvider: true,\n exporter: tracesExporter,\n })\n )\n\n client.registerInstrumentations([new HttpInstrumentation()])\n\n await logger.shutdown()\n await metrics.shutdown()\n\n if (global.fsDiagnostics.IS_DEV) console.log('TELEMETRY CLIENT STARTED', opt)\n\n global.fsDiagnostics.TELEMETRY_CLIENTS.set(opt.packageName, client)\n return client\n}\n\nexport function getTraceClient(serviceName: string) {\n return global.fsDiagnostics.TRACE_CLIENTS.get(serviceName)\n}\n"],"names":["setupTracesExporter","OTLP_TRACES_ENDPOINT","tracesConfig","CreateTracesExporterConfig","tracesExporter","CreateExporter","getTelemetryClient","opt","client","NewTelemetryClient","currentPkgName","resolvePackage","logger","metrics","HttpInstrumentation","getTraceClient","serviceName"],"mappings":"ulBAAA,WAAW,gBAAkB,CAC3B,OAAwC,QAAQ,IAAI,WAAa,aACjE,sBAAuB,IACvB,kBAAmB,GACrB,mCCMA,eAAeA,GAAsB,CACnC,MAAMC,EACJ,QAAQ,IAAI,sBAAwB,iBAEhCC,EAAeC,EAAAA,2BAA2B,CAC9C,SAAUF,EACV,SAAU,OAAO,cAAc,QAAU,EAAA,CAC1C,EAEKG,EAAiBC,EAAAA,eAAeH,EAAc,MAAM,EAC1D,aAAME,EAAe,WAAA,EACdA,CACT,CAEA,eAAsBE,EAAmBC,EAMtC,CACD,GAAI,OAAO,cAAc,kBAAkB,IAAIA,EAAI,WAAW,EAC5D,OAAO,OAAO,cAAc,kBAAkB,IAAIA,EAAI,WAAW,EAEnE,MAAMC,EAAS,MAAMC,EAAAA,mBACnBC,EACAH,EAAI,WACJA,EAAI,YACJ,CACE,gBAAiB,CACf,qBAAsBA,EAAI,QAC1B,0BAA2BA,EAAI,YAC/B,0BAA2BA,EAAI,SAAW,UAC1C,yBAA0B,QAAQ,IAAI,UAAY,aAAA,EAGpD,OAAQ,CACN,WAAYI,EACV,kCAAkC,OAAO,cAAc,OAAS,MAAQ,MAAM,QAC9E,CACE,IAAK,QAAQ,IAAI,KAAO,QAAQ,IAAA,CAAI,CACtC,CACF,CACF,CACF,EAGIP,EAAiB,MAAMJ,EAAA,EACvBY,EAAS,MAAMJ,EAAO,cAAA,EACtBK,EAAU,MAAML,EAAO,iBAAA,EAE7B,cAAO,cAAc,cAAc,IACjCD,EAAI,YACJ,MAAMC,EAAO,gBAAgB,CAC3B,kBAAmB,GACnB,SAAUJ,CAAA,CACX,CAAA,EAGHI,EAAO,yBAAyB,CAAC,IAAIM,EAAAA,mBAAqB,CAAC,EAE3D,MAAMF,EAAO,SAAA,EACb,MAAMC,EAAQ,SAAA,EAEV,OAAO,cAAc,QAAQ,QAAQ,IAAI,2BAA4BN,CAAG,EAE5E,OAAO,cAAc,kBAAkB,IAAIA,EAAI,YAAaC,CAAM,EAC3DA,CACT,CAEO,SAASO,EAAeC,EAAqB,CAClD,OAAO,OAAO,cAAc,cAAc,IAAIA,CAAW,CAC3D"}
1
+ {"version":3,"file":"index.js","sources":["../../src/globals.ts","../../src/credentials.ts","../../src/logger.ts","../../src/tracer.ts","../../src/start.ts"],"sourcesContent":["const DEFAULT_TRACES_ENDPOINT =\n 'traces-grpc-faststore-pvl.opentelemetry-collector.vtex.systems:80'\nconst DEFAULT_LOGGER_ENDPOINT =\n 'logs-developer-fluentd-faststore-pvl.opentelemetry-collector.vtex.systems'\n\n/** Fraction of traces exported when telemetry is enabled outside development. */\nconst DEFAULT_TRACES_SAMPLE_RATE = 0.3\n\nconst parseSampleRate = (value: string | undefined, fallback: number) => {\n if (!value) {\n return fallback\n }\n\n const parsed = Number(value)\n\n return Number.isFinite(parsed) && parsed >= 0 && parsed <= 1\n ? parsed\n : fallback\n}\n\nglobalThis.fsDiagnostics ??= {\n IS_DEV: process.env.NODE_ENV !== 'production',\n TELEMETRY_CLIENT: undefined,\n OTLP_TRACES_ENDPOINT:\n process.env.OTLP_TRACES_ENDPOINT || DEFAULT_TRACES_ENDPOINT,\n OTLP_LOGGER_ENDPOINT:\n process.env.OTLP_LOGGER_ENDPOINT || DEFAULT_LOGGER_ENDPOINT,\n OTLP_TRACES_SAMPLE_RATE: parseSampleRate(\n process.env.OTLP_TRACES_SAMPLE_RATE,\n DEFAULT_TRACES_SAMPLE_RATE\n ),\n}\n","import { type ChannelCredentials, credentials } from '@grpc/grpc-js'\n\n/**\n * The VTEX collectors are reached over plaintext gRPC (port 80), so transport\n * security is opt-in via an explicit `https://` endpoint rather than inferred\n * from the environment.\n */\nexport function createChannelCredentials(endpoint: string): ChannelCredentials {\n return endpoint.startsWith('https://')\n ? credentials.createSsl()\n : credentials.createInsecure()\n}\n","import { SeverityNumber, logs } from '@opentelemetry/api-logs'\nimport { OTLPLogExporter } from '@opentelemetry/exporter-logs-otlp-grpc'\nimport { BatchLogRecordProcessor } from '@opentelemetry/sdk-logs'\nimport { format } from 'node:util'\nimport { createChannelCredentials } from './credentials'\n\nexport function getLoggerExporter() {\n const endpoint = globalThis.fsDiagnostics.OTLP_LOGGER_ENDPOINT\n\n return new BatchLogRecordProcessor(\n new OTLPLogExporter({\n credentials: createChannelCredentials(endpoint),\n url: endpoint,\n })\n )\n}\n\nconst SEVERITY = {\n error: { number: SeverityNumber.ERROR, text: 'ERROR' },\n warn: { number: SeverityNumber.WARN, text: 'WARN' },\n info: { number: SeverityNumber.INFO, text: 'INFO' },\n debug: { number: SeverityNumber.DEBUG, text: 'DEBUG' },\n} as const\n\nexport type LogSeverity = keyof typeof SEVERITY\n\n/**\n * Builds a `util.format`-style emitter for the given instrumentation scope.\n *\n * The underlying provider is resolved on every call because callers hold these\n * emitters in module-level constants, which are evaluated before\n * `getTelemetryClient` installs the provider. Formatting is deferred until a\n * provider exists so disabled telemetry costs nothing on hot paths — pass\n * printf-style arguments rather than pre-built template strings.\n */\nexport function logger(name: string) {\n return (severity: LogSeverity, ...args: unknown[]) => {\n if (!globalThis.fsDiagnostics.TELEMETRY_CLIENT) {\n return\n }\n\n logs.getLogger(name).emit({\n severityNumber: SEVERITY[severity].number,\n severityText: SEVERITY[severity].text,\n body: format(...args),\n })\n }\n}\n","import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-grpc'\nimport {\n BatchSpanProcessor,\n ParentBasedSampler,\n type Sampler,\n TraceIdRatioBasedSampler,\n} from '@opentelemetry/sdk-trace-node'\nimport { createChannelCredentials } from './credentials'\n\n/**\n * Payload compression follows the standard `OTEL_EXPORTER_OTLP_COMPRESSION`\n * environment variable (set it to `gzip` to reduce egress).\n */\nexport function traceExporter() {\n const endpoint = globalThis.fsDiagnostics.OTLP_TRACES_ENDPOINT\n\n const collectorExporter = new OTLPTraceExporter({\n credentials: createChannelCredentials(endpoint),\n url: endpoint,\n })\n\n return new BatchSpanProcessor(collectorExporter, {\n maxQueueSize: 2048,\n maxExportBatchSize: 512,\n scheduledDelayMillis: 5000,\n exportTimeoutMillis: 30_000,\n })\n}\n\n/**\n * Development traces everything; elsewhere a ratio sampler keeps export volume\n * (and collector cost) bounded. Parent-based so a sampled request keeps all of\n * its child spans instead of producing partial traces.\n */\nexport function traceSampler(): Sampler {\n const ratio = globalThis.fsDiagnostics.IS_DEV\n ? 1\n : globalThis.fsDiagnostics.OTLP_TRACES_SAMPLE_RATE\n\n return new ParentBasedSampler({ root: new TraceIdRatioBasedSampler(ratio) })\n}\n","import { HttpInstrumentation } from '@opentelemetry/instrumentation-http'\nimport { UndiciInstrumentation } from '@opentelemetry/instrumentation-undici'\nimport { resourceFromAttributes } from '@opentelemetry/resources'\nimport { NodeSDK } from '@opentelemetry/sdk-node'\nimport { getLoggerExporter } from './logger'\nimport { traceExporter, traceSampler } from './tracer'\n\nexport interface TelemetryOptions {\n serviceName: string\n version: string\n clientName: string\n account: string\n packageName: string\n}\n\n/**\n * Boots the OpenTelemetry SDK once per process and registers it globally, so\n * `logger()` and `OTELAPI.trace` pick it up. Repeat calls return the running\n * instance, which also keeps Next.js hot-module-reload from starting a second\n * exporter in development.\n */\nexport async function getTelemetryClient(opt: TelemetryOptions) {\n if (globalThis.fsDiagnostics.TELEMETRY_CLIENT) {\n return globalThis.fsDiagnostics.TELEMETRY_CLIENT\n }\n\n const resource = resourceFromAttributes({\n 'service.name': opt.serviceName,\n 'service.version': opt.version,\n 'vtex.account.name': opt.account ?? 'unknown',\n 'vtex.application.id': opt.serviceName,\n 'vtex.diagnostics.name': 'faststore_custom',\n '@faststore_version': opt.version,\n '@faststore_package_name': opt.packageName,\n '@faststore_account_name': opt.account ?? 'unknown',\n '@faststore_environment': process.env.NODE_ENV ?? 'development',\n })\n\n // NodeSDK owns both pipelines: it installs the global tracer provider and,\n // via `logRecordProcessors`, the global logger provider that `logger()` reads.\n const sdk = new NodeSDK({\n resource,\n sampler: traceSampler(),\n spanProcessors: [traceExporter()],\n logRecordProcessors: [getLoggerExporter()],\n instrumentations: [new HttpInstrumentation(), new UndiciInstrumentation()],\n })\n\n sdk.start()\n globalThis.fsDiagnostics.TELEMETRY_CLIENT = sdk\n\n registerShutdownHook(sdk)\n\n if (globalThis.fsDiagnostics.IS_DEV) {\n console.log('TELEMETRY CLIENT STARTED', opt)\n }\n\n return sdk\n}\n\n/**\n * Flushes pending spans and logs on SIGTERM. Registering a listener suppresses\n * Node's default termination, so the signal is re-raised once the listener has\n * been removed instead of forcing `process.exit` on the host application.\n */\nfunction registerShutdownHook(sdk: NodeSDK) {\n process.once('SIGTERM', () => {\n sdk\n .shutdown()\n .catch((error) => console.error('Error shutting down OTel SDK', error))\n .finally(() => process.kill(process.pid, 'SIGTERM'))\n })\n}\n"],"names":["DEFAULT_TRACES_ENDPOINT","DEFAULT_LOGGER_ENDPOINT","DEFAULT_TRACES_SAMPLE_RATE","parseSampleRate","value","fallback","parsed","createChannelCredentials","endpoint","credentials","getLoggerExporter","BatchLogRecordProcessor","OTLPLogExporter","SEVERITY","SeverityNumber","logger","name","severity","args","logs","format","traceExporter","collectorExporter","OTLPTraceExporter","BatchSpanProcessor","traceSampler","ratio","ParentBasedSampler","TraceIdRatioBasedSampler","getTelemetryClient","opt","resource","resourceFromAttributes","sdk","NodeSDK","HttpInstrumentation","UndiciInstrumentation","registerShutdownHook","error"],"mappings":"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"}
@@ -0,0 +1,8 @@
1
+ import { ChannelCredentials } from '@grpc/grpc-js';
2
+ /**
3
+ * The VTEX collectors are reached over plaintext gRPC (port 80), so transport
4
+ * security is opt-in via an explicit `https://` endpoint rather than inferred
5
+ * from the environment.
6
+ */
7
+ export declare function createChannelCredentials(endpoint: string): ChannelCredentials;
8
+ //# sourceMappingURL=credentials.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../src/credentials.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,kBAAkB,EAAe,MAAM,eAAe,CAAA;AAEpE;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,GAAG,kBAAkB,CAI7E"}
package/dist/es/index.mjs CHANGED
@@ -1,59 +1,103 @@
1
- import * as T from "@opentelemetry/api";
2
- import { CreateTracesExporterConfig as o, CreateExporter as i } from "@vtex/diagnostics-nodejs/dist/exporters/index.js";
3
- import { NewTelemetryClient as r } from "@vtex/diagnostics-nodejs/dist/telemetry/client.js";
4
- import { HttpInstrumentation as c } from "@opentelemetry/instrumentation-http";
5
- import E from "resolve-pkg";
1
+ import * as v from "@opentelemetry/api";
2
+ import { SeverityNumber as o, logs as c } from "@opentelemetry/api-logs";
3
+ import { OTLPLogExporter as a } from "@opentelemetry/exporter-logs-otlp-grpc";
4
+ import { BatchLogRecordProcessor as E } from "@opentelemetry/sdk-logs";
5
+ import { format as T } from "node:util";
6
+ import { credentials as s } from "@grpc/grpc-js";
7
+ import { HttpInstrumentation as l } from "@opentelemetry/instrumentation-http";
8
+ import { UndiciInstrumentation as m } from "@opentelemetry/instrumentation-undici";
9
+ import { resourceFromAttributes as u } from "@opentelemetry/resources";
10
+ import { NodeSDK as p } from "@opentelemetry/sdk-node";
11
+ import { OTLPTraceExporter as _ } from "@opentelemetry/exporter-trace-otlp-grpc";
12
+ import { BatchSpanProcessor as f, ParentBasedSampler as g, TraceIdRatioBasedSampler as L } from "@opentelemetry/sdk-trace-node";
13
+ const N = "traces-grpc-faststore-pvl.opentelemetry-collector.vtex.systems:80", R = "logs-developer-fluentd-faststore-pvl.opentelemetry-collector.vtex.systems", D = 0.3, O = (e, r) => {
14
+ if (!e)
15
+ return r;
16
+ const t = Number(e);
17
+ return Number.isFinite(t) && t >= 0 && t <= 1 ? t : r;
18
+ };
6
19
  globalThis.fsDiagnostics ??= {
7
20
  IS_DEV: process.env.NODE_ENV !== "production",
8
- TELEMETRY_CLIENTS: /* @__PURE__ */ new Map(),
9
- TRACE_CLIENTS: /* @__PURE__ */ new Map()
21
+ TELEMETRY_CLIENT: void 0,
22
+ OTLP_TRACES_ENDPOINT: process.env.OTLP_TRACES_ENDPOINT || N,
23
+ OTLP_LOGGER_ENDPOINT: process.env.OTLP_LOGGER_ENDPOINT || R,
24
+ OTLP_TRACES_SAMPLE_RATE: O(
25
+ process.env.OTLP_TRACES_SAMPLE_RATE,
26
+ D
27
+ )
10
28
  };
11
- const g = "@faststore/diagnostics";
12
- async function l() {
13
- const e = process.env.OTLP_TRACES_ENDPOINT || "localhost:4317", t = o({
14
- endpoint: e,
15
- insecure: global.fsDiagnostics.IS_DEV ?? !1
16
- }), s = i(t, "otlp");
17
- return await s.initialize(), s;
29
+ function i(e) {
30
+ return e.startsWith("https://") ? s.createSsl() : s.createInsecure();
18
31
  }
19
- async function C(e) {
20
- if (global.fsDiagnostics.TELEMETRY_CLIENTS.has(e.packageName))
21
- return global.fsDiagnostics.TELEMETRY_CLIENTS.get(e.packageName);
22
- const t = await r(
23
- g,
24
- e.clientName,
25
- e.serviceName,
26
- {
27
- additionalAttrs: {
28
- "@faststore_version": e.version,
29
- "@faststore_package_name": e.packageName,
30
- "@faststore_account_name": e.account ?? "unknown",
31
- "@faststore_environment": process.env.NODE_ENV ?? "development"
32
- },
33
- // debug: global.fsDiagnostics.IS_DEV,
34
- config: {
35
- configPath: E(
36
- `@faststore/diagnostics/configs/${global.fsDiagnostics.IS_DEV ? "dev" : "prod"}.json`,
37
- {
38
- cwd: process.env.PWD ?? process.cwd()
39
- }
40
- )
41
- }
42
- }
43
- ), s = await l(), a = await t.newLogsClient(), n = await t.newMetricsClient();
44
- return global.fsDiagnostics.TRACE_CLIENTS.set(
45
- e.packageName,
46
- await t.newTracesClient({
47
- setGlobalProvider: !0,
48
- exporter: s
32
+ function S() {
33
+ const e = globalThis.fsDiagnostics.OTLP_LOGGER_ENDPOINT;
34
+ return new E(
35
+ new a({
36
+ credentials: i(e),
37
+ url: e
49
38
  })
50
- ), t.registerInstrumentations([new c()]), await a.shutdown(), await n.shutdown(), global.fsDiagnostics.IS_DEV && console.log("TELEMETRY CLIENT STARTED", e), global.fsDiagnostics.TELEMETRY_CLIENTS.set(e.packageName, t), t;
39
+ );
40
+ }
41
+ const n = {
42
+ error: { number: o.ERROR, text: "ERROR" },
43
+ warn: { number: o.WARN, text: "WARN" },
44
+ info: { number: o.INFO, text: "INFO" },
45
+ debug: { number: o.DEBUG, text: "DEBUG" }
46
+ };
47
+ function Y(e) {
48
+ return (r, ...t) => {
49
+ globalThis.fsDiagnostics.TELEMETRY_CLIENT && c.getLogger(e).emit({
50
+ severityNumber: n[r].number,
51
+ severityText: n[r].text,
52
+ body: T(...t)
53
+ });
54
+ };
55
+ }
56
+ function d() {
57
+ const e = globalThis.fsDiagnostics.OTLP_TRACES_ENDPOINT, r = new _({
58
+ credentials: i(e),
59
+ url: e
60
+ });
61
+ return new f(r, {
62
+ maxQueueSize: 2048,
63
+ maxExportBatchSize: 512,
64
+ scheduledDelayMillis: 5e3,
65
+ exportTimeoutMillis: 3e4
66
+ });
67
+ }
68
+ function P() {
69
+ const e = globalThis.fsDiagnostics.IS_DEV ? 1 : globalThis.fsDiagnostics.OTLP_TRACES_SAMPLE_RATE;
70
+ return new g({ root: new L(e) });
71
+ }
72
+ async function k(e) {
73
+ if (globalThis.fsDiagnostics.TELEMETRY_CLIENT)
74
+ return globalThis.fsDiagnostics.TELEMETRY_CLIENT;
75
+ const r = u({
76
+ "service.name": e.serviceName,
77
+ "service.version": e.version,
78
+ "vtex.account.name": e.account ?? "unknown",
79
+ "vtex.application.id": e.serviceName,
80
+ "vtex.diagnostics.name": "faststore_custom",
81
+ "@faststore_version": e.version,
82
+ "@faststore_package_name": e.packageName,
83
+ "@faststore_account_name": e.account ?? "unknown",
84
+ "@faststore_environment": process.env.NODE_ENV ?? "development"
85
+ }), t = new p({
86
+ resource: r,
87
+ sampler: P(),
88
+ spanProcessors: [d()],
89
+ logRecordProcessors: [S()],
90
+ instrumentations: [new l(), new m()]
91
+ });
92
+ return t.start(), globalThis.fsDiagnostics.TELEMETRY_CLIENT = t, I(t), globalThis.fsDiagnostics.IS_DEV && console.log("TELEMETRY CLIENT STARTED", e), t;
51
93
  }
52
- function _(e) {
53
- return global.fsDiagnostics.TRACE_CLIENTS.get(e);
94
+ function I(e) {
95
+ process.once("SIGTERM", () => {
96
+ e.shutdown().catch((r) => console.error("Error shutting down OTel SDK", r)).finally(() => process.kill(process.pid, "SIGTERM"));
97
+ });
54
98
  }
55
99
  export {
56
- T as OTELAPI,
57
- C as getTelemetryClient,
58
- _ as getTraceClient
100
+ v as OTELAPI,
101
+ k as getTelemetryClient,
102
+ Y as logger
59
103
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../src/globals.ts","../../src/start.ts"],"sourcesContent":["globalThis.fsDiagnostics ??= {\n IS_DEV: import.meta.env.DEV === true || process.env.NODE_ENV !== 'production',\n TELEMETRY_CLIENTS: new Map(),\n TRACE_CLIENTS: new Map(),\n}\n","import {\n CreateTracesExporterConfig,\n CreateExporter,\n} from '@vtex/diagnostics-nodejs/dist/exporters/index.js'\nimport { NewTelemetryClient } from '@vtex/diagnostics-nodejs/dist/telemetry/client.js'\nimport { HttpInstrumentation } from '@opentelemetry/instrumentation-http'\nimport resolvePackage from 'resolve-pkg'\n\nimport { name as currentPkgName } from '../package.json' with { type: 'json' }\n\nasync function setupTracesExporter() {\n const OTLP_TRACES_ENDPOINT =\n process.env.OTLP_TRACES_ENDPOINT || 'localhost:4317'\n\n const tracesConfig = CreateTracesExporterConfig({\n endpoint: OTLP_TRACES_ENDPOINT,\n insecure: global.fsDiagnostics.IS_DEV ?? false,\n })\n\n const tracesExporter = CreateExporter(tracesConfig, 'otlp')\n await tracesExporter.initialize()\n return tracesExporter\n}\n\nexport async function getTelemetryClient(opt: {\n serviceName: string\n version: string\n clientName: string\n account: string\n packageName: string\n}) {\n if (global.fsDiagnostics.TELEMETRY_CLIENTS.has(opt.packageName))\n return global.fsDiagnostics.TELEMETRY_CLIENTS.get(opt.packageName)\n\n const client = await NewTelemetryClient(\n currentPkgName,\n opt.clientName,\n opt.serviceName,\n {\n additionalAttrs: {\n '@faststore_version': opt.version,\n '@faststore_package_name': opt.packageName,\n '@faststore_account_name': opt.account ?? 'unknown',\n '@faststore_environment': process.env.NODE_ENV ?? 'development',\n },\n // debug: global.fsDiagnostics.IS_DEV,\n config: {\n configPath: resolvePackage(\n `@faststore/diagnostics/configs/${global.fsDiagnostics.IS_DEV ? 'dev' : 'prod'}.json`,\n {\n cwd: process.env.PWD ?? process.cwd(),\n }\n ),\n },\n }\n )\n\n const tracesExporter = await setupTracesExporter()\n const logger = await client.newLogsClient()\n const metrics = await client.newMetricsClient()\n\n global.fsDiagnostics.TRACE_CLIENTS.set(\n opt.packageName,\n await client.newTracesClient({\n setGlobalProvider: true,\n exporter: tracesExporter,\n })\n )\n\n client.registerInstrumentations([new HttpInstrumentation()])\n\n await logger.shutdown()\n await metrics.shutdown()\n\n if (global.fsDiagnostics.IS_DEV) console.log('TELEMETRY CLIENT STARTED', opt)\n\n global.fsDiagnostics.TELEMETRY_CLIENTS.set(opt.packageName, client)\n return client\n}\n\nexport function getTraceClient(serviceName: string) {\n return global.fsDiagnostics.TRACE_CLIENTS.get(serviceName)\n}\n"],"names":["setupTracesExporter","OTLP_TRACES_ENDPOINT","tracesConfig","CreateTracesExporterConfig","tracesExporter","CreateExporter","getTelemetryClient","opt","client","NewTelemetryClient","currentPkgName","resolvePackage","logger","metrics","HttpInstrumentation","getTraceClient","serviceName"],"mappings":";;;;;AAAA,WAAW,kBAAkB;AAAA,EAC3B,QAAwC,QAAQ,IAAI,aAAa;AAAA,EACjE,uCAAuB,IAAA;AAAA,EACvB,mCAAmB,IAAA;AACrB;;ACMA,eAAeA,IAAsB;AACnC,QAAMC,IACJ,QAAQ,IAAI,wBAAwB,kBAEhCC,IAAeC,EAA2B;AAAA,IAC9C,UAAUF;AAAA,IACV,UAAU,OAAO,cAAc,UAAU;AAAA,EAAA,CAC1C,GAEKG,IAAiBC,EAAeH,GAAc,MAAM;AAC1D,eAAME,EAAe,WAAA,GACdA;AACT;AAEA,eAAsBE,EAAmBC,GAMtC;AACD,MAAI,OAAO,cAAc,kBAAkB,IAAIA,EAAI,WAAW;AAC5D,WAAO,OAAO,cAAc,kBAAkB,IAAIA,EAAI,WAAW;AAEnE,QAAMC,IAAS,MAAMC;AAAA,IACnBC;AAAAA,IACAH,EAAI;AAAA,IACJA,EAAI;AAAA,IACJ;AAAA,MACE,iBAAiB;AAAA,QACf,sBAAsBA,EAAI;AAAA,QAC1B,2BAA2BA,EAAI;AAAA,QAC/B,2BAA2BA,EAAI,WAAW;AAAA,QAC1C,0BAA0B,QAAQ,IAAI,YAAY;AAAA,MAAA;AAAA;AAAA,MAGpD,QAAQ;AAAA,QACN,YAAYI;AAAA,UACV,kCAAkC,OAAO,cAAc,SAAS,QAAQ,MAAM;AAAA,UAC9E;AAAA,YACE,KAAK,QAAQ,IAAI,OAAO,QAAQ,IAAA;AAAA,UAAI;AAAA,QACtC;AAAA,MACF;AAAA,IACF;AAAA,EACF,GAGIP,IAAiB,MAAMJ,EAAA,GACvBY,IAAS,MAAMJ,EAAO,cAAA,GACtBK,IAAU,MAAML,EAAO,iBAAA;AAE7B,gBAAO,cAAc,cAAc;AAAA,IACjCD,EAAI;AAAA,IACJ,MAAMC,EAAO,gBAAgB;AAAA,MAC3B,mBAAmB;AAAA,MACnB,UAAUJ;AAAA,IAAA,CACX;AAAA,EAAA,GAGHI,EAAO,yBAAyB,CAAC,IAAIM,EAAA,CAAqB,CAAC,GAE3D,MAAMF,EAAO,SAAA,GACb,MAAMC,EAAQ,SAAA,GAEV,OAAO,cAAc,UAAQ,QAAQ,IAAI,4BAA4BN,CAAG,GAE5E,OAAO,cAAc,kBAAkB,IAAIA,EAAI,aAAaC,CAAM,GAC3DA;AACT;AAEO,SAASO,EAAeC,GAAqB;AAClD,SAAO,OAAO,cAAc,cAAc,IAAIA,CAAW;AAC3D;"}
1
+ {"version":3,"file":"index.mjs","sources":["../../src/globals.ts","../../src/credentials.ts","../../src/logger.ts","../../src/tracer.ts","../../src/start.ts"],"sourcesContent":["const DEFAULT_TRACES_ENDPOINT =\n 'traces-grpc-faststore-pvl.opentelemetry-collector.vtex.systems:80'\nconst DEFAULT_LOGGER_ENDPOINT =\n 'logs-developer-fluentd-faststore-pvl.opentelemetry-collector.vtex.systems'\n\n/** Fraction of traces exported when telemetry is enabled outside development. */\nconst DEFAULT_TRACES_SAMPLE_RATE = 0.3\n\nconst parseSampleRate = (value: string | undefined, fallback: number) => {\n if (!value) {\n return fallback\n }\n\n const parsed = Number(value)\n\n return Number.isFinite(parsed) && parsed >= 0 && parsed <= 1\n ? parsed\n : fallback\n}\n\nglobalThis.fsDiagnostics ??= {\n IS_DEV: process.env.NODE_ENV !== 'production',\n TELEMETRY_CLIENT: undefined,\n OTLP_TRACES_ENDPOINT:\n process.env.OTLP_TRACES_ENDPOINT || DEFAULT_TRACES_ENDPOINT,\n OTLP_LOGGER_ENDPOINT:\n process.env.OTLP_LOGGER_ENDPOINT || DEFAULT_LOGGER_ENDPOINT,\n OTLP_TRACES_SAMPLE_RATE: parseSampleRate(\n process.env.OTLP_TRACES_SAMPLE_RATE,\n DEFAULT_TRACES_SAMPLE_RATE\n ),\n}\n","import { type ChannelCredentials, credentials } from '@grpc/grpc-js'\n\n/**\n * The VTEX collectors are reached over plaintext gRPC (port 80), so transport\n * security is opt-in via an explicit `https://` endpoint rather than inferred\n * from the environment.\n */\nexport function createChannelCredentials(endpoint: string): ChannelCredentials {\n return endpoint.startsWith('https://')\n ? credentials.createSsl()\n : credentials.createInsecure()\n}\n","import { SeverityNumber, logs } from '@opentelemetry/api-logs'\nimport { OTLPLogExporter } from '@opentelemetry/exporter-logs-otlp-grpc'\nimport { BatchLogRecordProcessor } from '@opentelemetry/sdk-logs'\nimport { format } from 'node:util'\nimport { createChannelCredentials } from './credentials'\n\nexport function getLoggerExporter() {\n const endpoint = globalThis.fsDiagnostics.OTLP_LOGGER_ENDPOINT\n\n return new BatchLogRecordProcessor(\n new OTLPLogExporter({\n credentials: createChannelCredentials(endpoint),\n url: endpoint,\n })\n )\n}\n\nconst SEVERITY = {\n error: { number: SeverityNumber.ERROR, text: 'ERROR' },\n warn: { number: SeverityNumber.WARN, text: 'WARN' },\n info: { number: SeverityNumber.INFO, text: 'INFO' },\n debug: { number: SeverityNumber.DEBUG, text: 'DEBUG' },\n} as const\n\nexport type LogSeverity = keyof typeof SEVERITY\n\n/**\n * Builds a `util.format`-style emitter for the given instrumentation scope.\n *\n * The underlying provider is resolved on every call because callers hold these\n * emitters in module-level constants, which are evaluated before\n * `getTelemetryClient` installs the provider. Formatting is deferred until a\n * provider exists so disabled telemetry costs nothing on hot paths — pass\n * printf-style arguments rather than pre-built template strings.\n */\nexport function logger(name: string) {\n return (severity: LogSeverity, ...args: unknown[]) => {\n if (!globalThis.fsDiagnostics.TELEMETRY_CLIENT) {\n return\n }\n\n logs.getLogger(name).emit({\n severityNumber: SEVERITY[severity].number,\n severityText: SEVERITY[severity].text,\n body: format(...args),\n })\n }\n}\n","import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-grpc'\nimport {\n BatchSpanProcessor,\n ParentBasedSampler,\n type Sampler,\n TraceIdRatioBasedSampler,\n} from '@opentelemetry/sdk-trace-node'\nimport { createChannelCredentials } from './credentials'\n\n/**\n * Payload compression follows the standard `OTEL_EXPORTER_OTLP_COMPRESSION`\n * environment variable (set it to `gzip` to reduce egress).\n */\nexport function traceExporter() {\n const endpoint = globalThis.fsDiagnostics.OTLP_TRACES_ENDPOINT\n\n const collectorExporter = new OTLPTraceExporter({\n credentials: createChannelCredentials(endpoint),\n url: endpoint,\n })\n\n return new BatchSpanProcessor(collectorExporter, {\n maxQueueSize: 2048,\n maxExportBatchSize: 512,\n scheduledDelayMillis: 5000,\n exportTimeoutMillis: 30_000,\n })\n}\n\n/**\n * Development traces everything; elsewhere a ratio sampler keeps export volume\n * (and collector cost) bounded. Parent-based so a sampled request keeps all of\n * its child spans instead of producing partial traces.\n */\nexport function traceSampler(): Sampler {\n const ratio = globalThis.fsDiagnostics.IS_DEV\n ? 1\n : globalThis.fsDiagnostics.OTLP_TRACES_SAMPLE_RATE\n\n return new ParentBasedSampler({ root: new TraceIdRatioBasedSampler(ratio) })\n}\n","import { HttpInstrumentation } from '@opentelemetry/instrumentation-http'\nimport { UndiciInstrumentation } from '@opentelemetry/instrumentation-undici'\nimport { resourceFromAttributes } from '@opentelemetry/resources'\nimport { NodeSDK } from '@opentelemetry/sdk-node'\nimport { getLoggerExporter } from './logger'\nimport { traceExporter, traceSampler } from './tracer'\n\nexport interface TelemetryOptions {\n serviceName: string\n version: string\n clientName: string\n account: string\n packageName: string\n}\n\n/**\n * Boots the OpenTelemetry SDK once per process and registers it globally, so\n * `logger()` and `OTELAPI.trace` pick it up. Repeat calls return the running\n * instance, which also keeps Next.js hot-module-reload from starting a second\n * exporter in development.\n */\nexport async function getTelemetryClient(opt: TelemetryOptions) {\n if (globalThis.fsDiagnostics.TELEMETRY_CLIENT) {\n return globalThis.fsDiagnostics.TELEMETRY_CLIENT\n }\n\n const resource = resourceFromAttributes({\n 'service.name': opt.serviceName,\n 'service.version': opt.version,\n 'vtex.account.name': opt.account ?? 'unknown',\n 'vtex.application.id': opt.serviceName,\n 'vtex.diagnostics.name': 'faststore_custom',\n '@faststore_version': opt.version,\n '@faststore_package_name': opt.packageName,\n '@faststore_account_name': opt.account ?? 'unknown',\n '@faststore_environment': process.env.NODE_ENV ?? 'development',\n })\n\n // NodeSDK owns both pipelines: it installs the global tracer provider and,\n // via `logRecordProcessors`, the global logger provider that `logger()` reads.\n const sdk = new NodeSDK({\n resource,\n sampler: traceSampler(),\n spanProcessors: [traceExporter()],\n logRecordProcessors: [getLoggerExporter()],\n instrumentations: [new HttpInstrumentation(), new UndiciInstrumentation()],\n })\n\n sdk.start()\n globalThis.fsDiagnostics.TELEMETRY_CLIENT = sdk\n\n registerShutdownHook(sdk)\n\n if (globalThis.fsDiagnostics.IS_DEV) {\n console.log('TELEMETRY CLIENT STARTED', opt)\n }\n\n return sdk\n}\n\n/**\n * Flushes pending spans and logs on SIGTERM. Registering a listener suppresses\n * Node's default termination, so the signal is re-raised once the listener has\n * been removed instead of forcing `process.exit` on the host application.\n */\nfunction registerShutdownHook(sdk: NodeSDK) {\n process.once('SIGTERM', () => {\n sdk\n .shutdown()\n .catch((error) => console.error('Error shutting down OTel SDK', error))\n .finally(() => process.kill(process.pid, 'SIGTERM'))\n })\n}\n"],"names":["DEFAULT_TRACES_ENDPOINT","DEFAULT_LOGGER_ENDPOINT","DEFAULT_TRACES_SAMPLE_RATE","parseSampleRate","value","fallback","parsed","createChannelCredentials","endpoint","credentials","getLoggerExporter","BatchLogRecordProcessor","OTLPLogExporter","SEVERITY","SeverityNumber","logger","name","severity","args","logs","format","traceExporter","collectorExporter","OTLPTraceExporter","BatchSpanProcessor","traceSampler","ratio","ParentBasedSampler","TraceIdRatioBasedSampler","getTelemetryClient","opt","resource","resourceFromAttributes","sdk","NodeSDK","HttpInstrumentation","UndiciInstrumentation","registerShutdownHook","error"],"mappings":"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"}
@@ -0,0 +1,6 @@
1
+ declare const DEFAULT_TRACES_ENDPOINT = "traces-grpc-faststore-pvl.opentelemetry-collector.vtex.systems:80";
2
+ declare const DEFAULT_LOGGER_ENDPOINT = "logs-developer-fluentd-faststore-pvl.opentelemetry-collector.vtex.systems";
3
+ /** Fraction of traces exported when telemetry is enabled outside development. */
4
+ declare const DEFAULT_TRACES_SAMPLE_RATE = 0.3;
5
+ declare const parseSampleRate: (value: string | undefined, fallback: number) => number;
6
+ //# sourceMappingURL=globals.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"globals.d.ts","sourceRoot":"","sources":["../src/globals.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,uBAAuB,sEACwC,CAAA;AACrE,QAAA,MAAM,uBAAuB,8EACgD,CAAA;AAE7E,iFAAiF;AACjF,QAAA,MAAM,0BAA0B,MAAM,CAAA;AAEtC,QAAA,MAAM,eAAe,GAAI,OAAO,MAAM,GAAG,SAAS,EAAE,UAAU,MAAM,WAUnE,CAAA"}
@@ -0,0 +1,4 @@
1
+ export * as OTELAPI from '@opentelemetry/api';
2
+ export { type LogSeverity, logger } from './logger';
3
+ export { getTelemetryClient, type TelemetryOptions } from './start';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,CAAA;AAClB,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAA;AAC7C,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACnD,OAAO,EAAE,kBAAkB,EAAE,KAAK,gBAAgB,EAAE,MAAM,SAAS,CAAA"}
@@ -0,0 +1,34 @@
1
+ import { SeverityNumber } from '@opentelemetry/api-logs';
2
+ import { BatchLogRecordProcessor } from '@opentelemetry/sdk-logs';
3
+ export declare function getLoggerExporter(): BatchLogRecordProcessor;
4
+ declare const SEVERITY: {
5
+ readonly error: {
6
+ readonly number: SeverityNumber.ERROR;
7
+ readonly text: "ERROR";
8
+ };
9
+ readonly warn: {
10
+ readonly number: SeverityNumber.WARN;
11
+ readonly text: "WARN";
12
+ };
13
+ readonly info: {
14
+ readonly number: SeverityNumber.INFO;
15
+ readonly text: "INFO";
16
+ };
17
+ readonly debug: {
18
+ readonly number: SeverityNumber.DEBUG;
19
+ readonly text: "DEBUG";
20
+ };
21
+ };
22
+ export type LogSeverity = keyof typeof SEVERITY;
23
+ /**
24
+ * Builds a `util.format`-style emitter for the given instrumentation scope.
25
+ *
26
+ * The underlying provider is resolved on every call because callers hold these
27
+ * emitters in module-level constants, which are evaluated before
28
+ * `getTelemetryClient` installs the provider. Formatting is deferred until a
29
+ * provider exists so disabled telemetry costs nothing on hot paths — pass
30
+ * printf-style arguments rather than pre-built template strings.
31
+ */
32
+ export declare function logger(name: string): (severity: LogSeverity, ...args: unknown[]) => void;
33
+ export {};
34
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAQ,MAAM,yBAAyB,CAAA;AAE9D,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAA;AAIjE,wBAAgB,iBAAiB,4BAShC;AAED,QAAA,MAAM,QAAQ;;;;;;;;;;;;;;;;;CAKJ,CAAA;AAEV,MAAM,MAAM,WAAW,GAAG,MAAM,OAAO,QAAQ,CAAA;AAE/C;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,IACzB,UAAU,WAAW,EAAE,GAAG,MAAM,OAAO,EAAE,UAWlD"}
@@ -0,0 +1,16 @@
1
+ import { NodeSDK } from '@opentelemetry/sdk-node';
2
+ export interface TelemetryOptions {
3
+ serviceName: string;
4
+ version: string;
5
+ clientName: string;
6
+ account: string;
7
+ packageName: string;
8
+ }
9
+ /**
10
+ * Boots the OpenTelemetry SDK once per process and registers it globally, so
11
+ * `logger()` and `OTELAPI.trace` pick it up. Repeat calls return the running
12
+ * instance, which also keeps Next.js hot-module-reload from starting a second
13
+ * exporter in development.
14
+ */
15
+ export declare function getTelemetryClient(opt: TelemetryOptions): Promise<NodeSDK>;
16
+ //# sourceMappingURL=start.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../src/start.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AAIjD,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,MAAM,CAAA;IACf,WAAW,EAAE,MAAM,CAAA;CACpB;AAED;;;;;GAKG;AACH,wBAAsB,kBAAkB,CAAC,GAAG,EAAE,gBAAgB,oBAqC7D"}
@@ -0,0 +1,13 @@
1
+ import { BatchSpanProcessor, Sampler } from '@opentelemetry/sdk-trace-node';
2
+ /**
3
+ * Payload compression follows the standard `OTEL_EXPORTER_OTLP_COMPRESSION`
4
+ * environment variable (set it to `gzip` to reduce egress).
5
+ */
6
+ export declare function traceExporter(): BatchSpanProcessor;
7
+ /**
8
+ * Development traces everything; elsewhere a ratio sampler keeps export volume
9
+ * (and collector cost) bounded. Parent-based so a sampled request keeps all of
10
+ * its child spans instead of producing partial traces.
11
+ */
12
+ export declare function traceSampler(): Sampler;
13
+ //# sourceMappingURL=tracer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tracer.d.ts","sourceRoot":"","sources":["../src/tracer.ts"],"names":[],"mappings":"AACA,OAAO,EACL,kBAAkB,EAElB,KAAK,OAAO,EAEb,MAAM,+BAA+B,CAAA;AAGtC;;;GAGG;AACH,wBAAgB,aAAa,uBAc5B;AAED;;;;GAIG;AACH,wBAAgB,YAAY,IAAI,OAAO,CAMtC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faststore/diagnostics",
3
- "version": "4.5.1-dev.4",
3
+ "version": "4.6.0-dev.0",
4
4
  "description": "",
5
5
  "repository": {
6
6
  "type": "git",
@@ -8,40 +8,47 @@
8
8
  "directory": "packages/diagnostics"
9
9
  },
10
10
  "main": "./dist/cjs/index.js",
11
- "types": "./dist/src/index.d.ts",
11
+ "types": "./dist/index.d.ts",
12
12
  "keywords": [],
13
13
  "author": "",
14
14
  "license": "MIT",
15
15
  "files": [
16
- "configs",
17
16
  "dist"
18
17
  ],
19
18
  "exports": {
20
19
  ".": {
21
- "types": "./dist/src/index.d.ts",
20
+ "types": "./dist/index.d.ts",
22
21
  "require": "./dist/cjs/index.js",
23
22
  "import": "./dist/es/index.mjs",
24
- "default": "./dist/cjs/index.js"
25
- },
26
- "./configs/*": "./configs/*"
23
+ "default": "./dist/es/index.mjs"
24
+ }
27
25
  },
28
26
  "dependencies": {
27
+ "@grpc/grpc-js": "^1.14.4",
29
28
  "@opentelemetry/api": "^1.9.0",
30
- "@opentelemetry/instrumentation-http": "^0.212.0",
31
- "@vtex/diagnostics-nodejs": "^5.1.1",
32
- "resolve-pkg": "^3.0.1"
29
+ "@opentelemetry/api-logs": "^0.219.0",
30
+ "@opentelemetry/exporter-logs-otlp-grpc": "^0.219.0",
31
+ "@opentelemetry/exporter-trace-otlp-grpc": "^0.219.0",
32
+ "@opentelemetry/instrumentation-http": "^0.219.0",
33
+ "@opentelemetry/instrumentation-undici": "^0.29.0",
34
+ "@opentelemetry/resources": "^2.8.0",
35
+ "@opentelemetry/sdk-logs": "^0.219.0",
36
+ "@opentelemetry/sdk-node": "^0.219.0",
37
+ "@opentelemetry/sdk-trace-node": "^2.8.0"
33
38
  },
34
39
  "devDependencies": {
35
40
  "@types/node": "20.19.13",
36
41
  "tslib": "2.8.1",
37
42
  "typescript": "5.9.3",
38
43
  "vite": "7.1.5",
39
- "vite-plugin-dts": "4.5.4"
44
+ "vite-plugin-dts": "4.5.4",
45
+ "vitest": "4.0.18"
40
46
  },
41
47
  "publishConfig": {
42
48
  "access": "public"
43
49
  },
44
50
  "scripts": {
45
- "build": "vite build"
51
+ "build": "vite build",
52
+ "test": "vitest run"
46
53
  }
47
54
  }
package/configs/dev.json DELETED
@@ -1,14 +0,0 @@
1
- {
2
- "traces": {
3
- "sampling": {
4
- "defaultRate": 1,
5
- "rules": [
6
- {
7
- "name": "debug_all",
8
- "sampleRate": 1,
9
- "conditions": []
10
- }
11
- ]
12
- }
13
- }
14
- }
package/configs/prod.json DELETED
@@ -1,14 +0,0 @@
1
- {
2
- "traces": {
3
- "sampling": {
4
- "defaultRate": 0.01,
5
- "rules": [
6
- {
7
- "name": "trace_all",
8
- "sampleRate": 0.3,
9
- "conditions": []
10
- }
11
- ]
12
- }
13
- }
14
- }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=globals.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"globals.d.ts","sourceRoot":"","sources":["../../src/globals.ts"],"names":[],"mappings":""}
@@ -1,3 +0,0 @@
1
- export * as OTELAPI from '@opentelemetry/api';
2
- export { getTelemetryClient, getTraceClient } from './start';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,CAAA;AAClB,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAA;AAC7C,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA"}
@@ -1,9 +0,0 @@
1
- export declare function getTelemetryClient(opt: {
2
- serviceName: string;
3
- version: string;
4
- clientName: string;
5
- account: string;
6
- packageName: string;
7
- }): Promise<import('@vtex/diagnostics-nodejs/dist/telemetry/client.js').TelemetryClient | undefined>;
8
- export declare function getTraceClient(serviceName: string): import('@vtex/diagnostics-nodejs/dist/types/traces.js').TraceClient | undefined;
9
- //# sourceMappingURL=start.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../src/start.ts"],"names":[],"mappings":"AAwBA,wBAAsB,kBAAkB,CAAC,GAAG,EAAE;IAC5C,WAAW,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,MAAM,CAAA;IACf,WAAW,EAAE,MAAM,CAAA;CACpB,oGAgDA;AAED,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM,mFAEjD"}