# OpenTelemetry with Salesforce - is it working with Dynatrace?

**URL:** <https://community.dynatrace.com/t/opentelemetry-with-salesforce-is-it-working-with-dynatrace/40276>\
**Category:** OpenTelemetry\
**Tags:** distributed-traces-classic, opentelemetry, salesforce\
**Created:** [June 19, 2023, 7:28pm UTC](https://community.dynatrace.com/t/opentelemetry-with-salesforce-is-it-working-with-dynatrace/40276 "2023-06-19T19:28:10Z")\
**Posts on this page:** 1\
**Showing post:** 11

<div class="post-metadata">

**Author:** ![gopher](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/gopher/32/5728_2.png) [@gopher](https://community.dynatrace.com/u/gopher)\
**Post date:** [February 18, 2025, 2:02am UTC](https://community.dynatrace.com/t/opentelemetry-with-salesforce-is-it-working-with-dynatrace/40276/11 "2025-02-18T02:02:43Z")

</div>

[@Slawa](https://community.dynatrace.com/user/60907)&nbsp;, if you are not going to purchase the available plugins, then your options are limited.

you’re not really providing much about what you have in Sales Force, so here’s a generic answer.  
&nbsp;  
Only relevant if you have custom apps.  
You can use Apex to create custom HTTP callouts to send traces or custom events to Dynatrace.

This will involve:  
Creating a HTTP Callout to Dynatrace&nbsp;by using Apex to make a HTTP callout to the Dynatrace API endpoint.  
you’ll need an apex class sort of like the below.

```cpp
public class DynatraceIntegration {

    // The endpoint for Dynatrace custom events API
    private static final String DYNATRACE_API_URL = 'https://{environmentid}.live.dynatrace.com/api/v1/events';
    private static final String DYNATRACE_API_TOKEN = 'YOUR_DYNATRACE_API_TOKEN';

    public static void sendCustomEvent(String eventName, String eventDetails) {
        // Prepare the request headers
        Map<String, String> headers = new Map<String, String>();
        headers.put('Authorization', 'Api-Token ' + DYNATRACE_API_TOKEN);
        headers.put('Content-Type', 'application/json');

        // Prepare the request body
        String body = '{"eventType":"CUSTOM","title":"' + eventName + '","description":"' + eventDetails + '","source":"Salesforce Apex","customProperties":{"salesforceEvent":"true"}}';

        // Send the HTTP request to Dynatrace
        HttpRequest req = new HttpRequest();
        req.setEndpoint(DYNATRACE_API_URL);
        req.setMethod('POST');
        req.setHeaders(headers);
        req.setBody(body);

        Http http = new Http();
        HttpResponse res = http.send(req);

        // Log the response
        System.debug('Dynatrace Response: ' + res.getBody());
    }
}

```

You can then trigger this class when specific events occur in your Salesforce environment.

```markup
// Trigger this in your Apex logic when an event occurs
DynatraceIntegration.sendCustomEvent('Record Updated', 'Salesforce record has been updated successfully.');

```

If you don’t have a custom App, then the only other option is to us the SF API to get events into Dynatrace.  
This will involve you creating a custom integration:&nbsp;&nbsp;[Dynatrace Extensions Python SDK — Dynatrace Docs](https://docs.dynatrace.com/docs/ingest-from/extensions20/data-sources/python)  
based on your own version of:&nbsp;[Salesforce Extension monitoring & observability | Dynatrace Hub](https://www.dynatrace.com/hub/detail/salesforce-event-streaming-v2/?query=salesforce&filter=all)

This will allow you go get events based on API calls, user actions, or login events. You would need to host this on a local Active Gate and pull the data.

The RUM components, you can just rip off the extension steps.

Anyway, have fun building your own solution.

---

_[View the full topic](https://community.dynatrace.com/t/opentelemetry-with-salesforce-is-it-working-with-dynatrace/40276)._
