Skip to content

Commit 11e783b

Browse files
committed
Revert "TEST TEST macos binary build OOM"
This reverts commit 2b0ee4c.
1 parent 2b0ee4c commit 11e783b

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

packages/gateway/src/commands/handleOpenTelemetryConfig.ts

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
BatchSpanProcessor,
44
SpanProcessor,
55
} from '@opentelemetry/sdk-trace-base';
6-
import { getEnvStr } from '~internal/env';
6+
import { getEnvStr, isNode } from '~internal/env';
77
import type { CLIContext } from '..';
88

99
export async function handleOpenTelemetryConfig(
@@ -110,6 +110,21 @@ export async function handleOpenTelemetryConfig(
110110

111111
openTelemetrySetup({
112112
traces: { processors },
113+
resource: await detectResource().catch((err) => {
114+
if (
115+
err &&
116+
typeof err === 'object' &&
117+
'code' in err &&
118+
err.code === 'ERR_MODULE_NOT_FOUND'
119+
) {
120+
ctx.log.warn(
121+
err,
122+
`NodeJS modules necessary for environment detection is missing, please install it to auto-detect the environment`,
123+
);
124+
return undefined;
125+
}
126+
throw err;
127+
}),
113128
contextManager,
114129
});
115130

@@ -121,3 +136,16 @@ export async function handleOpenTelemetryConfig(
121136

122137
return false;
123138
}
139+
140+
async function detectResource() {
141+
if (isNode()) {
142+
// eslint-disable-next-line import/no-extraneous-dependencies -- it's up to the user to install
143+
const { getResourceDetectors } = await import(
144+
'@opentelemetry/auto-instrumentations-node'
145+
);
146+
// eslint-disable-next-line import/no-extraneous-dependencies -- it's up to the user to install
147+
const { detectResources } = await import('@opentelemetry/resources');
148+
return detectResources({ detectors: getResourceDetectors() });
149+
}
150+
return undefined;
151+
}

0 commit comments

Comments
 (0)