Skip to content

Commit

Permalink
[WIP] Moved service name field to Log__c, added additional 'external …
Browse files Browse the repository at this point in the history
…service' fields
  • Loading branch information
jongpie committed Dec 30, 2024
1 parent db75832 commit f0c63df
Show file tree
Hide file tree
Showing 22 changed files with 310 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ public without sharing class LogEntryEventHandler extends LoggerSObjectHandler {
AsyncContextParentJobId__c = logEntryEvent.AsyncContextParentJobId__c,
AsyncContextTriggerId__c = logEntryEvent.AsyncContextTriggerId__c,
AsyncContextType__c = logEntryEvent.AsyncContextType__c,
ExternalServiceId__c = logEntryEvent.ExternalServiceId__c,
ExternalServiceName__c = logEntryEvent.ExternalServiceName__c,
ExternalServiceType__c = logEntryEvent.ExternalServiceType__c,
ExternalServiceVersion__c = logEntryEvent.ExternalServiceVersion__c,
ImpersonatedBy__c = logEntryEvent.ImpersonatedById__c,
Locale__c = logEntryEvent.Locale__c,
LoggedBy__c = logEntryEvent.LoggedById__c,
Expand Down Expand Up @@ -335,7 +339,6 @@ public without sharing class LogEntryEventHandler extends LoggerSObjectHandler {
MessageTruncated__c = logEntryEvent.MessageTruncated__c,
Name = null, // Salesforce will auto-set the record ID as the name when null
OriginLocation__c = logEntryEvent.OriginLocation__c,
OriginServiceName__c = logEntryEvent.OriginServiceName__c,
OriginSourceActionName__c = logEntryEvent.OriginSourceActionName__c,
OriginSourceApiName__c = logEntryEvent.OriginSourceApiName__c,
OriginSourceId__c = logEntryEvent.OriginSourceId__c,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,12 +344,18 @@ global with sharing class LoggerRestResource {

for (OTelAttribute entryAttribute : this.attributes) {
switch on entryAttribute.key {
when 'service.id' {
supplementalFieldToValue.put(LogEntryEvent__e.ExternalServiceId__c, entryAttribute.value?.stringValue);
}
when 'service.name' {
supplementalFieldToValue.put(LogEntryEvent__e.OriginServiceName__c, entryAttribute.value?.stringValue);
supplementalFieldToValue.put(LogEntryEvent__e.ExternalServiceName__c, entryAttribute.value?.stringValue);
}
when 'service.type' {
supplementalFieldToValue.put(LogEntryEvent__e.ExternalServiceType__c, entryAttribute.value?.stringValue);
}
when 'service.version' {
supplementalFieldToValue.put(LogEntryEvent__e.ExternalServiceVersion__c, entryAttribute.value?.stringValue);
}
// TODO
// when 'service.version' {
// }
}
}

Expand Down Expand Up @@ -393,7 +399,7 @@ global with sharing class LoggerRestResource {
}
this.convertedLogEntryEvent = builder.getLogEntryEvent();
this.convertedLogEntryEvent.EntryScenario__c = this.name;
this.convertedLogEntryEvent.OriginType__c = 'API';
this.convertedLogEntryEvent.OriginType__c = 'External Service';
this.convertedLogEntryEvent.TransactionId__c = convertedTraceId;

// Since the log entries originate off-platform, tracking the limits usage isn't really relevant here
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>61.0</apiVersion>
<apiVersion>62.0</apiVersion>
<status>Active</status>
</ApexClass>
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,86 @@
<type>Facet</type>
</flexiPageRegions>
<flexiPageRegions>
<itemInstances>
<fieldInstance>
<fieldInstanceProperties>
<name>uiBehavior</name>
<value>none</value>
</fieldInstanceProperties>
<fieldItem>Record.ExternalServiceId__c</fieldItem>
<identifier>RecordExternalServiceId_cField2</identifier>
<visibilityRule>
<criteria>
<leftValue>{!Record.ExternalServiceId__c}</leftValue>
<operator>NE</operator>
</criteria>
</visibilityRule>
</fieldInstance>
</itemInstances>
<itemInstances>
<fieldInstance>
<fieldInstanceProperties>
<name>uiBehavior</name>
<value>none</value>
</fieldInstanceProperties>
<fieldItem>Record.ExternalServiceName__c</fieldItem>
<identifier>RecordExternalServiceName_cField</identifier>
<visibilityRule>
<criteria>
<leftValue>{!Record.ExternalServiceName__c}</leftValue>
<operator>NE</operator>
</criteria>
</visibilityRule>
</fieldInstance>
</itemInstances>
<itemInstances>
<fieldInstance>
<fieldInstanceProperties>
<name>uiBehavior</name>
<value>none</value>
</fieldInstanceProperties>
<fieldItem>Record.ExternalServiceType__c</fieldItem>
<identifier>RecordExternalServiceType_cField</identifier>
<visibilityRule>
<criteria>
<leftValue>{!Record.ExternalServiceType__c}</leftValue>
<operator>NE</operator>
</criteria>
</visibilityRule>
</fieldInstance>
</itemInstances>
<itemInstances>
<fieldInstance>
<fieldInstanceProperties>
<name>uiBehavior</name>
<value>none</value>
</fieldInstanceProperties>
<fieldItem>Record.ExternalServiceVersion__c</fieldItem>
<identifier>RecordExternalServiceVersion_cField</identifier>
<visibilityRule>
<criteria>
<leftValue>{!Record.ExternalServiceVersion__c}</leftValue>
<operator>NE</operator>
</criteria>
</visibilityRule>
</fieldInstance>
</itemInstances>
<itemInstances>
<fieldInstance>
<fieldInstanceProperties>
<name>uiBehavior</name>
<value>readonly</value>
</fieldInstanceProperties>
<fieldItem>Record.ParentLogLink__c</fieldItem>
<identifier>RecordParentLogLink__cField</identifier>
<visibilityRule>
<criteria>
<leftValue>{!Record.ParentLogTransactionId__c}</leftValue>
<operator>NE</operator>
</criteria>
</visibilityRule>
</fieldInstance>
</itemInstances>
<itemInstances>
<fieldInstance>
<fieldInstanceProperties>
Expand Down Expand Up @@ -348,6 +428,10 @@
<identifier>RecordStartTime__cField</identifier>
</fieldInstance>
</itemInstances>
<name>Facet-d581561a-9af6-472b-bf5b-f191cbaa0836</name>
<type>Facet</type>
</flexiPageRegions>
<flexiPageRegions>
<itemInstances>
<fieldInstance>
<fieldInstanceProperties>
Expand All @@ -368,10 +452,6 @@
<identifier>RecordTotalLimitsCpuTimeUsed__cField</identifier>
</fieldInstance>
</itemInstances>
<name>Facet-d581561a-9af6-472b-bf5b-f191cbaa0836</name>
<type>Facet</type>
</flexiPageRegions>
<flexiPageRegions>
<itemInstances>
<fieldInstance>
<fieldInstanceProperties>
Expand Down Expand Up @@ -402,16 +482,6 @@
<identifier>RecordTotalWARNLogEntries__cField</identifier>
</fieldInstance>
</itemInstances>
<itemInstances>
<fieldInstance>
<fieldInstanceProperties>
<name>uiBehavior</name>
<value>readonly</value>
</fieldInstanceProperties>
<fieldItem>Record.ParentLogLink__c</fieldItem>
<identifier>RecordParentLogLink__cField</identifier>
</fieldInstance>
</itemInstances>
<name>Facet-af147cb3-e6b1-4ef7-a00b-d4746d5a1c90</name>
<type>Facet</type>
</flexiPageRegions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@
<default>false</default>
<label>Apex</label>
</value>
<value>
<fullName>API</fullName>
<color>#FFCA3A</color>
<default>false</default>
<label>API</label>
</value>
<value>
<fullName>Component</fullName>
<color>#8AC926</color>
<default>false</default>
<label>Component</label>
</value>
<value>
<fullName>External Service</fullName>
<color>#FFCA3A</color>
<default>false</default>
<label>External Service</label>
</value>
<value>
<fullName>Flow</fullName>
<color>#1982C4</color>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<CustomField xmlns="http://soap.sforce.com/2006/04/metadata">
<fullName>OriginServiceName__c</fullName>
<fullName>ExternalServiceId__c</fullName>
<businessStatus>Active</businessStatus>
<complianceGroup>None</complianceGroup>
<externalId>true</externalId>
<label>Origin Service Name</label>
<label>External Service ID</label>
<length>255</length>
<required>false</required>
<securityClassification>Confidential</securityClassification>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<CustomField xmlns="http://soap.sforce.com/2006/04/metadata">
<fullName>ExternalServiceName__c</fullName>
<businessStatus>Active</businessStatus>
<complianceGroup>None</complianceGroup>
<externalId>true</externalId>
<label>External Service Name</label>
<length>255</length>
<required>false</required>
<securityClassification>Confidential</securityClassification>
<trackTrending>false</trackTrending>
<type>Text</type>
<unique>false</unique>
</CustomField>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<CustomField xmlns="http://soap.sforce.com/2006/04/metadata">
<fullName>ExternalServiceType__c</fullName>
<businessStatus>Active</businessStatus>
<complianceGroup>None</complianceGroup>
<externalId>true</externalId>
<label>External Service Type</label>
<length>255</length>
<required>false</required>
<securityClassification>Confidential</securityClassification>
<trackTrending>false</trackTrending>
<type>Text</type>
<unique>false</unique>
</CustomField>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<CustomField xmlns="http://soap.sforce.com/2006/04/metadata">
<fullName>ExternalServiceVersion__c</fullName>
<businessStatus>Active</businessStatus>
<complianceGroup>None</complianceGroup>
<externalId>true</externalId>
<label>External Service Version</label>
<length>255</length>
<required>false</required>
<securityClassification>Confidential</securityClassification>
<trackTrending>false</trackTrending>
<type>Text</type>
<unique>false</unique>
</CustomField>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<ListView xmlns="http://soap.sforce.com/2006/04/metadata">
<fullName>AllExternalServiceLogs</fullName>
<columns>NAME</columns>
<columns>ExternalServiceType__c</columns>
<columns>ExternalServiceId__c</columns>
<columns>ExternalServiceName__c</columns>
<columns>LoggedByUsernameLink__c</columns>
<columns>ProfileLink__c</columns>
<columns>TransactionId__c</columns>
<columns>TotalLogEntries__c</columns>
<columns>TotalERRORLogEntries__c</columns>
<columns>TotalWARNLogEntries__c</columns>
<columns>OWNER.ALIAS</columns>
<columns>Priority__c</columns>
<columns>Status__c</columns>
<columns>TransactionScenarioLink__c</columns>
<columns>StartTime__c</columns>
<filterScope>Everything</filterScope>
<filters>
<field>ExternalServiceName__c</field>
<operation>notEqual</operation>
</filters>
<label>All Child Logs</label>
</ListView>
Original file line number Diff line number Diff line change
Expand Up @@ -935,11 +935,6 @@
<field>LogEntry__c.OriginLocation__c</field>
<readable>true</readable>
</fieldPermissions>
<fieldPermissions>
<editable>false</editable>
<field>LogEntry__c.OriginServiceName__c</field>
<readable>true</readable>
</fieldPermissions>
<fieldPermissions>
<editable>false</editable>
<field>LogEntry__c.OriginSourceActionName__c</field>
Expand Down Expand Up @@ -1255,6 +1250,26 @@
<field>Log__c.EndTime__c</field>
<readable>true</readable>
</fieldPermissions>
<fieldPermissions>
<editable>false</editable>
<field>Log__c.ExternalServiceId__c</field>
<readable>true</readable>
</fieldPermissions>
<fieldPermissions>
<editable>false</editable>
<field>Log__c.ExternalServiceName__c</field>
<readable>true</readable>
</fieldPermissions>
<fieldPermissions>
<editable>false</editable>
<field>Log__c.ExternalServiceType__c</field>
<readable>true</readable>
</fieldPermissions>
<fieldPermissions>
<editable>false</editable>
<field>Log__c.ExternalServiceVersion__c</field>
<readable>true</readable>
</fieldPermissions>
<fieldPermissions>
<editable>false</editable>
<field>Log__c.HasComments__c</field>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -617,11 +617,6 @@
<field>LogEntry__c.OriginLocation__c</field>
<readable>true</readable>
</fieldPermissions>
<fieldPermissions>
<editable>false</editable>
<field>LogEntry__c.OriginServiceName__c</field>
<readable>true</readable>
</fieldPermissions>
<fieldPermissions>
<editable>false</editable>
<field>LogEntry__c.OriginSourceApiName__c</field>
Expand Down Expand Up @@ -782,6 +777,26 @@
<field>Log__c.EndTime__c</field>
<readable>true</readable>
</fieldPermissions>
<fieldPermissions>
<editable>false</editable>
<field>Log__c.ExternalServiceId__c</field>
<readable>true</readable>
</fieldPermissions>
<fieldPermissions>
<editable>false</editable>
<field>Log__c.ExternalServiceName__c</field>
<readable>true</readable>
</fieldPermissions>
<fieldPermissions>
<editable>false</editable>
<field>Log__c.ExternalServiceType__c</field>
<readable>true</readable>
</fieldPermissions>
<fieldPermissions>
<editable>false</editable>
<field>Log__c.ExternalServiceVersion__c</field>
<readable>true</readable>
</fieldPermissions>
<fieldPermissions>
<editable>false</editable>
<field>Log__c.HasLoggedByFederationIdentifier__c</field>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8" ?>
<?xml version="1.0" encoding="UTF-8"?>
<PermissionSet xmlns="http://soap.sforce.com/2006/04/metadata">
<classAccesses>
<apexClass>LoggerRestResource</apexClass>
Expand Down
Loading

0 comments on commit f0c63df

Please sign in to comment.