Skip to content

Commit

Permalink
Add audit name resolution performance information
Browse files Browse the repository at this point in the history
- AuditHelper.resolveName operation is now profiled via OperationResult
  (this covers model-level name resolution)
- AuditService is now profiled via interceptor (this covers audit-level
  name resolution)
  • Loading branch information
mederly committed Jun 17, 2019
1 parent facdf60 commit 028ac9e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
Expand Up @@ -235,6 +235,16 @@ public OperationResult createMinorProfiledSubresult(String operation) {
return createSubresult(operation, true, true, new Object[0]);
}

public static OperationResult createProfiled(String operation) {
return createProfiled(operation, new Object[0]);
}

public static OperationResult createProfiled(String operation, Object[] arguments) {
OperationResult result = new OperationResult(operation);
result.invocationRecord = MethodInvocationRecord.create(operation, arguments);
return result;
}

private OperationResult createSubresult(String operation, boolean minor, boolean profiled, Object[] arguments) {
OperationResult subresult = new OperationResult(operation);
addSubresult(subresult);
Expand Down
Expand Up @@ -65,14 +65,12 @@ public EnvironmentalPerformanceInformationType getStartValue() {
}

public synchronized EnvironmentalPerformanceInformationType getDeltaValue() {
EnvironmentalPerformanceInformationType rv = toEnvironmentalPerformanceInformationType();
return rv;
return toEnvironmentalPerformanceInformationType();
}

public synchronized EnvironmentalPerformanceInformationType getAggregatedValue() {
EnvironmentalPerformanceInformationType delta = toEnvironmentalPerformanceInformationType();
EnvironmentalPerformanceInformationType rv = aggregate(startValue, delta);
return rv;
return aggregate(startValue, delta);
}

private EnvironmentalPerformanceInformationType toEnvironmentalPerformanceInformationType() {
Expand Down
1 change: 1 addition & 0 deletions infra/util/src/main/resources/ctx-interceptor.xml
Expand Up @@ -40,6 +40,7 @@
<value>synchronizationService</value>
<value>modelController</value>
<value>modelInteractionService</value>
<value>auditService</value>
</list>
</constructor-arg>
</bean>
Expand Down
Expand Up @@ -49,12 +49,18 @@ public void audit(AuditEventRecord record, Task task) {
if (record.getDeltas() != null) {
for (ObjectDeltaOperation<? extends ObjectType> objectDeltaOperation : record.getDeltas()) {
ObjectDelta<? extends ObjectType> delta = objectDeltaOperation.getObjectDelta();

// we use null options here, in order to utilize the local or global repository cache
ObjectDeltaSchemaLevelUtil.NameResolver nameResolver = (objectClass, oid) -> {
PrismObject<? extends ObjectType> object = repositoryService.getObject(objectClass, oid, null,
new OperationResult(AuditHelper.class.getName() + ".resolveName"));
return object.getName();
OperationResult result = OperationResult.createProfiled(AuditHelper.class.getName() + ".resolveName");
try {
// we use null options here, in order to utilize the local or global repository cache
PrismObject<? extends ObjectType> object = repositoryService.getObject(objectClass, oid, null, result);
return object.getName();
} catch (Throwable t) {
result.recordFatalError(t.getMessage(), t);
throw t;
} finally {
result.computeStatusIfUnknown();
}
};
resolveNames(delta, nameResolver, prismContext);
}
Expand Down

0 comments on commit 028ac9e

Please sign in to comment.