|
1 | 1 | package org.dddjava.jig.infrastructure.javaproductreader; |
2 | 2 |
|
| 3 | +import io.micrometer.core.instrument.Metrics; |
3 | 4 | import io.micrometer.core.instrument.Timer; |
4 | 5 | import org.dddjava.jig.application.GlossaryRepository; |
5 | 6 | import org.dddjava.jig.application.JigDataProvider; |
6 | 7 | import org.dddjava.jig.application.JigEventRepository; |
7 | | -import org.dddjava.jig.application.metrics.JigMetrics; |
8 | 8 | import org.dddjava.jig.domain.model.data.rdbaccess.MyBatisStatements; |
9 | 9 | import org.dddjava.jig.domain.model.data.terms.Glossary; |
10 | 10 | import org.dddjava.jig.domain.model.data.types.JigTypeHeader; |
|
26 | 26 | import java.nio.file.Path; |
27 | 27 | import java.util.Collection; |
28 | 28 | import java.util.List; |
| 29 | +import java.util.Objects; |
29 | 30 |
|
30 | 31 | public class DefaultJigRepositoryFactory { |
31 | 32 |
|
@@ -82,31 +83,29 @@ public JigRepository createJigRepository(SourceBasePaths sourceBasePaths) { |
82 | 83 | * プロジェクト情報を読み取る |
83 | 84 | */ |
84 | 85 | private JigRepository analyze(LocalSource sources) { |
85 | | - var timer = JigMetrics.of("jig.analysis.time"); |
86 | | - return timer.measure("code_analysis_total", () -> { |
| 86 | + var metricName = "jig.analysis.time"; |
| 87 | + return Metrics.timer(metricName, "phase", "code_analysis_total").record(() -> { |
87 | 88 | JavaFilePaths javaFilePaths = sources.javaFilePaths(); |
88 | 89 |
|
89 | | - timer.measureVoid("package_info_parsing", () -> |
| 90 | + Metrics.timer(metricName, "phase", "package_info_parsing").record(() -> |
90 | 91 | javaFilePaths.packageInfoPaths().forEach( |
91 | 92 | path -> javaparserReader.loadPackageInfoJavaFile(path, glossaryRepository)) |
92 | 93 | ); |
93 | 94 |
|
94 | | - JavaSourceModel javaSourceModel = timer.measure("java_source_parsing", () -> |
| 95 | + JavaSourceModel javaSourceModel = Metrics.timer(metricName, "phase", "java_source_parsing").record(() -> |
95 | 96 | javaFilePaths.javaPaths().stream() |
96 | 97 | .map(path -> javaparserReader.parseJavaFile(path, glossaryRepository)) |
97 | 98 | .reduce(JavaSourceModel::merge) |
98 | | - .orElseGet(JavaSourceModel::empty) |
99 | | - ); |
| 99 | + .orElseGet(JavaSourceModel::empty)); |
100 | 100 |
|
101 | | - Collection<ClassDeclaration> classDeclarations = timer.measure("class_file_parsing", () -> |
102 | | - asmClassSourceReader.readClasses(sources.classFiles()) |
103 | | - ); |
| 101 | + Collection<ClassDeclaration> classDeclarations = Objects.requireNonNull( |
| 102 | + Metrics.timer(metricName, "phase", "class_file_parsing").record(() -> |
| 103 | + asmClassSourceReader.readClasses(sources.classFiles()))); |
104 | 104 |
|
105 | | - MyBatisStatements myBatisStatements = timer.measure("mybatis_reading", () -> |
106 | | - readMyBatisStatements(sources, classDeclarations) |
107 | | - ); |
| 105 | + MyBatisStatements myBatisStatements = Metrics.timer(metricName, "phase", "mybatis_reading").record(() -> |
| 106 | + readMyBatisStatements(sources, classDeclarations)); |
108 | 107 |
|
109 | | - return timer.measure("jig_repository_creation", () -> { |
| 108 | + return Metrics.timer(metricName, "phase", "jig_repository_creation").record(() -> { |
110 | 109 | DefaultJigDataProvider defaultJigDataProvider = new DefaultJigDataProvider(javaSourceModel, myBatisStatements); |
111 | 110 | JigTypes jigTypes = JigTypeFactory.createJigTypes(classDeclarations, glossaryRepository.all()); |
112 | 111 | return new JigRepository() { |
|
0 commit comments