The OpenTelemetryContainerFilter as a @RequestScope annotation on it. In most cases this should be fine. However, if this is ever ran from a ManagedThread the request scope will likely not be active.
CDI beans can be used as tasks. Such tasks could make use of injection if they are themselves components or are created dynamically using various CDI APIs. However, application developers should be aware of the following when using CDI beans as tasks:
- Tasks that are submitted to a managed instance of ExecutorService may still be running after the lifecycle of the submitting component. Therefore, CDI beans with a scope of @RequestScoped,
@SessionScoped, or @ConversationScoped are not recommended to use as tasks as it cannot be guaranteed that the tasks will complete before the CDI context is destroyed.
- CDI beans with a scope of @ApplicationScoped or @Dependent can be used as tasks. However, it is still possible that the task could be running beyond the lifecycle of the submitting component, such as when the component is destroyed.
- The transitive closure of CDI beans that are injected into tasks should follow the above guidelines regarding their scopes.
Jakarta REST Providers support CDI and therefore the annotation should not be required.