jongpie / NebulaLogger

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.
https://nebulalogger.com
MIT License
684 stars 162 forks source link

OpenTelemetry support #466

Open RaviVaranasi opened 1 year ago

RaviVaranasi commented 1 year ago

New Feature Summary

Can I ship logs to DataDog instead of logging inside Salesforce? The advantage is to have one logging system across multiple systems

jamessimone commented 1 year ago

@RaviVaranasi I would look at the Slack plugin for the canonical way to publish log entries off-platform (as far as architecture is concerned; this isn't to say that you must send log entries to Slack if they're going off-platform, just that the way that this plugin is built should answer the question of "how to do this.")

I'm sure @jongpie can add additional info - and perhaps an official DataDog plugin can also be supported - but if you're looking to build out this functionality and the question is just "is it possible," the architecture in the Slack plugin should be enough to get going!

RaviVaranasi commented 1 year ago

Thanks for the feedback. If we ship the logs to DataDog, can we not create Log objects in SF?

jamessimone commented 1 year ago

You still can!

jongpie commented 1 year ago

@RaviVaranasi I've previously done some integrations other tools like Loggly, but I haven't used Datadog myself before, so I'm not familiar with their API or how to best integrate with them. But to expand on what @jamessimone has said, I think there are 2-3 ways you could approach this type of integration:

Option 1: Create a Nebula Logger plugin that sends Log__c and LogEntry__c data to Datadog

As @jamessimone pointed out, the Slack plugin is a great example of how plugins for Nebula Logger are structured. This plugin in particular also leverages Log__c and LogEntry__c data, so if you want to still store data in Salesforce (in addition to storing it in Datadog), then I would mimic the Slack plugin's approach

Option 2: Create a Nebula Logger plugin that can be configured to send either LogEntryEvent__e or Log__c/LogEntry__c data to Datadog

If you're worried about the storage usage of the custom objects in your org, and you want to control if some or all Nebula Logger instead goes just to Datadog, then you can take a look at the Big Object Archiving plugin. The Big Object Archiving plugin lets you choose per user if Nebula Logger's LogEntryEvent__e data is stored in Log__c/LogEntry__c, or only stored in a custom big object (LogEntryArchive__b). You could have a similar plugin for Datadog that lets you control per user if logging data is stored in Salesforce, Datadog, or both

Option 3: Don't Create a Nebula Logger plugin at all - instead, integrate using pub/sub API

I'm not sure what's involved with setting up this option (because I haven't used Datadog before), but since Nebula Logger uses platform events to create LogEntryEvent__e data, you can probably setup Datadog to subscribe directly to LogEntryEvent__e object using the pub/sub API.

Hope this helps, but let us know if you have questions!

sjurgis commented 1 year ago

@jongpie any chance you know any resources / examples how to log apex metrics (mostly around performance)?

sjurgis commented 1 year ago

FWIW Datadog does have a connector for Event Monitoring https://docs.datadoghq.com/integrations/salesforce/

RaviVaranasi commented 1 year ago

FWIW Datadog does have a connector for Event Monitoring https://docs.datadoghq.com/integrations/salesforce/

Does this do logging?

jonathankretzmer commented 1 year ago

Instead of actively targeting a single provider like DataDog, it would possibly be more beneficial to target an open standard, e.g. OpenTelemetry (which DataDog supports).

jongpie commented 1 year ago

@jonathankretzmer I agree, I think it makes more sense to target the OpenTelemetry standard, instead of vendor-specific integrations. There was recently a discussion about this too, so I think a lot of people would benefit from using OpenTelemetry. I've started some initial analysis & prototyping on this already - I'm hoping to work on it more over the next several weeks.