@@ -1811,6 +1811,8 @@ public RollbackResult deleteAspect(String urn, String aspectName, @Nonnull Map<S
18111811 latest .setCreatedBy (survivingAspect .getCreatedBy ());
18121812 latest .setCreatedFor (survivingAspect .getCreatedFor ());
18131813 _aspectDao .saveAspect (latest , false );
1814+ // metrics
1815+ _aspectDao .incrementWriteMetrics (aspectName , 1 , latest .getAspect ().getBytes (StandardCharsets .UTF_8 ).length );
18141816 _aspectDao .deleteAspect (survivingAspect );
18151817 } else {
18161818 if (isKeyAspect ) {
@@ -2014,20 +2016,27 @@ private UpdateAspectResult ingestAspectToLocalDBNoTransaction(
20142016
20152017 _aspectDao .saveAspect (latest , false );
20162018
2019+ // metrics
2020+ _aspectDao .incrementWriteMetrics (aspectName , 1 , latest .getAspect ().getBytes (StandardCharsets .UTF_8 ).length );
2021+
20172022 return new UpdateAspectResult (urn , oldValue , oldValue ,
20182023 EntityUtils .parseSystemMetadata (latest .getSystemMetadata ()), latestSystemMetadata ,
20192024 MetadataAuditOperation .UPDATE , auditStamp , 0 );
20202025 }
20212026
20222027 // 4. Save the newValue as the latest version
20232028 log .debug ("Ingesting aspect with name {}, urn {}" , aspectName , urn );
2029+ String newValueStr = EntityUtils .toJsonAspect (newValue );
20242030 long versionOfOld = _aspectDao .saveLatestAspect (urn .toString (), aspectName , latest == null ? null : EntityUtils .toJsonAspect (oldValue ),
20252031 latest == null ? null : latest .getCreatedBy (), latest == null ? null : latest .getCreatedFor (),
20262032 latest == null ? null : latest .getCreatedOn (), latest == null ? null : latest .getSystemMetadata (),
2027- EntityUtils . toJsonAspect ( newValue ) , auditStamp .getActor ().toString (),
2033+ newValueStr , auditStamp .getActor ().toString (),
20282034 auditStamp .hasImpersonator () ? auditStamp .getImpersonator ().toString () : null ,
20292035 new Timestamp (auditStamp .getTime ()), EntityUtils .toJsonAspect (providedSystemMetadata ), nextVersion );
20302036
2037+ // metrics
2038+ _aspectDao .incrementWriteMetrics (aspectName , 1 , newValueStr .getBytes (StandardCharsets .UTF_8 ).length );
2039+
20312040 return new UpdateAspectResult (urn , oldValue , newValue ,
20322041 latest == null ? null : EntityUtils .parseSystemMetadata (latest .getSystemMetadata ()), providedSystemMetadata ,
20332042 MetadataAuditOperation .UPDATE , auditStamp , versionOfOld );
@@ -2072,10 +2081,14 @@ private RecordTemplate updateAspect(
20722081 newSystemMetadata .setLastObserved (System .currentTimeMillis ());
20732082
20742083 log .debug ("Updating aspect with name {}, urn {}" , aspectName , urn );
2075- _aspectDao .saveAspect (urn .toString (), aspectName , EntityUtils .toJsonAspect (value ), auditStamp .getActor ().toString (),
2084+ String aspectStr = EntityUtils .toJsonAspect (value );
2085+ _aspectDao .saveAspect (urn .toString (), aspectName , aspectStr , auditStamp .getActor ().toString (),
20762086 auditStamp .hasImpersonator () ? auditStamp .getImpersonator ().toString () : null ,
20772087 new Timestamp (auditStamp .getTime ()), EntityUtils .toJsonAspect (newSystemMetadata ), version , oldAspect == null );
20782088
2089+ // metrics
2090+ _aspectDao .incrementWriteMetrics (aspectName , 1 , aspectStr .getBytes (StandardCharsets .UTF_8 ).length );
2091+
20792092 return new UpdateAspectResult (urn , oldValue , value , oldSystemMetadata , newSystemMetadata ,
20802093 MetadataAuditOperation .UPDATE , auditStamp , version );
20812094 }, maxTransactionRetry );
0 commit comments