ElasticCommonSchemaProperties Class — spring-boot Architecture
Architecture documentation for the ElasticCommonSchemaProperties class in ElasticCommonSchemaProperties.java from the spring-boot codebase.
Entity Profile
Relationship Graph
Source Code
core/spring-boot/src/main/java/org/springframework/boot/logging/structured/ElasticCommonSchemaProperties.java lines 38–113
public record ElasticCommonSchemaProperties(Service service) {
static final ElasticCommonSchemaProperties NONE = new ElasticCommonSchemaProperties(Service.NONE);
ElasticCommonSchemaProperties withDefaults(Environment environment) {
Service service = this.service.withDefaults(environment);
return new ElasticCommonSchemaProperties(service);
}
static @Nullable String withFallbackProperty(Environment environment, @Nullable String value, String property) {
return (!StringUtils.hasLength(value)) ? environment.getProperty(property) : value;
}
/**
* Add {@link JsonWriter} members for the service.
* @param members the members to add to
*/
public void jsonMembers(JsonWriter.Members<?> members) {
this.service.jsonMembers(members);
}
/**
* Return a new {@link ElasticCommonSchemaProperties} from bound from properties in
* the given {@link Environment}.
* @param environment the source environment
* @return a new {@link ElasticCommonSchemaProperties} instance
*/
public static ElasticCommonSchemaProperties get(Environment environment) {
return Binder.get(environment)
.bind("logging.structured.ecs", ElasticCommonSchemaProperties.class)
.orElse(NONE)
.withDefaults(environment);
}
/**
* Service details.
*
* @param name the application name
* @param version the version of the application
* @param environment the name of the environment the application is running in
* @param nodeName the name of the node the application is running on
*/
public record Service(@Nullable String name, @Nullable String version, @Nullable String environment,
@Nullable String nodeName) {
static final Service NONE = new Service(null, null, null, null);
@SuppressWarnings("NullAway") // Doesn't detect lambda with correct nullability
void jsonMembers(Members<?> members) {
members.add("service").usingMembers((service) -> {
service.add("name", this::name).whenHasLength();
service.add("version", this::version).whenHasLength();
service.add("environment", this::environment).whenHasLength();
service.add("node").usingMembers((node) -> node.add("name", this::nodeName).whenHasLength());
});
}
Service withDefaults(Environment environment) {
String name = withFallbackProperty(environment, this.name, "spring.application.name");
String version = withFallbackProperty(environment, this.version, "spring.application.version");
return new Service(name, version, this.environment, this.nodeName);
}
}
static class ElasticCommonSchemaPropertiesRuntimeHints implements RuntimeHintsRegistrar {
@Override
public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader) {
BindableRuntimeHintsRegistrar.forTypes(ElasticCommonSchemaProperties.class)
.registerHints(hints, classLoader);
}
}
}
Domain
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free