Skip to content

Commit e67f581

Browse files
dmealingclaude
andcommitted
Remove MetaDataMetrics class and all references to eliminate unnecessary performance overhead
The MetaDataMetrics class provided detailed performance tracking for metadata operations but added significant overhead: - Memory overhead: Every MetaData, MetaObject, MetaField, and MetaAttribute instance created its own MetaDataMetrics - CPU overhead: Atomic operations on every tracked operation (validation, child operations, etc.) - Thread synchronization cost: Multiple atomic variables per instance caused memory barriers - Code complexity: 300+ lines of metrics collection requiring maintenance For a metadata framework designed to be incredibly fast, this collection overhead outweighed any monitoring benefit. Changes: - Deleted metadata/src/main/java/com/draagon/meta/metrics/MetaDataMetrics.java (307 lines) - Removed all imports and field declarations across 4 classes - Removed all metrics recording calls from validation, child operations, and property changes - Verified compilation and all tests pass Total reduction: 441 lines of code removed 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 5e5149c commit e67f581

5 files changed

Lines changed: 0 additions & 441 deletions

File tree

metadata/src/main/java/com/draagon/meta/MetaData.java

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import com.draagon.meta.cache.CacheStrategy;
99
import com.draagon.meta.cache.HybridCache;
1010
import com.draagon.meta.collections.IndexedMetaDataCollection;
11-
import com.draagon.meta.metrics.MetaDataMetrics;
1211
import com.draagon.meta.validation.ValidationChain;
1312
import com.draagon.meta.validation.MetaDataValidators;
1413
import org.slf4j.Logger;
@@ -37,8 +36,6 @@ public class MetaData implements Cloneable, Serializable {
3736
private final IndexedMetaDataCollection children = new IndexedMetaDataCollection();
3837

3938

40-
// Metrics collection
41-
private final MetaDataMetrics metrics;
4239

4340
// Validation chain
4441
private volatile ValidationChain<MetaData> validationChain;
@@ -77,9 +74,6 @@ public MetaData(String type, String subType, String name ) {
7774
// Initialize type definition (lazy loading to avoid circular dependencies)
7875
this.typeDefinition = null;
7976

80-
// Initialize metrics
81-
this.metrics = new MetaDataMetrics(name);
82-
this.metrics.recordCreation();
8377

8478
// Cache the shortName and packageName
8579
int i = name.lastIndexOf(PKG_SEPARATOR);
@@ -132,16 +126,9 @@ public ValidationResult validateEnhanced() {
132126
try {
133127
ValidationResult result = getValidationChain().validate(this);
134128

135-
// Record metrics
136-
Duration duration = Duration.between(start, Instant.now());
137-
metrics.recordValidation(duration, result.isValid());
138129

139130
return result;
140131
} catch (Exception e) {
141-
// Record error metrics
142-
Duration duration = Duration.between(start, Instant.now());
143-
metrics.recordValidation(duration, false);
144-
metrics.recordError();
145132

146133
log.error("Validation failed for {}: {}", getName(), e.getMessage(), e);
147134

@@ -269,21 +256,6 @@ public Optional<Object> getCacheStats() {
269256
return cache.getStats().map(stats -> (Object) stats);
270257
}
271258

272-
// ========== METRICS ==========
273-
274-
/**
275-
* Get metrics for this MetaData
276-
*/
277-
public MetaDataMetrics getMetrics() {
278-
return metrics;
279-
}
280-
281-
/**
282-
* Get metrics snapshot
283-
*/
284-
public MetaDataMetrics.MetricsSnapshot getMetricsSnapshot() {
285-
return metrics.getSnapshot();
286-
}
287259

288260
// ========== ENHANCED ATTRIBUTE MANAGEMENT ==========
289261

@@ -723,8 +695,6 @@ public void addChild(MetaData data, boolean checkExists) throws InvalidMetaData
723695

724696
// Use indexed collection for O(1) operations
725697
if (children.add(data)) {
726-
// Record metrics
727-
metrics.recordChildAddition();
728698

729699
// Flush caches
730700
flushCaches();
@@ -738,8 +708,6 @@ public void deleteChildOfType(String type, String name ) {
738708
MetaData d = getChildOfType(type, name);
739709
if (d.getParent() == this) {
740710
if (children.remove(d)) {
741-
// Record metrics
742-
metrics.recordChildRemoval();
743711

744712
flushCaches();
745713
}
@@ -755,8 +723,6 @@ public void deleteChild(String name, Class<? extends MetaData> c) {
755723
MetaData d = getChild(name, c);
756724
if (d.getParent() == this) {
757725
if (children.remove(d)) {
758-
// Record metrics
759-
metrics.recordChildRemoval();
760726

761727
flushCaches();
762728
}
@@ -774,8 +740,6 @@ public void deleteChild(MetaData data) {
774740
}
775741

776742
if (children.remove(data)) {
777-
// Record metrics
778-
metrics.recordChildRemoval();
779743

780744
flushCaches();
781745
}
@@ -983,8 +947,6 @@ public void clearChildrenOfType( String type ) {
983947
for (MetaData child : toRemove) {
984948
if (children.remove(child)) {
985949
removed = true;
986-
// Record metrics
987-
metrics.recordChildRemoval();
988950
}
989951
}
990952

@@ -1003,8 +965,6 @@ public void clearChildren(Class<? extends MetaData> c) {
1003965
for (MetaData child : toRemove) {
1004966
if (children.remove(child)) {
1005967
removed = true;
1006-
// Record metrics
1007-
metrics.recordChildRemoval();
1008968
}
1009969
}
1010970

metadata/src/main/java/com/draagon/meta/attr/MetaAttribute.java

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import com.draagon.meta.util.DataConverter;
55
import com.draagon.meta.validation.ValidationChain;
66
import com.draagon.meta.validation.Validator;
7-
import com.draagon.meta.metrics.MetaDataMetrics;
87
import org.slf4j.Logger;
98
import org.slf4j.LoggerFactory;
109

@@ -29,17 +28,13 @@ public class MetaAttribute<T> extends MetaData implements DataTypeAware<T>, Meta
2928
// Enhanced validation chain for attribute-specific validation
3029
private volatile ValidationChain<MetaAttribute<T>> attributeValidationChain;
3130

32-
// Attribute-specific metrics
33-
private final MetaDataMetrics attributeMetrics;
3431

3532
/**
3633
* Constructs the MetaAttribute with enhanced validation and metrics
3734
*/
3835
public MetaAttribute(String subtype, String name, DataTypes dataType ) {
3936
super( TYPE_ATTR, subtype, name );
4037
this.dataType = dataType;
41-
this.attributeMetrics = new MetaDataMetrics("attr:" + name);
42-
this.attributeMetrics.recordCreation();
4338

4439
log.debug("Created MetaAttribute: {}:{}:{} with dataType: {}", TYPE_ATTR, subtype, name, dataType);
4540
}
@@ -83,19 +78,6 @@ public DataTypes getDataType() {
8378

8479
// ========== ENHANCED ATTRIBUTE-SPECIFIC METHODS ==========
8580

86-
/**
87-
* Get attribute-specific metrics
88-
*/
89-
public MetaDataMetrics getAttributeMetrics() {
90-
return attributeMetrics;
91-
}
92-
93-
/**
94-
* Get attribute metrics snapshot
95-
*/
96-
public MetaDataMetrics.MetricsSnapshot getAttributeMetricsSnapshot() {
97-
return attributeMetrics.getSnapshot();
98-
}
9981

10082
/**
10183
* Validate this MetaAttribute using enhanced validation
@@ -106,16 +88,9 @@ public ValidationResult validateAttribute() {
10688
try {
10789
ValidationResult result = getAttributeValidationChain().validate(this);
10890

109-
// Record metrics
110-
Duration duration = Duration.between(start, Instant.now());
111-
attributeMetrics.recordValidation(duration, result.isValid());
11291

11392
return result;
11493
} catch (Exception e) {
115-
// Record error metrics
116-
Duration duration = Duration.between(start, Instant.now());
117-
attributeMetrics.recordValidation(duration, false);
118-
attributeMetrics.recordError();
11994

12095
log.error("Attribute validation failed for {}: {}", getName(), e.getMessage(), e);
12196

@@ -238,8 +213,6 @@ public void setValue( T value ) {
238213
T oldValue = this.value;
239214
this.value = value;
240215

241-
// Record metrics
242-
attributeMetrics.recordPropertyChange();
243216

244217
log.debug("MetaAttribute {} value changed from {} to {}", getName(), oldValue, value);
245218
}
@@ -282,16 +255,10 @@ public void setValueAsObject(Object value) {
282255
try {
283256
this.value = DataConverter.toTypeSafe( dataType, value, (Class<T>) dataType.getValueClass() );
284257

285-
// Record successful conversion metrics
286-
Duration duration = Duration.between(start, Instant.now());
287-
attributeMetrics.recordPropertyChange();
288258

289259
log.debug("MetaAttribute {} value converted and set from {} to {}", getName(), oldValue, this.value);
290260

291261
} catch (Exception e) {
292-
// Record error metrics
293-
Duration duration = Duration.between(start, Instant.now());
294-
attributeMetrics.recordError();
295262

296263
log.error("Failed to convert value for MetaAttribute {}: {}", getName(), e.getMessage(), e);
297264
throw e; // Re-throw to maintain existing behavior

metadata/src/main/java/com/draagon/meta/field/MetaField.java

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import com.draagon.meta.validation.ValidationChain;
1212
import com.draagon.meta.validation.Validator;
1313
import com.draagon.meta.validation.MetaDataValidators;
14-
import com.draagon.meta.metrics.MetaDataMetrics;
1514
import org.slf4j.Logger;
1615
import org.slf4j.LoggerFactory;
1716

@@ -49,8 +48,6 @@ public abstract class MetaField<T> extends MetaData implements DataTypeAware<T>
4948
// Enhanced field-specific validation chain
5049
private volatile ValidationChain<MetaField<T>> fieldValidationChain;
5150

52-
// Field-specific metrics
53-
private final MetaDataMetrics fieldMetrics;
5451

5552

5653
/**
@@ -62,8 +59,6 @@ public abstract class MetaField<T> extends MetaData implements DataTypeAware<T>
6259
public MetaField(String subtype, String name, DataTypes dataType) {
6360
super(TYPE_FIELD, subtype, name);
6461
this.dataType = dataType;
65-
this.fieldMetrics = new MetaDataMetrics("field:" + name);
66-
this.fieldMetrics.recordCreation();
6762

6863
log.debug("Created MetaField: {}:{}:{} with dataType: {}", TYPE_FIELD, subtype, name, dataType);
6964
//addAttributeDef( new AttributeDef( ATTR_LEN, String.class, false, "Length of the field" ));
@@ -173,19 +168,6 @@ public Class<?> getValueClass() {
173168

174169
// ========== ENHANCED FIELD-SPECIFIC METHODS ==========
175170

176-
/**
177-
* Get field-specific metrics
178-
*/
179-
public MetaDataMetrics getFieldMetrics() {
180-
return fieldMetrics;
181-
}
182-
183-
/**
184-
* Get field metrics snapshot
185-
*/
186-
public MetaDataMetrics.MetricsSnapshot getFieldMetricsSnapshot() {
187-
return fieldMetrics.getSnapshot();
188-
}
189171

190172
/**
191173
* Validate this MetaField using enhanced validation
@@ -196,16 +178,9 @@ public ValidationResult validateField() {
196178
try {
197179
ValidationResult result = getFieldValidationChain().validate(this);
198180

199-
// Record metrics
200-
Duration duration = Duration.between(start, Instant.now());
201-
fieldMetrics.recordValidation(duration, result.isValid());
202181

203182
return result;
204183
} catch (Exception e) {
205-
// Record error metrics
206-
Duration duration = Duration.between(start, Instant.now());
207-
fieldMetrics.recordValidation(duration, false);
208-
fieldMetrics.recordError();
209184

210185
log.error("Field validation failed for {}: {}", getName(), e.getMessage(), e);
211186

@@ -329,14 +304,10 @@ public void setDefaultValueEnhanced(T defVal) {
329304
this.defaultValue = DataConverter.toTypeSafe(getDataType(), defVal, (Class<T>) getValueClass());
330305
}
331306

332-
// Record metrics
333-
fieldMetrics.recordPropertyChange();
334307

335308
log.debug("MetaField {} default value changed from {} to {}", getName(), oldValue, defVal);
336309

337310
} catch (Exception e) {
338-
// Record error metrics
339-
fieldMetrics.recordError();
340311

341312
log.error("Failed to set default value for MetaField {}: {}", getName(), e.getMessage(), e);
342313
throw e; // Re-throw to maintain existing behavior

0 commit comments

Comments
 (0)