Be consistent about using snake case in metadata yaml (#13610)
This commit is contained in:
parent
2e16a2e526
commit
a3a3b8bc87
File diff suppressed because it is too large
Load Diff
|
@ -50,9 +50,9 @@ public class SpringWebInstrumentationModule extends InstrumentationModule
|
|||
* name
|
||||
* Identifier for instrumentation module, used to enable/disable
|
||||
* Configured in `InstrumentationModule` code for each module
|
||||
* srcPath
|
||||
* source_path
|
||||
* Path to the source code of the instrumentation module
|
||||
* minimumJavaVersion
|
||||
* minimum_java_version
|
||||
* Minimum Java version required by the instrumentation module. If not specified, it is assumed to
|
||||
be Java 8
|
||||
* description
|
||||
|
@ -73,7 +73,7 @@ As of now, the following fields are supported:
|
|||
|
||||
```yaml
|
||||
description: "Description of what the instrumentation does."
|
||||
disabledByDefault: true
|
||||
disabled_by_default: true
|
||||
|
||||
# used to mark modules that do not instrument traditional libraries (e.g. methods, annotations)
|
||||
# defaults to true
|
||||
|
|
|
@ -9,17 +9,18 @@ import java.util.Objects;
|
|||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* This class is internal and is hence not for public use. Its APIs are unstable and can change at
|
||||
* any time.
|
||||
* Represents the data in a metadata.yaml file. This class is internal and is hence not for public
|
||||
* use. Its APIs are unstable and can change at any time.
|
||||
*/
|
||||
public class InstrumentationMetaData {
|
||||
@Nullable private String description;
|
||||
@Nullable private Boolean isLibraryInstrumentation;
|
||||
@Nullable private Boolean disabledByDefault;
|
||||
|
||||
public InstrumentationMetaData() {}
|
||||
|
||||
public InstrumentationMetaData(String description) {
|
||||
this.description = description;
|
||||
this.isLibraryInstrumentation = true;
|
||||
this.disabledByDefault = false;
|
||||
}
|
||||
|
||||
public InstrumentationMetaData(
|
||||
|
@ -29,10 +30,6 @@ public class InstrumentationMetaData {
|
|||
this.description = description;
|
||||
}
|
||||
|
||||
@Nullable private String description;
|
||||
@Nullable private Boolean disabledByDefault;
|
||||
@Nullable private Boolean isLibraryInstrumentation;
|
||||
|
||||
@Nullable
|
||||
public String getDescription() {
|
||||
return description;
|
||||
|
|
|
@ -15,10 +15,20 @@ import java.util.Map;
|
|||
import java.util.TreeMap;
|
||||
import java.util.stream.Collectors;
|
||||
import org.yaml.snakeyaml.DumperOptions;
|
||||
import org.yaml.snakeyaml.TypeDescription;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
|
||||
public class YamlHelper {
|
||||
|
||||
private static final Yaml metaDataYaml = new Yaml();
|
||||
|
||||
static {
|
||||
TypeDescription customDescriptor = new TypeDescription(InstrumentationMetaData.class);
|
||||
customDescriptor.substituteProperty(
|
||||
"disabled_by_default", Boolean.class, "getDisabledByDefault", "setDisabledByDefault");
|
||||
metaDataYaml.addTypeDescription(customDescriptor);
|
||||
}
|
||||
|
||||
public static void printInstrumentationList(
|
||||
List<InstrumentationEntity> list, BufferedWriter writer) {
|
||||
Map<String, List<InstrumentationEntity>> groupedByGroup =
|
||||
|
@ -43,14 +53,14 @@ public class YamlHelper {
|
|||
}
|
||||
|
||||
if (entity.getMetadata().getDisabledByDefault()) {
|
||||
entityMap.put("disabledByDefault", entity.getMetadata().getDisabledByDefault());
|
||||
entityMap.put("disabled_by_default", entity.getMetadata().getDisabledByDefault());
|
||||
}
|
||||
}
|
||||
|
||||
entityMap.put("srcPath", entity.getSrcPath());
|
||||
entityMap.put("source_path", entity.getSrcPath());
|
||||
|
||||
if (entity.getMinJavaVersion() != null) {
|
||||
entityMap.put("minimumJavaVersion", entity.getMinJavaVersion());
|
||||
entityMap.put("minimum_java_version", entity.getMinJavaVersion());
|
||||
}
|
||||
|
||||
Map<String, Object> scopeMap = getScopeMap(entity);
|
||||
|
@ -97,7 +107,7 @@ public class YamlHelper {
|
|||
}
|
||||
|
||||
public static InstrumentationMetaData metaDataParser(String input) {
|
||||
return new Yaml().loadAs(input, InstrumentationMetaData.class);
|
||||
return metaDataYaml.loadAs(input, InstrumentationMetaData.class);
|
||||
}
|
||||
|
||||
private YamlHelper() {}
|
||||
|
|
|
@ -69,9 +69,9 @@ class YamlHelperTest {
|
|||
instrumentations:
|
||||
- name: spring-web-6.0
|
||||
description: Spring Web 6.0 instrumentation
|
||||
disabledByDefault: true
|
||||
srcPath: instrumentation/spring/spring-web/spring-web-6.0
|
||||
minimumJavaVersion: 11
|
||||
disabled_by_default: true
|
||||
source_path: instrumentation/spring/spring-web/spring-web-6.0
|
||||
minimum_java_version: 11
|
||||
scope:
|
||||
name: io.opentelemetry.spring-web-6.0
|
||||
target_versions:
|
||||
|
@ -80,7 +80,7 @@ class YamlHelperTest {
|
|||
struts:
|
||||
instrumentations:
|
||||
- name: struts-2.3
|
||||
srcPath: instrumentation/struts/struts-2.3
|
||||
source_path: instrumentation/struts/struts-2.3
|
||||
scope:
|
||||
name: io.opentelemetry.struts-2.3
|
||||
target_versions:
|
||||
|
@ -137,8 +137,8 @@ class YamlHelperTest {
|
|||
instrumentations:
|
||||
- name: spring-web-6.0
|
||||
description: Spring Web 6.0 instrumentation
|
||||
srcPath: instrumentation/spring/spring-web/spring-web-6.0
|
||||
minimumJavaVersion: 11
|
||||
source_path: instrumentation/spring/spring-web/spring-web-6.0
|
||||
minimum_java_version: 11
|
||||
scope:
|
||||
name: io.opentelemetry.spring-web-6.0
|
||||
target_versions:
|
||||
|
@ -155,7 +155,7 @@ class YamlHelperTest {
|
|||
"""
|
||||
description: test description
|
||||
isLibraryInstrumentation: false
|
||||
disabledByDefault: true
|
||||
disabled_by_default: true
|
||||
""";
|
||||
|
||||
InstrumentationMetaData metadata = YamlHelper.metaDataParser(input);
|
||||
|
@ -183,7 +183,7 @@ class YamlHelperTest {
|
|||
|
||||
@Test
|
||||
void testMetadataParserWithOnlyDisabledByDefault() {
|
||||
String input = "disabledByDefault: true";
|
||||
String input = "disabled_by_default: true";
|
||||
InstrumentationMetaData metadata = YamlHelper.metaDataParser(input);
|
||||
assertThat(metadata.getIsLibraryInstrumentation()).isTrue();
|
||||
assertThat(metadata.getDescription()).isNull();
|
||||
|
|
|
@ -1 +1 @@
|
|||
disabledByDefault: true
|
||||
disabled_by_default: true
|
||||
|
|
|
@ -1 +1 @@
|
|||
disabledByDefault: true
|
||||
disabled_by_default: true
|
||||
|
|
|
@ -1 +1 @@
|
|||
disabledByDefault: true
|
||||
disabled_by_default: true
|
||||
|
|
|
@ -1 +1 @@
|
|||
disabledByDefault: true
|
||||
disabled_by_default: true
|
||||
|
|
|
@ -1 +1 @@
|
|||
disabledByDefault: true
|
||||
disabled_by_default: true
|
||||
|
|
|
@ -1 +1 @@
|
|||
disabledByDefault: true
|
||||
disabled_by_default: true
|
||||
|
|
|
@ -1 +1 @@
|
|||
disabledByDefault: true
|
||||
disabled_by_default: true
|
||||
|
|
|
@ -1 +1 @@
|
|||
disabledByDefault: true
|
||||
disabled_by_default: true
|
||||
|
|
|
@ -1 +1 @@
|
|||
disabledByDefault: true
|
||||
disabled_by_default: true
|
||||
|
|
|
@ -1 +1 @@
|
|||
disabledByDefault: true
|
||||
disabled_by_default: true
|
||||
|
|
|
@ -1 +1 @@
|
|||
disabledByDefault: true
|
||||
disabled_by_default: true
|
||||
|
|
Loading…
Reference in New Issue