-
Notifications
You must be signed in to change notification settings - Fork 812
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consolidate sync and async resource interfaces #3582
Comments
Adding needs refinement label. There are several proposals
|
I went through the code, and I think we can apply all of the above proposals. The hardest one to do might be
We may also be able to change the I think it would be best to await the resource (once) in the export pipeline before passing it to the exporter. Not awaiting before the exporter would mean many promises created as each span has a |
@pichlermarc I see this has |
@pichlermarc @dyladan I've created a draft PR. Could you have a quick look to check if aligns with what you have in mind? |
Letting Look at the resource related configuration fields of export interface NodeSDKConfiguration {
resource: IResource;
resourceDetectors: Array<Detector | DetectorSync>;
autoDetectResources: boolean;
mergeResourceWithDefaults?: boolean;
} Why does it need a With #3460 there's suddenly loads of code that needs to know about async attributes (span processors). My suggestions are:
import { MyAsyncDetector, MySyncDetector } from 'xyz';
import { detectResources, detectResourcesAsync } from '@opentelemetry/resources';
const sdk = new NodeSDK({ resource: await detectResources([new MyAsyncDetector()]) });
// or
const sdk = new NodeSDK({ resource: detectResourcesSync([new MySyncDetector()]) });
There are other SDK implementations besides |
@seemk hmm, from what I understand this is what this issue in spirit is about.
// no matter if you use NodeSDK
const sdk = new NodeSDK({ resource: detectResources([new MyAsyncDetector(), new MySyncDetector()]) });
// a MeterProvider
const meterProvider = new MeterProvider({ resource: detectResources([new MyAsyncDetector(), new MySyncDetector()]) });
// or a TracerProvider
const tracerProvider = new NodeTracerProvider({ resource: detectResources([new MyAsyncDetector(), new MySyncDetector()]) }); Since awaiting is done in the export pipeline, I think we should reduce complexity and getting rid of stuff we don't need, but async resources are a very often recurring feature request. Consolidating the interface like this and having the export pipeline |
In #3460 we introduced resources which may be sync or async. In a future version we should consolidate the interfaces into a single point of entry.
Because the resource class can now contain async unresolved resource attributes, we can remove the
detectResourcesAsync
. All resource detectors can return a sync resource that may contain async attributes.The text was updated successfully, but these errors were encountered: