From 4139c9fc29b7114a1e797cb5672e92ee2ccf3294 Mon Sep 17 00:00:00 2001 From: Paul Sweeney Date: Thu, 11 Apr 2024 03:43:08 +0100 Subject: [PATCH] [Addon] update datadog trait (#750) Signed-off-by: kolossi Co-authored-by: kolossi --- experimental/addons/datadog/README.md | 44 ++++++++++++++++--- .../addons/datadog/definitions/datadog.cue | 44 ++++++++++++++++--- experimental/addons/datadog/metadata.yaml | 2 +- 3 files changed, 77 insertions(+), 13 deletions(-) diff --git a/experimental/addons/datadog/README.md b/experimental/addons/datadog/README.md index ebb96e27..95400f6b 100644 --- a/experimental/addons/datadog/README.md +++ b/experimental/addons/datadog/README.md @@ -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 @@ -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" + + +``` diff --git a/experimental/addons/datadog/definitions/datadog.cue b/experimental/addons/datadog/definitions/datadog.cue index d11d61fe..85a42261 100644 --- a/experimental/addons/datadog/definitions/datadog.cue +++ b/experimental/addons/datadog/definitions/datadog.cue @@ -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, @@ -109,7 +135,7 @@ template: { // +usage=name of host mount volume (default datadog) volumeName: *"datadog" | string - // +usage=source for logging (added as an annotation 'ad.datadoghq.com/.logs: [{"source":""}]' ) + // +usage=source for logging - added as an annotation 'ad.datadoghq.com/.logs: [{"source":""}]', and if logDirectSubmissionIntegrations is given, also assigned to DD_LOGS_DIRECT_SUBMISSION_SOURCE env var. source?: string // +usage=auto-map standard dependencies to -dependency by setting DD_TRACE_SERVICE_MAPPING env var (default false) @@ -117,6 +143,12 @@ template: { // +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 } } diff --git a/experimental/addons/datadog/metadata.yaml b/experimental/addons/datadog/metadata.yaml index d24c1427..01193e9d 100644 --- a/experimental/addons/datadog/metadata.yaml +++ b/experimental/addons/datadog/metadata.yaml @@ -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.