Skip to content

fix(obs): query the emitted span-export alarm series (#985) - #986

Merged
athvin merged 3 commits into
mainfrom
issue/985-span-alarm-inputs
Nov 9, 2026
Merged

athvin merged 3 commits into
mainfrom
issue/985-span-alarm-inputs

Conversation

@athvin

@athvin athvin commented Nov 9, 2026 •

Copy link
Copy Markdown
Owner

Closes #985

Claimed by Codex session 01a1be1b-0c92-7703-a4c2-25cb2c999baa on Mac.lan at 2026-11-09T02:24:54.648707+00:00.
Follow-up to #942; closing this draft releases the claim.

Post-merge is part of this pull request. The ledger below records whether
the follow-up work actually happened. /land-pr closes it.

What

Repair the span-export alarms introduced by #942 so they query the CloudWatch series the collector actually emits. Share the existing public R2 account input across plan and apply to make the required Terraform preview accurately show this change.

Why

Both alarms currently read nonexistent dimension sets and apply RATE to interval deltas, leaving export silence undetected.

Proof

  • Terraform fmt, make skills-check, actionlint, workflow-shell-check, and credential-free validation of all five stacks pass. Independent pr-review on df0af58 found no reuse/prose issues.
  • Read-only CloudWatch GetMetricData evaluated the actual proposed expression: healthy/idle return 0; wedged/absent-export return 1. The original expression returns 0 for both failure cases. No telemetry or alarm state was mutated by the probe.

Risk & rollback

Changes only existing dev alarm queries. Per-role aggregation still lets a healthy replica hide a wedged peer; this does not add per-pod monitoring. Revert the squash commit to restore the previous alarm configuration.

Post-merge ledger

Closed by: Codex · session 01a1be1b-0c92-7703-a4c2-25cb2c999baa on Mac.lan · 2026-11-09T02:45:34.712962+00:00

Specific to this change

  • Both live alarms updated at 2026-11-09T02:37:39Z. DescribeAlarms confirms er.role plus OTelLib=er-obs, Sum for both inputs, and IF(ended>0 AND FILL(exported,0)==0, 1, 0).
  • The corrected dimension set returns real API data (20 ended / 20 exported in the observed active period). Read-only CloudWatch metric math returns breach=1 for zero-export and absent-export fixtures, and 0 for healthy and idle fixtures; the old expression misses both failure fixtures.
  • Final CI preview and apply agree: core 0/0/0, dev 0/2/0, prod 0/0/0. No token exposure or destroy override was needed.
Context — plan, discoveries, measurements, files

Plan

  1. Add the exporter-injected OTelLib dimension to both inputs, use Sum over delta samples, and fill an absent exported series with zero.
  2. Correct the alarm comments and observability reference so future queries use CloudWatch temporality and dimensions.
  3. Validate Terraform and exercise the expression against healthy, idle, zero-export, and absent-export series using read-only CloudWatch metric math.
  4. pr-review completed with no reuse/prose findings. Final CI green with the non-destructive plan; merged as c70538e at 2026-11-09T02:34:50Z. Post-merge apply, live alarm verification and main watch completed; see the ledger.

Discoveries

Plan prerequisite fixed: the first CI run proposed deleting the core R2 bucket because only apply received TF_VAR_cloudflare_account_id. An isolated credential-free plan of the actual R2 resources passed with that public input and -refresh=false. The workflow now supplies the existing account ID at workflow scope so plan and apply agree; no token is exposed and the apply identity/value is unchanged. CI run 42551482100 confirmed zero destroys across all stacks; dev has two in-place alarm updates and all other stacks have no changes.

The collector adds OTelLib even with NoDimensionRollup and converts cumulative monotonic counters to deltas. Live ListMetrics showed both dimensions; the old dimension set returned no points. Upstream behavior: https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/v0.161.0/exporter/awsemfexporter/README.md . Root-cause investigation preserved separately in #987.

Measurements

Live GetMetricStatistics with the corrected dimensions returned matching positive sums (20 ended / 20 exported) for the API role, then zeros during idle time. The original role-only queries returned no data. The synthetic read-only metric-math probe returned six breach points for both wedge scenarios and six clear points for healthy and idle cases.

Files

@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

terraform plan

732e237 · run log and full plans

env add change destroy
state-backend (plan only) 0 0 0
core 0 0 0
dev 0 2 0
prod 0 0 0

Planned with -refresh=false, so this is the config-versus-state diff and
not out-of-band drift. That is a security choice, not a speed one: a refreshing
plan reads secret values, and the plan role is assumable from any PR branch —
which can edit the workflow it runs under. Drift is caught at apply time, which
refreshes fully.

dev — 0 to add, 2 to change
data.aws_iam_policy_document.obs_pod_trust: Reading...
data.aws_iam_openid_connect_provider.github: Reading...
data.aws_caller_identity.current: Reading...
module.network.data.aws_availability_zones.available: Reading...
data.aws_iam_policy_document.er_api_pod_trust: Reading...
data.aws_iam_policy_document.eso: Reading...
data.aws_iam_policy_document.eso: Read complete after 0s [id=1725605485]
data.aws_iam_policy_document.obs_pod_trust: Read complete after 0s [id=819195744]
data.aws_iam_policy_document.er_api_pod_trust: Read complete after 0s [id=819195744]
data.aws_region.current: Reading...
module.network.data.aws_region.current: Reading...
data.aws_iam_policy_document.eso_trust: Reading...
data.aws_region.current: Read complete after 0s [id=us-east-2]
data.aws_iam_policy_document.eso_trust: Read complete after 0s [id=819195744]
module.network.data.aws_region.current: Read complete after 0s [id=us-east-2]
data.aws_iam_policy_document.efs_csi_trust: Reading...
data.aws_rds_engine_version.aurora_pg: Reading...
data.aws_caller_identity.current: Read complete after 0s [id=797781631727]
data.aws_iam_policy_document.efs_csi_trust: Read complete after 0s [id=819195744]
module.eks.data.aws_iam_policy_document.node_trust: Reading...
module.eks.data.aws_iam_policy_document.cluster_trust: Reading...
module.eks.data.aws_iam_policy_document.cluster_trust: Read complete after 0s [id=1029077455]
module.eks.data.aws_iam_policy_document.node_trust: Read complete after 0s [id=2851119427]
data.aws_iam_policy_document.fluent_bit: Reading...
data.aws_iam_policy_document.otel_collector: Reading...
data.aws_iam_policy_document.otel_collector: Read complete after 0s [id=3111493560]
data.aws_iam_policy_document.fluent_bit: Read complete after 0s [id=4006586444]
data.aws_iam_policy_document.bedrock_invoke: Reading...
data.aws_iam_policy_document.bedrock_invoke: Read complete after 0s [id=3601248236]
module.lake.data.aws_iam_policy_document.lake_tls_only: Reading...
module.lake.data.aws_iam_policy_document.lake_tls_only: Read complete after 0s [id=2205495074]
data.aws_iam_policy_document.lake_access: Reading...
module.network.data.aws_availability_zones.available: Read complete after 1s [id=us-east-2]
data.aws_iam_policy_document.lake_access: Read complete after 0s [id=3442692123]
data.aws_rds_engine_version.aurora_pg: Read complete after 1s [id=17.9]
data.aws_iam_policy_document.ci_deploy_dev: Reading...
data.aws_iam_policy_document.ci_deploy_dev: Read complete after 0s [id=1754478413]
data.aws_iam_openid_connect_provider.github: Read complete after 1s [id=arn:aws:iam::797781631727:oidc-provider/token.actions.githubusercontent.com]
data.aws_iam_policy_document.ci_deploy_dev_trust: Reading...
data.aws_iam_policy_document.ci_deploy_dev_trust: Read complete after 0s [id=4060172364]

Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # aws_cloudwatch_metric_alarm.span_export_silence["api"] will be updated in-place
  ~ resource "aws_cloudwatch_metric_alarm" "span_export_silence" {
        id                                    = "er-dev-span-export-silence-api"
        # (22 unchanged attributes hidden)

      - metric_query {
          - id          = "ended" -> null
          - return_data = false -> null
            # (3 unchanged attributes hidden)

          - metric {
              - dimensions  = {
                  - "er.role" = "api"
                } -> null
              - metric_name = "er.telemetry.spans_ended" -> null
              - namespace   = "ER/Dev" -> null
              - period      = 300 -> null
              - stat        = "Maximum" -> null
                # (1 unchanged attribute hidden)
            }
        }
      - metric_query {
          - id          = "exported" -> null
          - return_data = false -> null
            # (3 unchanged attributes hidden)

          - metric {
              - dimensions  = {
                  - "er.role" = "api"
                } -> null
              - metric_name = "er.telemetry.spans_exported" -> null
              - namespace   = "ER/Dev" -> null
              - period      = 300 -> null
              - stat        = "Maximum" -> null
                # (1 unchanged attribute hidden)
            }
        }
      - metric_query {
          - expression  = "IF(RATE(ended)>0 AND RATE(exported)==0, 1, 0)" -> null
          - id          = "silence" -> null
          - label       = "spans ending but none exported" -> null
          - return_data = true -> null
            # (1 unchanged attribute hidden)
        }
      + metric_query {
          + id          = "ended"
          + return_data = false
            # (3 unchanged attributes hidden)

          + metric {
              + dimensions  = {
                  + "OTelLib" = "er-obs"
                  + "er.role" = "api"
                }
              + metric_name = "er.telemetry.spans_ended"
              + namespace   = "ER/Dev"
              + period      = 300
              + stat        = "Sum"
                # (1 unchanged attribute hidden)
            }
        }
      + metric_query {
          + id          = "exported"
          + return_data = false
            # (3 unchanged attributes hidden)

          + metric {
              + dimensions  = {
                  + "OTelLib" = "er-obs"
                  + "er.role" = "api"
                }
              + metric_name = "er.telemetry.spans_exported"
              + namespace   = "ER/Dev"
              + period      = 300
              + stat        = "Sum"
                # (1 unchanged attribute hidden)
            }
        }
      + metric_query {
          + expression  = "IF(ended>0 AND FILL(exported,0)==0, 1, 0)"
          + id          = "silence"
          + label       = "spans ending but none exported"
          + return_data = true
            # (1 unchanged attribute hidden)
        }
    }

  # aws_cloudwatch_metric_alarm.span_export_silence["dispatcher"] will be updated in-place
  ~ resource "aws_cloudwatch_metric_alarm" "span_export_silence" {
        id                                    = "er-dev-span-export-silence-dispatcher"
        # (22 unchanged attributes hidden)

      - metric_query {
          - id          = "ended" -> null
          - return_data = false -> null
            # (3 unchanged attributes hidden)

          - metric {
              - dimensions  = {
                  - "er.role" = "dispatcher"
                } -> null
              - metric_name = "er.telemetry.spans_ended" -> null
              - namespace   = "ER/Dev" -> null
              - period      = 300 -> null
              - stat        = "Maximum" -> null
                # (1 unchanged attribute hidden)
            }
        }
      - metric_query {
          - id          = "exported" -> null
          - return_data = false -> null
            # (3 unchanged attributes hidden)

          - metric {
              - dimensions  = {
                  - "er.role" = "dispatcher"
                } -> null
              - metric_name = "er.telemetry.spans_exported" -> null
              - namespace   = "ER/Dev" -> null
              - period      = 300 -> null
              - stat        = "Maximum" -> null
                # (1 unchanged attribute hidden)
            }
        }
      - metric_query {
          - expression  = "IF(RATE(ended)>0 AND RATE(exported)==0, 1, 0)" -> null
          - id          = "silence" -> null
          - label       = "spans ending but none exported" -> null
          - return_data = true -> null
            # (1 unchanged attribute hidden)
        }
      + metric_query {
          + id          = "ended"
          + return_data = false
            # (3 unchanged attributes hidden)

          + metric {
              + dimensions  = {
                  + "OTelLib" = "er-obs"
                  + "er.role" = "dispatcher"
                }
              + metric_name = "er.telemetry.spans_ended"
              + namespace   = "ER/Dev"
              + period      = 300
              + stat        = "Sum"
                # (1 unchanged attribute hidden)
            }
        }
      + metric_query {
          + id          = "exported"
          + return_data = false
            # (3 unchanged attributes hidden)

          + metric {
              + dimensions  = {
                  + "OTelLib" = "er-obs"
                  + "er.role" = "dispatcher"
                }
              + metric_name = "er.telemetry.spans_exported"
              + namespace   = "ER/Dev"
              + period      = 300
              + stat        = "Sum"
                # (1 unchanged attribute hidden)
            }
        }
      + metric_query {
          + expression  = "IF(ended>0 AND FILL(exported,0)==0, 1, 0)"
          + id          = "silence"
          + label       = "spans ending but none exported"
          + return_data = true
            # (1 unchanged attribute hidden)
        }
    }

Plan: 0 to add, 2 to change, 0 to destroy.

@athvin
athvin merged commit c70538e into main Nov 9, 2026
42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix span-export alarms to match CloudWatch dimensions and delta counters

2 participants