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 OpenTelemetry REST endpoint for external systems to store logs in Salesforce #767

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,20 @@ env:

on:
push:
branches:
- main
paths:
- .github/workflows/**
- config/scratch-orgs/**
- nebula-logger/**
- sfdx-project.json
pull_request:
types: [opened, synchronize, reopened]
paths:
- .github/workflows/**
- config/scratch-orgs/**
- nebula-logger/**
- sfdx-project.json

jobs:
code-quality-tests:
Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@

The most robust observability solution for Salesforce experts. Built 100% natively on the platform, and designed to work seamlessly with Apex, Lightning Components, Flow, Process Builder & integrations.

## Unlocked Package - v4.14.10
## Unlocked Package - v4.14.11

[![Install Unlocked Package in a Sandbox](./images/btn-install-unlocked-package-sandbox.png)](https://test.salesforce.com/packaging/installPackage.apexp?p0=04t5Y0000015oTdQAI)
[![Install Unlocked Package in Production](./images/btn-install-unlocked-package-production.png)](https://login.salesforce.com/packaging/installPackage.apexp?p0=04t5Y0000015oTdQAI)
[![Install Unlocked Package in a Sandbox](./images/btn-install-unlocked-package-sandbox.png)](https://test.salesforce.com/packaging/installPackage.apexp?p0=04t5Y0000015oUHQAY)
[![Install Unlocked Package in Production](./images/btn-install-unlocked-package-production.png)](https://login.salesforce.com/packaging/installPackage.apexp?p0=04t5Y0000015oUHQAY)
[![View Documentation](./images/btn-view-documentation.png)](https://github.com/jongpie/NebulaLogger/wiki)

`sf package install --wait 20 --security-type AdminsOnly --package 04t5Y0000015oTdQAI`
`sf package install --wait 20 --security-type AdminsOnly --package 04t5Y0000015oUHQAY`

`sfdx force:package:install --wait 20 --securitytype AdminsOnly --package 04t5Y0000015oTdQAI`
`sfdx force:package:install --wait 20 --securitytype AdminsOnly --package 04t5Y0000015oUHQAY`

---

Expand All @@ -40,6 +40,7 @@ The most robust observability solution for Salesforce experts. Built 100% native
- [Lightning Components](https://github.com/jongpie/NebulaLogger/wiki/Logging-in-Components): lightning web components (LWCs) & aura components
- [Flow & Process Builder](https://github.com/jongpie/NebulaLogger/wiki/Logging-in-Flow): any Flow type that supports invocable actions
- [OmniStudio](https://github.com/jongpie/NebulaLogger/wiki/Logging-in-OmniStudio): omniscripts and omni integration procedures
- [OpenTelemetry (OTel) REST API](https://github.com/jongpie/NebulaLogger/wiki/Logging-in-OpenTelemetry-REST-API): inbound integrations, using HTTP and [OTel's JSON format for logs](https://github.com/open-telemetry/opentelemetry-proto/blob/main/examples/logs.json)

2. Built with an event-driven pub/sub messaging architecture, using `LogEntryEvent__e` [platform events](https://developer.salesforce.com/docs/atlas.en-us.platform_events.meta/platform_events/platform_events_intro.htm). For more details on leveraging platform events, see [the Platform Events Developer Guide site](https://developer.salesforce.com/docs/atlas.en-us.platform_events.meta/platform_events/platform_events_subscribe_cometd.htm)

Expand Down
193 changes: 193 additions & 0 deletions docs/apex/Log-Management/LoggerRestResource.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
---
layout: default
---

## LoggerRestResource class

REST Resource class for external integrations to interact with Nebula Logger

---

### Properties

#### `body` → `String`

#### `endpointRequest` → `EndpointRequest`

#### `errors` → `List<EndpointError>`

#### `headerKeys` → `List<String>`

#### `httpMethod` → `String`

#### `isSuccess` → `Boolean`

#### `message` → `String`

#### `name` → `String`

#### `parameters` → `Map<String, String>`

#### `particle` → `String`

#### `statusCode` → `Integer`

#### `type` → `String`

#### `uri` → `String`

---

### Methods

#### `EndpointError(System.Exception apexException)` → `public`

#### `EndpointError(String message)` → `public`

#### `EndpointError(String message, String type)` → `public`

#### `EndpointRequest(System.RestRequest restRequest)` → `public`

#### `addError(System.Exception apexException)` → `EndpointResponse`

#### `addError(EndpointError endpointError)` → `EndpointResponse`

#### `handlePost()` → `void`

Processes any HTTP POST requests sent

#### `handlePost(EndpointRequest endpointRequest)` → `EndpointResponse`

#### `handlePost(EndpointRequest endpointRequest)` → `EndpointResponse`

#### `handlePost(EndpointRequest endpointRequest)` → `EndpointResponse`

#### `setStatusCode(Integer statusCode)` → `EndpointResponse`

---

### Inner Classes

#### LoggerRestResource.OTelAttribute class

---

##### Constructors

###### `OTelAttribute(String key, String value)`

---

##### Properties

###### `key` → `String`

###### `value` → `OTelAttributeValue`

---

#### LoggerRestResource.OTelAttributeValue class

---

##### Constructors

###### `OTelAttributeValue(String value)`

---

##### Properties

###### `stringValue` → `String`

---

#### LoggerRestResource.OTelLogRecord class

---

##### Properties

###### `attributes` → `List<OTelAttribute>`

###### `body` → `OTelAttributeValue`

###### `severityText` → `String`

###### `timeUnixNano` → `String`

---

##### Methods

###### `getLogEntryEvent()` → `LogEntryEvent__e`

---

#### LoggerRestResource.OTelLogsPayload class

---

##### Properties

###### `resourceLogs` → `List<OTelResourceLog>`

---

##### Methods

###### `getConvertedLogEntryEvents()` → `List<LogEntryEvent__e>`

---

#### LoggerRestResource.OTelResource class

---

##### Properties

###### `attributes` → `List<OTelAttribute>`

---

#### LoggerRestResource.OTelResourceLog class

---

##### Properties

###### `resource` → `OTelResource`

###### `scopeLogs` → `List<OTelScopeLog>`

---

##### Methods

###### `getLogEntryEvents()` → `List<LogEntryEvent__e>`

---

#### LoggerRestResource.OTelScope class

---

##### Properties

###### `name` → `String`

###### `version` → `String`

---

#### LoggerRestResource.OTelScopeLog class

---

##### Properties

###### `logRecords` → `List<OTelLogRecord>`

###### `scope` → `OTelScope`

---
4 changes: 4 additions & 0 deletions docs/apex/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ Builds and sends email notifications when internal exceptions occur within the l

Controller class for the LWC `loggerHomeHeader`

### [LoggerRestResource](Log-Management/LoggerRestResource)

REST Resource class for external integrations to create &amp; retrieve logging data

### [LoggerSObjectMetadata](Log-Management/LoggerSObjectMetadata)

Provides details to LWCs about Logger&apos;s `SObjects`, using `@AuraEnabled` properties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ 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 @@ -405,7 +405,13 @@ public without sharing virtual class LogManagementDataSelector {
return new List<Schema.User>();
}

return [SELECT Id, Name, Username, SmallPhotoUrl FROM User WHERE Name LIKE :searchTerm OR Username LIKE :searchTerm ORDER BY Username LIMIT 20];
return [
SELECT Id, Name, Username, SmallPhotoUrl
FROM User
WHERE IsActive = TRUE AND (Name LIKE :searchTerm OR Username LIKE :searchTerm)
ORDER BY Username
LIMIT 20
];
}

/**
Expand Down
Loading