Skip to content

Commit edfae1d

Browse files
Adds support for events in documented observation and documented span
1 parent f604db6 commit edfae1d

File tree

15 files changed

+240
-274
lines changed

15 files changed

+240
-274
lines changed

build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,10 @@ subprojects {
299299
description = 'Facade over tracing concepts'
300300

301301
repositories {
302+
mavenLocal()
302303
mavenCentral()
303304
maven { url 'https://repo.spring.io/milestone' }
305+
maven { url 'https://repo.spring.io/snapshot' }
304306
}
305307

306308
def check = tasks.findByName('check')

buildscript-gradle.lockfile

Lines changed: 0 additions & 80 deletions
This file was deleted.

dependencies.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ def VERSIONS = [
1919
]
2020

2121
def PLATFORM_VERSIONS = [
22-
'io.micrometer:micrometer-bom:1.10.0-M4',
23-
'io.micrometer:micrometer-tracing-bom:1.0.0-M7',
22+
'io.micrometer:micrometer-bom:1.10.0-SNAPSHOT',
23+
'io.micrometer:micrometer-tracing-bom:1.0.0-SNAPSHOT',
2424
'org.junit:junit-bom:5.8.+'
2525
]
2626

micrometer-docs-generator-bom/gradle.lockfile

Lines changed: 0 additions & 7 deletions
This file was deleted.

micrometer-docs-generator-commons/gradle.lockfile

Lines changed: 0 additions & 54 deletions
This file was deleted.

micrometer-docs-generator-commons/src/main/java/io/micrometer/docs/commons/ParsingUtils.java

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import io.micrometer.common.util.internal.logging.InternalLogger;
3636
import io.micrometer.common.util.internal.logging.InternalLoggerFactory;
3737
import io.micrometer.observation.Observation;
38+
import org.jboss.forge.roaster.Internal;
3839
import org.jboss.forge.roaster.Roaster;
3940
import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.AbstractTypeDeclaration;
4041
import org.jboss.forge.roaster._shade.org.eclipse.jdt.core.dom.CompilationUnit;
@@ -65,7 +66,7 @@ public class ParsingUtils {
6566
private static final InternalLogger logger = InternalLoggerFactory.getInstance(ParsingUtils.class);
6667

6768
public static void updateKeyValuesFromEnum(JavaEnumImpl parentEnum, JavaSource<?> source, Class requiredClass,
68-
Collection<KeyValueEntry> keyValues) {
69+
Collection<KeyValueEntry> keyValues, @Nullable String methodName) {
6970
if (!(source instanceof JavaEnumImpl)) {
7071
return;
7172
}
@@ -78,7 +79,7 @@ public static void updateKeyValuesFromEnum(JavaEnumImpl parentEnum, JavaSource<?
7879
return;
7980
}
8081
for (EnumConstantSource enumConstant : myEnum.getEnumConstants()) {
81-
String keyValue = enumKeyValue(enumConstant);
82+
String keyValue = enumKeyValue(enumConstant, methodName);
8283
keyValues.add(new KeyValueEntry(keyValue, enumConstant.getJavaDoc().getText()));
8384
}
8485
}
@@ -153,14 +154,19 @@ private static String filePath(String className, File parent) {
153154

154155
public static Collection<KeyValueEntry> keyValueEntries(JavaEnumImpl myEnum, MethodDeclaration methodDeclaration,
155156
Class requiredClass) {
157+
return keyValueEntries(myEnum, methodDeclaration, requiredClass, null);
158+
}
159+
160+
public static Collection<KeyValueEntry> keyValueEntries(JavaEnumImpl myEnum, MethodDeclaration methodDeclaration,
161+
Class requiredClass, @Nullable String methodName) {
156162
Collection<String> enumNames = readClassValue(methodDeclaration);
157163
Collection<KeyValueEntry> keyValues = new TreeSet<>();
158164
enumNames.forEach(enumName -> {
159165
List<JavaSource<?>> nestedTypes = myEnum.getNestedTypes();
160166
JavaSource<?> nestedSource = nestedTypes.stream()
161167
.filter(javaSource -> javaSource.getName().equals(enumName)).findFirst().orElseThrow(
162168
() -> new IllegalStateException("There's no nested type with name [" + enumName + "]"));
163-
ParsingUtils.updateKeyValuesFromEnum(myEnum, nestedSource, requiredClass, keyValues);
169+
ParsingUtils.updateKeyValuesFromEnum(myEnum, nestedSource, requiredClass, keyValues, methodName);
164170
});
165171
return keyValues;
166172
}
@@ -198,13 +204,18 @@ else if (!methodInvocation.toString().endsWith(".values()")) {
198204
return Collections.singletonList(methodInvocation.getExpression().toString());
199205
}
200206

201-
private static String enumKeyValue(EnumConstantSource enumConstant) {
207+
private static String enumKeyValue(EnumConstantSource enumConstant, @Nullable String methodName) {
202208
List<MemberSource<EnumConstantSource.Body, ?>> members = enumConstant.getBody().getMembers();
203209
if (members.isEmpty()) {
204210
logger.warn("No method declarations in the enum.");
205211
return "";
206212
}
207-
Object internal = members.get(0).getInternal();
213+
Object internal;
214+
if (methodName == null) {
215+
internal = members.get(0).getInternal();
216+
} else {
217+
internal = members.stream().filter(bodyMemberSource -> bodyMemberSource.getName().equals(methodName)).findFirst().map(Internal::getInternal).orElse(null);
218+
}
208219
if (!(internal instanceof MethodDeclaration)) {
209220
logger.warn("Can't read the member [" + internal.getClass() + "] as a method declaration.");
210221
return "";

micrometer-docs-generator-metrics/gradle.lockfile

Lines changed: 0 additions & 60 deletions
This file was deleted.

0 commit comments

Comments
 (0)