Skip to content

Commit

Permalink
[Addon] update datadog trait (#750)
Browse files Browse the repository at this point in the history
Signed-off-by: kolossi <[email protected]>
Co-authored-by: kolossi <[email protected]>
  • Loading branch information
Kolossi and kolossi authored Apr 11, 2024
1 parent 8d6dcdc commit 4139c9f
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 13 deletions.
44 changes: 38 additions & 6 deletions experimental/addons/datadog/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ installed on the host nodes.

The Datadog agent must already be install on the cluster nodes.

## Use case example
The expectation is that the datadog volume is `/var/run/datadog` on the host,
and will be mounted as `/var/run/datadog` in the container, though this can
be changed (not recommended).

## Simple use case example

```yaml
apiVersion: core.oam.dev/v1beta1
Expand All @@ -19,13 +23,41 @@ spec:
- name: myapp
type: webservice
properties:
image: me/myapp:latest
image: me/myapp:1.0.15
traits:
- type: datadog
properties:
serviceName: myService
env: prod
version: 1.0.15
source: csharp
serviceName: "myService"
env: "prod"
version: "1.0.15"
```
## Comprehensive use case example
```yaml
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: myapp
spec:
components:
- name: myapp
type: webservice
properties:
image: me/myapp:1.0.17
traits:
- type: datadog
properties:
serviceName: "myService"
env: "dev"
version: "1.0.17"
source: "csharp"
hostMountPath: "/var/run/custom-datadog"
mountPath: "/usr/var/run/datadog"
volumeName: "customdatadog"
autoDependencyMap: true
autoDependencies: "http-client,sql-server,firestore"
logDirectSubmissionIntegrations: "Serilog"


```
44 changes: 38 additions & 6 deletions experimental/addons/datadog/definitions/datadog.cue
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,47 @@ template: {
name: "DD_ENV",
value: parameter.env
},
{
name: "DD_TAGS",
value: "env:"+parameter.env
},
{
name: "DD_VERSION",
value: parameter.version
},

if parameter.autoDependencyMap {
let autoDepenencyList = [ for x in strings.Split(parameter.autoDependencies,",") { strings.TrimSpace(x) } ]
let mappings = [ for x in autoDepenencyList { x + ":" + parameter.serviceName + "-dependency" }]
let autoDependencyList = [ for x in strings.Split(parameter.autoDependencies,",") { strings.TrimSpace(x) } ]
let mappings = [ for x in autoDependencyList { x + ":" + parameter.serviceName + "-dependency" }]

{
name: "DD_TRACE_SERVICE_MAPPING"
name: "DD_TRACE_SERVICE_MAPPING",
value: strings.Join(mappings, ",")
}
}
]
},
if parameter.logDirectSubmissionIntegrations != _|_ for i in [
{
name: "DD_LOGS_DIRECT_SUBMISSION_INTEGRATIONS",
value: parameter.logDirectSubmissionIntegrations
},
{
name: "DD_LOGS_INJECTION",
value: true
},
if parameter.source != _|_ {
{
name: "DD_LOGS_DIRECT_SUBMISSION_SOURCE",
value: parameter.source
}
},
if parameter.logDirectSubmissionMinLevel != _|_ {
{
name: "DD_LOGS_DIRECT_SUBMISSION_MINIMUM_LEVEL",
value: parameter.logDirectSubmissionMinLevel
}
},
] {i}
]

let volumeMount = {
name: parameter.volumeName,
Expand Down Expand Up @@ -109,14 +135,20 @@ template: {
// +usage=name of host mount volume (default datadog)
volumeName: *"datadog" | string

// +usage=source for logging (added as an annotation 'ad.datadoghq.com/<serviceName>.logs: [{"source":"<this value>"}]' )
// +usage=source for logging - added as an annotation 'ad.datadoghq.com/<serviceName>.logs: [{"source":"<this value>"}]', and if logDirectSubmissionIntegrations is given, also assigned to DD_LOGS_DIRECT_SUBMISSION_SOURCE env var.
source?: string

// +usage=auto-map standard dependencies to <serviceName>-dependency by setting DD_TRACE_SERVICE_MAPPING env var (default false)
autoDependencyMap: *false | bool

// +usage=comma-separated list of dependencies to be used by autoDependencyMap (default "http-client,redis,sql-server,kafka,faulthandlingdb")
autoDependencies: *"http-client,redis,sql-server,kafka,faulthandlingdb" | string

// +usage=give the integrations to be used for log direct submission, e.g. "Serilog". If set will be assigned to DD_LOGS_DIRECT_SUBMISSION_INTERGRATIONS env var, and will set DD_LOGS_INJECTION=true.
logDirectSubmissionIntegrations?: string

// +usage=give the minimum log level to be submitted for log direct submission, e.g. "Information". If set as well as logDirectSubmissionIntegrations, will be assigned to DD_LOGS_DIRECT_SUBMISSION_MINIMUM_LEVEL env var
logDirectSubmissionMinLevel? : string
}

}
2 changes: 1 addition & 1 deletion experimental/addons/datadog/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: datadog
version: 0.0.2
version: 0.0.3
system:
vela: ">=v1.9.0"
description: Sets up the annotations and environment variables to assist a webservice or cron-task component to have correct collection of logs and apm stats by a datadog agent installed on the host nodes.
Expand Down

0 comments on commit 4139c9f

Please sign in to comment.