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