# Sending Directly from Instrumented Services

## Overview

groundcover supports ingestion of data directly from DataDog SDKs, allowing you to continue using your existing DataDog instrumentation without sending it to DataDog itself.

### Why would you use SDK Redirection?

This method is recommended when you want to leverage your existing SDKs - we know how much work it is adding these - without the need to run a DataDog agent or send the generated data to DataDog.

### What data will be received in groundcover?

1. Traces - allowing you to use the DataDog distributed traces generated by your applications
2. Custom metrics - sent by your applications using DogStatsD

{% hint style="info" %}
Sending custom metrics directly from the SDK is currently only supported for Kubernetes
{% endhint %}

### Traces Sampling in Kubernetes

{% hint style="info" %}
This part is only relevant for Kubernetes setups. Data sent from from non-kubernetes envs is not sampled.
{% endhint %}

groundcover automatically performs sampling for traces sent from DataDog SDKs to the sensors in kubernetes clusters.

{% hint style="success" %}
The default sampling rate is 5%
{% endhint %}

To configure sampling, the relevant values can be used:

```yaml
agent:
  sensor:
    apmIngestor:
      dataDog:
        samplingRatio: 0.05
```

The `samplingRatio` field is a fraction in the range 0-1. For example, 0.1 means 10% of the incoming traces will be sampled and stored in groundcover.

#### Configuring 100% Sampling Ratio (No Sampling)

Use the values below to disable sampling and ingest 100% of the incoming traces.

```yaml
agent:
  sensor:
    apmIngestor:
      dataDog:
        samplingRatio: 1
```

## Setting up Shipping from the Application

### Kubernetes

The recommended method to Dual Ship data in Kubernetes is by sending it to groundcover components inside the cluster

* Traces will be forwarded to the `groundcover-sensor` service
* Custom metrics will be forwarded to the `groundcover-vector` service

#### Configuring the Instrumented Application

Add the following to the application environment variables:

{% hint style="success" %}
Leave `groundcover-placeholder` as is - do not replace with a real API key
{% endhint %}

```yaml
datadog:  
  env:
    - name: "DD_TRACE_AGENT_URL"
      value: "http://groundcover-sensor.groundcover.svc.cluster.local:8126"
    - name: "DD_DOGSTATSD_URL"
      value: "udp://groundcover-vector.groundcover.svc.cluster.local:8125"
```

### Standalone Hosts

{% hint style="info" %}
Sending custom metrics directly from the SDK is currently only supported for Kubernetes
{% endhint %}

The recommended method to Dual Ship data from standalone hosts is by sending it do the groundcover sensor deployed on the host.

### Deploy the groundcover sensor

Follow these steps to deploy groundcover sensor on your host:

[connect-linux-hosts](https://docs.groundcover.com/getting-started/installation-and-updating/connect-linux-hosts "mention")

#### Configuring the DataDog Agent

Add the following to the service environment variables:

```bash
DD_TRACE_AGENT_URL="https://localhost:8126"
```
