Open illrill opened 9 months ago
You should add that to the otelins resource like this as the one on the pod/container will be overwritten:
apiVersion: opentelemetry.io/v1alpha1
kind: Instrumentation
metadata:
name: my-instrumentation
spec:
exporter:
endpoint: http://otel-collector:4317
...
nodejs:
env:
- name: OTEL_NODE_RESOURCE_DETECTORS
value: env,host,os,process,container
I've tried that too, still doesn't take effect. See https://github.com/open-telemetry/opentelemetry-js-contrib/issues/1780#issuecomment-1943723681.
I did this in my cluster and it worked. Are you using the latest version of the operator?
Stumbled upon this one today and can confirm that this is a real issue.
Modifying OTEL_NODE_RESOURCE_DETECTORS
may lead to errors like this (code):
Invalid resource detector "container" specified in the environment variable OTEL_NODE_RESOURCE_DETECTORS
Invalid resource detector "aws" specified in the environment variable OTEL_NODE_RESOURCE_DETECTORS
Since SDK will check OTEL_NODE_RESOURCE_DETECTORS
but not the operator as mentioned by the reporter.
Is this as simple as changing the affected lines to use the env util?
const sdk = new NodeSDK({
autoDetectResources: true,
instrumentations: [getNodeAutoInstrumentations()],
traceExporter: new OTLPTraceExporter(),
metricReader: getMetricReader(),
resourceDetectors: getResourceDetectorsFromEnv()
});
Component(s)
instrumentation
What happened?
Description
The Node.js auto-instrumentation includes a series of cloud provider resource detectors which cannot be toggled off. I'm running on AKS, so the instrumentation keeps attempting to retrieve metadata related to other cloud providers (for example, calling the API server on
https://kubernetes.default.svc/api/v1/namespaces/kube-system/configmaps/aws-auth
), but this naturally fails because the metadata doesn't exist.The auto-instrumentations-node package exposes
OTEL_NODE_RESOURCE_DETECTORS
to give users control over which resource detectors to use, but here in the Operator, since all resource detectors are hardcoded when instantiating the SDK, this variable has no effect.https://github.com/open-telemetry/opentelemetry-operator/blob/c10fe8aff3017d41f82999e354e6a705a3b2dfe7/autoinstrumentation/nodejs/src/autoinstrumentation.ts#L49-L55
Steps to Reproduce
instrumentation.opentelemetry.io/inject-nodejs: "my-instrument"
OTEL_LOG_LEVEL="debug"
OTEL_NODE_RESOURCE_DETECTORS="env,host,os,process,container"
on the application to try and exclude cloud-specific resource detectorsExpected Result
OTEL_NODE_RESOURCE_DETECTORS
should work as per https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/metapackages/auto-instrumentations-node/README.md#usage-auto-instrumentationActual Result
OTEL_NODE_RESOURCE_DETECTORS
has no effectKubernetes Version
1.26.6
Operator version
0.92.1
Collector version
0.92.0
Environment information
Environment
AKS
Log output
Additional context
Originally posted in https://github.com/open-telemetry/opentelemetry-js-contrib/issues/1780