• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2015 The Dagger Authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package dagger.producers.monitoring;
18 
19 import dagger.producers.Produces;
20 import dagger.producers.ProductionComponent;
21 
22 /**
23  * A hook for recording timing of the execution of
24  * {@linkplain ProductionComponent production components}. To install a
25  * {@code ProductionComponentTimingRecorder}, contribute to a set binding of
26  * {@code ProductionComponentTimingRecorder.Factory}, and include the {@code TimingMonitorModule} to
27  * the component. The factory will be asked to create one timing recorder for the component, and the
28  * resulting instance will be used to create individual timing recorders for producers.
29  *
30  * <p>If any of these methods throw, then the exception will be logged, and the framework will act
31  * as though a no-op timing recorder was returned.
32  *
33  * @since 2.1
34  */
35 public interface ProductionComponentTimingRecorder {
36   /** Returns a timing recorder for an individual {@linkplain Produces producer method}. */
producerTimingRecorderFor(ProducerToken token)37   ProducerTimingRecorder producerTimingRecorderFor(ProducerToken token);
38 
39   public interface Factory {
40     /** Creates a component-specific timing recorder when the component is created. */
create(Object component)41     ProductionComponentTimingRecorder create(Object component);
42   }
43 }
44