Open sgohlke opened 2 months ago
I'm also seeing this message. My otel config is here: https://gist.github.com/tmokmss/b6b0d639658161cd28519a65992866f9
packages versions are same as the OP.
Encountered the same issue and wrote a simple workaround while awaiting the actual fix to land:
import {
Detector,
DetectorSync,
IResource,
ResourceDetectionConfig,
envDetectorSync,
hostDetectorSync,
processDetectorSync,
} from "@opentelemetry/resources"
function awaitAttributes(detector: DetectorSync): Detector {
return {
async detect(config?: ResourceDetectionConfig): Promise<IResource> {
const resource = detector.detect(config)
await resource.waitForAsyncAttributes?.()
return resource
},
}
}
const sdk = new opentelemetry.NodeSDK({
// ...
resourceDetectors: [
awaitAttributes(envDetectorSync),
awaitAttributes(processDetectorSync),
awaitAttributes(hostDetectorSync),
],
})
@timosaikkonen Your solution was really helpful!
In the logs of one of our applications I see the following error from time to time:
Accessing resource attributes before async attributes settled
I took a look into https://github.com/open-telemetry/opentelemetry-js/blob/main/packages/opentelemetry-resources/src/Resource.ts#L98 which I assume is the code line that writes this error.I'm not sure what to do with this error. Is is necessary to take an action or can this error be ignored? There isn't really much information about the origin of this error so I'm not sure how to find the root problem/how to debug this.
We are using the following packages:
In our instrumentation create a new SDK using the following resource:
Maybe someone has an idea how to handle this.