datadog-agent icon indicating copy to clipboard operation
datadog-agent copied to clipboard

[APM Instrumentation] Integrate APM Instrumentation and language detection

Open liliyadd opened this issue 1 year ago • 1 comments
trafficstars

What does this PR do?

Integrates APM Instrumentation and language detection:

  • If language annotations is specified on the application Deployment, inject ONLY libraries for given annotations.
  • If SSI configuration apm_config.instrumentation.lib_versions is specified and language annotations on the app is not present, inject ONLY libraries listed by language annotations.
  • If none of language annotation or apm_config.instrumentation.lib_versions are set, try running language detection.
  • If language detection is disabled or not capable detecting the language, inject "latest" version of all tracing libraries.

Motivation

https://docs.google.com/document/d/1QJoTwJLvpAsBsLHuDedbXi1FlmW_askMsp57Z03qNLU/edit?pli=1

Additional Notes

Possible Drawbacks / Trade-offs

Describe how to test/QA your changes

Use Cluster Agent with the image datadog/cluster-agent-dev@sha256:04f76cb111177b58043e29b29c3d2cc3f4465273606614cbadefc77f25eae6f9

  1. Deploy CA with configuration datadog.apm.instrumentation.enabled=true and test app with the language annotation admission.datadoghq.com/java-lib.version: v1.29.0. Observe only one init container injected into the pod for java tracer v1.29.0.
apiVersion: apps/v1
kind: Deployment
metadata:
  name: test-app-enabled-ns
  labels:
    app: test-app
spec:
  replicas: 1
  selector:
    matchLabels:
      app: test-app
  template:
    metadata:
      labels:
        app: test-app
      annotations:
        admission.datadoghq.com/java-lib.version: v1.29.0
    spec:
      containers:
      - name: test-app
        image: ghcr.io/datadog/dd-trace-java/dd-lib-java-init-test-app:46b144f890e8076c782552c36ad331333b2f65fa
        env:
          - name: SERVER_PORT
            value: "18080"
          - name: DD_TRACE_DEBUG
            value: "true"
          - name: JAVA_TOOL_OPTIONS
            value: "-XX:MaxDirectMemorySize=8M -XX:MaxMetaspaceSize=64M -XX:ReservedCodeCacheSize=16M -Xss512K"
        readinessProbe:
          timeoutSeconds: 1
          successThreshold: 1
          failureThreshold: 1
          httpGet:
            host:
            scheme: HTTP
            path: /
            port: 18080
          initialDelaySeconds: 20
          periodSeconds: 5
        ports:
          - containerPort: 18080
            protocol: TCP
  1. Deploy CA with configuration datadog.apm.instrumentation.enabled=true, datadog.apm.instrumentation.libVersions={java: v1.22.0, python: v1.20.6} and test app with the language annotation admission.datadoghq.com/java-lib.version: v1.28.0. Observe only one init container injected into the pod for java tracer v1.28.0.
  2. Deploy CA with configuration datadog.apm.instrumentation.enabled=true, datadog.apm.instrumentation.libVersions={java: v1.22.0, python: v1.20.6} and test app without the language annotation. Observe two init containers injected into the pod.
containerStatuses:
  - image: ghcr.io/datadog/dd-trace-java/dd-lib-java-init-test-app:46b144f890e8076c782552c36ad331333b2f65fa
    imageID: ""
    lastState: {}
    name: test-app
    ready: false
    restartCount: 0
    started: false
    state:
      waiting:
        reason: PodInitializing
  hostIP: 10.142.0.88
  initContainerStatuses:
  - image: gcr.io/datadoghq/dd-lib-python-init:v1.20.6
    imageID: ""
    lastState: {}
    name: datadog-lib-python-init
    ready: false
    restartCount: 0
    started: false
    state:
      waiting:
        reason: PodInitializing
  - image: gcr.io/datadoghq/dd-lib-java-init:v1.22.0
    imageID: ""
    lastState: {}
    name: datadog-lib-java-init
    ready: false
    restartCount: 0
    started: false
    state:
      waiting:
        reason: PodInitializing
  phase: Pending
  qosClass: BestEffort
  startTime: "2024-02-09T21:39:48Z"

