Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added logging support for instances of RestRequest and RestResponse #613

Merged

Conversation

jongpie
Copy link
Owner

@jongpie jongpie commented Jan 23, 2024

Core Unlocked Package Changes

Added logging support for instances of RestRequest and RestResponse

  • Resolved Ability to Log against RestRequest/RestResponse #514 by introducing new features & fields to support logging instances of System.RestRequest and System.RestResponse that are used for Apex REST services:

    • Added 2 new global instance methods in LogEntryBuilder to provide a way to log instances of System.RestRequest and System.RestResponse:

      1. global LogEntryEventBuilder setRestRequestDetails(System.RestRequest request);
      2. global LogEntryEventBuilder setRestResponseDetails(System.RestResponse response);
    • Added 2 new LoggerParameter__mdt records to control logging of request & response headers when using the new builder methods. These LoggerParameter__mdt records are equivalent to the record StoreHttpResponseHeaderValues (introduced in Nebula Logger v4.11.8) for System.HttpResponse logging:

      1. StoreRestRequestHeaderValues - this metadata records controls if the request's header values are stored in new fields LogEntryEvent__e.RestRequestHeaders__c and LogEntryEvent__e.RestrequestHeaders__c. By default, it's enabled.
      2. StoreRestResponseHeaderValues - this metadata records controls if the response's header values are stored in new fields LogEntryEvent__e.RestResponseHeaders__c and LogEntryEvent__e.RestResponseHeaders__c. By default, it's enabled.
    • Added 9 new fields for System.RestRequest data on LogEntryEvent__e platform event

      1. LogEntryEvent__e.RestRequestBodyMasked__c
      2. LogEntryEvent__e.RestRequestBody__c
      3. LogEntryEvent__e.RestRequestHeaderKeys__c
      4. LogEntryEvent__e.RestRequestHeaders__c
      5. LogEntryEvent__e.RestRequestMethod__c
      6. LogEntryEvent__e.RestRequestParameters__c
      7. LogEntryEvent__e.RestRequestRemoteAddress__c
      8. LogEntryEvent__e.RestRequestResourcePath__c
      9. LogEntryEvent__e.RestRequestUri__c
    • Added 5 new fields for System.RestResponse data on LogEntryEvent__e platform event

      1. LogEntryEvent__e.RestResponseBodyMasked__c
      2. LogEntryEvent__e.RestResponseBody__c
      3. LogEntryEvent__e.RestResponseHeaderKeys__c
      4. LogEntryEvent__e.RestResponseHeaders__c
      5. LogEntryEvent__e.RestResponseStatusCode__c
    • Added 12 new fields for System.RestResponse data on LogEntry__c custom object

      1. LogEntry__c.HasRestRequestBody__c
      2. LogEntry__c.HasRestRequestHeaderKeys__c
      3. LogEntry__c.HasRestRequestHeaders__c
      4. LogEntry__c.RestRequestBody__c
      5. LogEntry__c.RestRequestBodyMasked__c
      6. LogEntry__c.RestRequestHeaderKeys__c
      7. LogEntry__c.RestRequestHeaders__c
      8. LogEntry__c.RestRequestMethod__c
      9. LogEntry__c.RestRequestParameters__c
      10. LogEntry__c.RestRequestRemoteAddress__c
      11. LogEntry__c.RestRequestResourcePath__c
      12. LogEntry__c.RestRequestUri__c
    • Added 8 new fields for System.RestResponse data on LogEntry__c custom object

      1. LogEntry__c.HasRestResponseBody__c
      2. LogEntry__c.HasRestResponseHeaderKeys__c
      3. LogEntry__c.HasRestResponseHeaders__c
      4. LogEntry__c.RestResponseBodyMasked__c
      5. LogEntry__c.RestResponseBody__c
      6. LogEntry__c.RestResponseHeaderKeys__c
      7. LogEntry__c.RestResponseHeaders__c
      8. LogEntry__c.RestResponseStatusCode__c
    • Updated permission sets LoggerAdmin, LoggerLogViewer, and LoggerEndUser to add access to the new custom fields on LogEntry__c

    • Add 2 new sections on LogEntryRecordPage flexipage

      • Apex REST Service Request section shows the corresponding fields for RestRequest data (when populated)
      • Apex REST Service Response section shows the corresponding fields for RestResponse data (when populated)
    • Renamed 2 existing sections on LogEntryRecordPage flexipage to help avoid confusion with the 2 new sections Apex Rest Service Request and Apex REST Service Response

      • HTTP Request is now HTTP Callout Request
      • HTTP Response is now HTTP Callout Response

Reduced the Max Length of Several Existing Long Textarea Fields

  • LogEntryEvent__e.ExceptionMessage__c: 131,072 limit reduced to 5,000
  • LogEntryEvent__e.ExceptionStackTrace__c: 131,072 limit reduced to 5,000
  • LogEntryEvent__e.StackTrace__c: 131,072 limit reduced to 5,000
  • LogEntryEvent__e.Topics__c (deprecated/no longer used): 131,072 limit reduced to 256
  • LogEntry__c.ExceptionMessage__c: 131,072 limit reduced to 5,000
  • LogEntry__c.ExceptionStackTrace__c: 131,072 limit reduced to 5,000
  • LogEntry__c.FlowDescription__c: 131,072 limit reduced to 5,000
  • LogEntry__c.StackTrace__c: 131,072 limit reduced to 5,000

