MCPcopy Create free account
hub / github.com/getsentry/sentry-javascript / constructor

Method constructor

packages/node-core/src/sdk/client.ts:32–74  ·  view source on GitHub ↗
(options: NodeClientOptions)

Source from the content-addressed store, hash-verified

30 private _logOnExitFlushListener: (() => void) | undefined;
31
32 public constructor(options: NodeClientOptions) {
33 const serverName =
34 options.includeServerName === false
35 ? undefined
36 : options.serverName || global.process.env.SENTRY_NAME || os.hostname();
37
38 const clientOptions: ServerRuntimeClientOptions = {
39 ...options,
40 platform: 'node',
41 // Use provided runtime or default to 'node' with current process version
42 runtime: options.runtime || { name: 'node', version: global.process.version },
43 serverName,
44 };
45
46 if (options.openTelemetryInstrumentations) {
47 registerInstrumentations({
48 instrumentations: options.openTelemetryInstrumentations,
49 });
50 }
51
52 applySdkMetadata(clientOptions, 'node');
53
54 debug.log(`Initializing Sentry: process: ${process.pid}, thread: ${isMainThread ? 'main' : `worker-${threadId}`}.`);
55
56 super(clientOptions);
57
58 if (this.getOptions().enableLogs) {
59 this._logOnExitFlushListener = () => {
60 _INTERNAL_flushLogsBuffer(this);
61 };
62
63 if (serverName) {
64 this.on('beforeCaptureLog', log => {
65 log.attributes = {
66 ...log.attributes,
67 'server.address': serverName,
68 };
69 });
70 }
71
72 process.on('beforeExit', this._logOnExitFlushListener);
73 }
74 }
75
76 /** Get the OTEL tracer. */
77 public get tracer(): Tracer {

Callers

nothing calls this directly

Calls 5

applySdkMetadataFunction · 0.90
logMethod · 0.65
getOptionsMethod · 0.65
onMethod · 0.65

Tested by

no test coverage detected