Reviewer's Checklist

  • [x] If known, an appropriate milestone has been selected; otherwise the Triage milestone is set.
  • [ ] Use the major_change label if your change either has a major impact on the code base, is impacting multiple teams or is changing important well-established internals of the Agent. This label will be use during QA to make sure each team pay extra attention to the changed behavior. For any customer facing change use a releasenote.
  • [x] A release note has been added or the changelog/no-changelog label has been applied.
  • [x] Changed code has automated tests for its functionality.
  • [ ] Adequate QA/testing plan information is provided. Except if the qa/skip-qa label, with required either qa/done or qa/no-code-change labels, are applied.
  • [x] At least one team/.. label has been applied, indicating the team(s) that should QA this change.
  • [ ] If applicable, docs team has been notified or an issue has been opened on the documentation repo.
  • [ ] If applicable, the need-change/operator and need-change/helm labels have been applied.
  • [ ] If applicable, the k8s/<min-version> label, indicating the lowest Kubernetes version compatible with this feature.
  • [ ] If applicable, the config template has been updated.

liliyadd avatar Jan 29 '24 19:01 liliyadd

Bloop Bleep... Dogbot Here

Regression Detector Results

Run ID: 12128b87-2dc4-4f31-82ab-06b36e141cc3 Baseline: afbdda0fbc3cbd4453e04a889e0e964adac502ca Comparison: ad42337c1571958cd950613b225f9dbed065d6a7 Total CPUs: 7

Performance changes are noted in the perf column of each table:

  • ✅ = significantly better comparison variant performance
  • ❌ = significantly worse comparison variant performance
  • ➖ = no significant change in performance

Experiments with missing or malformed data

  • basic_py_check

Usually, this warning means that there is no usable optimization goal data for that experiment, which could be a result of misconfiguration.

No significant changes in experiment optimization goals

Confidence level: 90.00% Effect size tolerance: |Δ mean %| ≥ 5.00%

There were no significant changes in experiment optimization goals at this confidence level and effect size tolerance.

Experiments ignored for regressions

Regressions in experiments with settings containing erratic: true are ignored.

perf experiment goal Δ mean % Δ mean % CI
file_to_blackhole % cpu utilization +0.09 [-6.47, +6.64]

Fine details of change detection per experiment

perf experiment goal Δ mean % Δ mean % CI
otel_to_otel_logs ingress throughput +1.23 [+0.64, +1.82]
process_agent_standard_check_with_stats memory utilization +0.30 [+0.26, +0.33]
file_to_blackhole % cpu utilization +0.09 [-6.47, +6.64]
process_agent_standard_check memory utilization +0.01 [-0.03, +0.05]
tcp_dd_logs_filter_exclude ingress throughput +0.00 [-0.00, +0.00]
uds_dogstatsd_to_api ingress throughput +0.00 [-0.00, +0.00]
trace_agent_msgpack ingress throughput +0.00 [-0.00, +0.00]
idle memory utilization -0.02 [-0.05, +0.02]
trace_agent_json ingress throughput -0.02 [-0.04, +0.01]
process_agent_real_time_mode memory utilization -0.02 [-0.05, +0.01]
tcp_syslog_to_blackhole ingress throughput -0.11 [-0.16, -0.06]
file_tree memory utilization -0.24 [-0.32, -0.16]
uds_dogstatsd_to_api_cpu % cpu utilization -1.37 [-2.78, +0.03]

Explanation

A regression test is an A/B test of target performance in a repeatable rig, where "performance" is measured as "comparison variant minus baseline variant" for an optimization goal (e.g., ingress throughput). Due to intrinsic variability in measuring that goal, we can only estimate its mean value for each experiment; we report uncertainty in that value as a 90.00% confidence interval denoted "Δ mean % CI".

For each experiment, we decide whether a change in performance is a "regression" -- a change worth investigating further -- if all of the following criteria are true:

  1. Its estimated |Δ mean %| ≥ 5.00%, indicating the change is big enough to merit a closer look.

  2. Its 90.00% confidence interval "Δ mean % CI" does not contain zero, indicating that if our statistical model is accurate, there is at least a 90.00% chance there is a difference in performance between baseline and comparison variants.

  3. Its configuration does not mark it "erratic".

pr-commenter[bot] avatar Feb 02 '24 06:02 pr-commenter[bot]

/merge

liliyadd avatar Feb 16 '24 20:02 liliyadd

:steam_locomotive: MergeQueue

Pull request added to the queue.

There are 9 builds ahead! (estimated merge in less than 3h)

Use /merge -c to cancel this operation!

dd-devflow[bot] avatar Feb 16 '24 20:02 dd-devflow[bot]