@jongpie jongpie added Type: Enhancement New feature or request Salesforce Feature: Reporting Anything related to reports, dashboards, and the underlying data model Logging Source: Apex Items related to using Logger within Apex Layer: Log Management Items related to the custom objects & Logger Console app Layer: Logger Engine Items related to the core logging engine labels Jan 23, 2024
@jongpie jongpie temporarily deployed to Experience Cloud Scratch Org January 23, 2024 03:24 — with GitHub Actions Inactive
@jongpie jongpie force-pushed the feature/logging-support-for-rest-request-and-rest-response branch from 106bfe6 to 7102d3d Compare January 23, 2024 21:40
@jongpie jongpie temporarily deployed to Experience Cloud Scratch Org January 23, 2024 21:42 — with GitHub Actions Inactive
@jongpie jongpie temporarily deployed to Experience Cloud Scratch Org January 23, 2024 21:53 — with GitHub Actions Inactive
@jongpie jongpie force-pushed the feature/logging-support-for-rest-request-and-rest-response branch from 1276dae to ae4c372 Compare February 1, 2024 16:00
…seDetails() to store info on instances of System.RestResponse

Also renamed existing flexipage sections 'HTTP Request' and 'HTTP Response' to 'HTTP Callout Request' and 'HTTP Callout Response' for clarity
…tDetails() to store info on instances of System.RestRequest
…ixed package generation for the managed package by including an empty copy of Admin.profile-meta.xml ಥ_ಥ

Also updated both sfdx-project.json files to use the new flag 'scopeProfiles'
@jongpie jongpie force-pushed the feature/logging-support-for-rest-request-and-rest-response branch from ae4c372 to 041aa2d Compare February 1, 2024 16:16
@jongpie jongpie had a problem deploying to Experience Cloud Scratch Org February 1, 2024 16:17 — with GitHub Actions Failure
@jongpie jongpie had a problem deploying to Experience Cloud Scratch Org February 1, 2024 16:23 — with GitHub Actions Failure
@jongpie jongpie had a problem deploying to Experience Cloud Scratch Org February 1, 2024 16:35 — with GitHub Actions Failure
@jongpie jongpie had a problem deploying to Experience Cloud Scratch Org February 1, 2024 16:43 — with GitHub Actions Failure
@jongpie jongpie had a problem deploying to Experience Cloud Scratch Org February 1, 2024 17:01 — with GitHub Actions Failure
@jongpie jongpie temporarily deployed to Experience Cloud Scratch Org February 1, 2024 17:09 — with GitHub Actions Inactive
@jongpie jongpie force-pushed the feature/logging-support-for-rest-request-and-rest-response branch from 7f53a43 to 1934550 Compare February 1, 2024 18:30
@jongpie jongpie had a problem deploying to Experience Cloud Scratch Org February 1, 2024 18:31 — with GitHub Actions Failure
…me usage of the per-object limit

Previously, these fields were all using the max length of 131072, which is overkill for these fields
@jongpie jongpie force-pushed the feature/logging-support-for-rest-request-and-rest-response branch from 1934550 to 358e0d7 Compare February 1, 2024 18:44
@jongpie jongpie had a problem deploying to Experience Cloud Scratch Org February 1, 2024 18:45 — with GitHub Actions Failure
@jongpie jongpie had a problem deploying to Experience Cloud Scratch Org February 1, 2024 18:53 — with GitHub Actions Failure
@jongpie jongpie temporarily deployed to Experience Cloud Scratch Org February 1, 2024 19:12 — with GitHub Actions Inactive
@jongpie jongpie force-pushed the feature/logging-support-for-rest-request-and-rest-response branch from d40c442 to c4ae423 Compare February 2, 2024 03:31
@jongpie jongpie temporarily deployed to Experience Cloud Scratch Org February 2, 2024 03:32 — with GitHub Actions Inactive
@jongpie jongpie marked this pull request as ready for review February 2, 2024 03:34
…due to the change being unsupported (of course)
@jongpie jongpie added the Logging Source: API Items related to using Nebula Logger via REST API label Feb 2, 2024
Copy link

codecov bot commented Feb 2, 2024

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (21e02ac) 95.66% compared to head (c4ae423) 95.73%.

❗ Current head c4ae423 differs from pull request most recent head a72d926. Consider uploading reports for the commit a72d926 to get more accurate results

Files Patch % Lines
...ain/logger-engine/classes/LogEntryEventBuilder.cls 98.18% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #613      +/-   ##
==========================================
+ Coverage   95.66%   95.73%   +0.06%     
==========================================
  Files          48       48              
  Lines        5215     5297      +82     
==========================================
+ Hits         4989     5071      +82     
  Misses        226      226              
Flag Coverage Δ
Apex 95.73% <98.79%> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jongpie jongpie merged commit f602f90 into main Feb 2, 2024
1 check passed
@jongpie jongpie deleted the feature/logging-support-for-rest-request-and-rest-response branch February 2, 2024 04:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Layer: Log Management Items related to the custom objects & Logger Console app Layer: Logger Engine Items related to the core logging engine Logging Source: Apex Items related to using Logger within Apex Logging Source: API Items related to using Nebula Logger via REST API Salesforce Feature: Reporting Anything related to reports, dashboards, and the underlying data model Type: Enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ability to Log against RestRequest/RestResponse
2 participants