Skip to content

feat(telemetry): name the repository the same way in logs and traces #4576

Done

Description

@dan-petty

Update 2026-11-26 (infra move): the log label setting goes to dan-petty/homelab.

  • k8s/monitoring/k8s-monitoring-values.yaml here is gone after step 17. The podLogsViaLoki.annotations entry is the follow-up issue.
  • This issue keeps the log filter, the VCS span attributes and the metric label.
  • The merged plan openspec/changes/4576-* needs a change: drop task group 6. Group 7 renders k8s/overlays/homelab/devops, which step 17 deletes; render k8s/devops.

Follow-up: dan-petty/homelab#270.


Problem or Motivation

The logs, metrics and traces of the roadmap Service name a repository in different ways. Loki has no repo label for a Job pod, and the router logs carry the repository only in the message text. Traces use service.repo. When the rows move into their own pods, one Grafana variable must filter logs, metrics and traces for one repository with one value.

Proposed Solution & Architectural Design

Use the casefolded key of RepoRef in all telemetry:

  • A logging filter that copies repo = key into each record of the router and the sweep (the pattern of TraceCorrelationFilter, src/devops_cli/telemetry/logging_bridge.py:77).
  • The OpenTelemetry VCS span attributes (vcs.provider.name=github, vcs.owner.name, vcs.repository.name) in place of service.repo. The item number is a span attribute only.
  • podLogsViaLoki.annotations: {repo: roadmap.devops-cli/repository} in k8s/monitoring/k8s-monitoring-values.yaml of dan-petty/homelab (follow-up issue), so a unit pod's logs get the stream label repo.
  • The metric repo value from RepoRef (other for a repository outside service.repos). Never an item number, a unit name, a branch or a pod name in a Service metric label.

Target Subsystem

Kubernetes & Minikube Automation (telemetry: src/devops_cli/telemetry/, k8s/monitoring/).

Existing Tool Considered

OpenTelemetry VCS semantic conventions and the k8s-monitoring chart's podLogsViaLoki.annotations (open tools). Cost: about 200,000 tokens and 2 hours to build, about 5,000 tokens a month to keep, about 20,000 tokens to fix.

Acceptance Criteria

  • {service_name="roadmap-service"} | json | repo="<owner>/<name>" returns lines from each repository's work.
  • {repo="<owner>/<name>"} returns the lines of a unit pod, and the value is the casefolded key in logs, metrics and traces.
  • TraceQL {span.vcs.repository.name="<name>"} finds round spans.
  • count by (repo) over devops_cli_service_* gives only service.repos values and other.
  • The router pod gets no new stream label.

Dependencies

  • "feat(roadmap): name each repository's resources from one RepoRef".
  • "feat(roadmap): label Service Jobs by repository and item" (the pod annotation).

Source: #4517

Alternatives check of 2026-11-19: in-use.
The item already names this tool.
Tool: open-telemetry/semantic-conventions (https://github.com/open-telemetry/semantic-conventions), Apache-2.0, last activity 2026-11-18, maintained.
Reason: Searches found the OpenTelemetry VCS semantic conventions and the k8s-monitoring chart, both open and maintained; they cover trace span attributes and the Loki pod-annotation stream label, but not the Python log-record filter or the bounded Service metric label.

Covers:

  • vcs.provider.name, vcs.owner.name and vcs.repository.name span attributes
  • Vendor-neutral convention read by Tempo and Grafana
  • Adopted by ADR 0022 for span attributes

Lacks:

  • No Python log-record filter that copies the repo key
  • No Loki stream label from a pod annotation
  • No bounded repo metric label with an other fallback
  • No router JSON log body field

Proposed design

Problem statement

The roadmap Service names a repository in different ways in its logs, metrics and traces. The router and the sweep put the repository only in the message text, and traces use the custom attribute service.repo. One Grafana variable cannot filter logs, metrics and traces for one repository with one value. This change puts the casefolded RepoRef key in each signal. The Loki stream label from the pod annotation is the follow-up dan-petty/homelab#270, because the collector values left this repository in step 17.

Acceptance criteria

Requirement: Router log record carries the repository key

Each log record that the Service json handler writes while a RepoRef is current SHALL carry repo with the casefolded key.

Scenario: A router record names its repository

  • WHEN a test sets the current RepoRef to dan-petty/devops-cli and writes one record from the devops_cli logger, which does not propagate, through the json handler of service_log_config
  • THEN the parsed JSON line holds repo equal to dan-petty/devops-cli

Requirement: Sweep log record holds the casefolded key

The repo field of a log record SHALL hold the casefolded RepoRef key, also when the display spelling has capital letters.

Scenario: A sweep record for a repository with capitals

  • WHEN a test sets the current RepoRef to Dan-Petty/DevOps-CLI and writes one record through the json handler of service_log_config
  • THEN the parsed JSON line holds repo equal to dan-petty/devops-cli

Requirement: No repository field without a current reference

A log record that the json handler writes with no current RepoRef MUST NOT carry a repo field.

Scenario: A service-level record with no repository

  • WHEN a test clears the current RepoRef and writes one record through the json handler of service_log_config
  • THEN the parsed JSON line holds no repo key

Requirement: Round span uses the VCS repository attributes

A round span SHALL carry vcs.provider.name, vcs.owner.name and vcs.repository.name, and MUST NOT carry service.repo.

Scenario: A round span names its repository

  • WHEN a test starts a round for dan-petty/devops-cli with an in-memory span recorder
  • THEN the span holds vcs.provider.name=github, vcs.owner.name=dan-petty and vcs.repository.name=devops-cli, and holds no service.repo

Requirement: Metric label for a configured repository

The repo label of a devops_cli_service_* metric SHALL equal the casefolded RepoRef key when service.repos holds the repository.

Scenario: A metric for a configured repository

  • WHEN a test records a Service metric for dan-petty/devops-cli, which service.repos holds
  • THEN the metric sample holds repo equal to dan-petty/devops-cli

Requirement: Metric label outside the configured repositories

The repo label of a devops_cli_service_* metric MUST be other for a repository that service.repos does not hold.

Scenario: A metric for a repository outside service.repos

  • WHEN a test records a Service metric for a repository that service.repos does not hold
  • THEN the metric sample holds repo equal to other

Existing Tool Considered

open-telemetry/semantic-conventions (in-use): the item already names this tool, and ADR 0022 adopts its VCS span attributes. The alternatives check in the issue body records the verdict and what the tool covers and lacks. The tool lacks a Python log-record filter, a bounded metric label and a router JSON field. The change adds a logging.Filter that copies the casefolded RepoRef key from a contextvar into repo, and a metric repo value of key or other. Written cost: about 200,000 tokens and 2 hours to build, about 5,000 tokens a month to keep, and about 20,000 tokens to fix. The Loki stream label from a pod annotation is the follow-up dan-petty/homelab#270.

Key questions

  • Which log handler carries the repository filter?: Attach a logging.Filter to the Service json handler in service_log_config, as TraceCorrelationFilter is attached there. A filter on the root logger misses a Service logger that does not propagate. (best practice) [sources: src/devops_cli/server/json_logs.py, src/devops_cli/telemetry/logging_bridge.py:77]
    • Chosen: Attach to the Service json handler. It sees each record that the handler formats, as TraceCorrelationFilter does, also from a logger with propagate: False.
    • Rejected: Attach to the root logger. A Service logger that does not propagate bypasses it.
    • Rejected: Attach to each module logger. It misses the records that libraries write and needs many call sites.
  • How does a log record learn the repository of the work that it names?: A contextvar in a new src/devops_cli/telemetry/repo_context.py holds the current RepoRef. The webhook handler sets it for a request, and the sweep sets it for each repository of a round. A logging.Filter copies the casefolded key into repo. (best practice) [sources: docs/adr/0022-one-repository-reference-names-the-objects-labels-and-keys-of-each-repository.md, src/devops_cli/telemetry/logging_bridge.py:77]
    • Chosen: Contextvar set at the edge and read by a filter. ADR 0022 parses owner/name one time at the edge, and one filter names each record with no change to a call site.
    • Rejected: Parse the message or the record arguments. Messages change, and some records name no repository.
    • Rejected: Pass repo to each logging call. It changes many call sites and misses the records that libraries write.
  • Which span attributes name the repository?: Use vcs.provider.name=github, vcs.owner.name and vcs.repository.name, and remove service.repo. The item number stays a span attribute only. (best practice) [sources: docs/adr/0022-one-repository-reference-names-the-objects-labels-and-keys-of-each-repository.md]
    • Chosen: OpenTelemetry VCS conventions. An open, maintained convention that Tempo and Grafana read, and ADR 0022 section 6 adopts it.
    • Rejected: Keep service.repo. No convention or dashboard reads a project-specific key.
    • Rejected: Add a project repo span attribute. It duplicates the VCS names, and no standard tool reads it.
  • What value does the repo metric label take for a repository outside service.repos?: other. One fixed value bounds the label set, so a webhook from an unknown repository cannot grow it. (best practice) [sources: docs/adr/0022-one-repository-reference-names-the-objects-labels-and-keys-of-each-repository.md, src/devops_cli/github/metrics.py:130]
    • Chosen: other for a repository outside service.repos. It bounds the label cardinality and keeps a fixed value.
    • Rejected: The RepoRef key for every repository. A webhook from any repository would grow the metric label set without limit.
    • Rejected: No repo label. The metric cannot group by repository.
  • What does a log record do when no RepoRef is current?: It carries no repo field. JsonLogFormatter writes a context key only when the record attribute is not None. (best practice) [sources: src/devops_cli/server/json_logs.py]
    • Chosen: Omit repo when no RepoRef is current. A service-level record names no repository, and an empty value would mislead a query.
    • Rejected: Write other. other is a metric value for a repository outside service.repos, not for a record with no repository.
  • Does the router pod get a repo stream label?: No. The chart annotation applies to unit pods only, and that mapping is the homelab follow-up. The router writes repo into the JSON body of each line. (best practice) [sources: docs/adr/0022-one-repository-reference-names-the-objects-labels-and-keys-of-each-repository.md, src/devops_cli/server/json_logs.py]
    • Chosen: Keep the router stream labels and put repo in the JSON body. One pod keeps one stream set, and a | json | repo=... filter finds the lines of one repository.
    • Rejected: Add a repo stream label to the router pod. The router serves many repositories, so its stream set would multiply.
  • What does RepoRef.key hold?: The casefolded owner/name. Two RepoRef values are equal when their key values are equal. [sources: src/devops_cli/github/repo_ref.py:103, tests/github/test_repo_ref.py, docs/adr/0022-one-repository-reference-names-the-objects-labels-and-keys-of-each-repository.md]
  • Where does the Loki stream label mapping for the pod annotation live?: In dan-petty/homelab, as the follow-up dan-petty/homelab#270. The environment tree of the homelab cluster lives only in dan-petty/homelab, so this repository holds no k8s/monitoring/k8s-monitoring-values.yaml after step 17. [sources: CONTEXT.md, docs/adr/0022-one-repository-reference-names-the-objects-labels-and-keys-of-each-repository.md]
  • Which dependency remains for this issue?: No dependency remains. ADR 0022 is accepted, so feat(roadmap): name each repository's resources from one RepoRef #4533 is delivered. feat(roadmap): label Service Jobs by repository and item #4558 writes the pod annotation that the homelab chart maps, and no criterion here reads it. (best practice) [sources: docs/adr/0022-one-repository-reference-names-the-objects-labels-and-keys-of-each-repository.md, CONTEXT.md]
  • Which capability holds the remaining requirements?: The product telemetry capability of this repository. The plan folder holds no requirement of monitoring-collectors, because step 17 retires that capability and an archive would recreate it with a placeholder Purpose. (best practice) [sources: CONTEXT.md, docs/adr/0022-one-repository-reference-names-the-objects-labels-and-keys-of-each-repository.md]
    • Chosen: Keep only the product requirements. The collector files are in dan-petty/homelab, so this change adds no requirement to monitoring-collectors.
    • Rejected: Keep the collector requirements in this change. The archive would recreate the retired spec with a placeholder Purpose and fail validation.
  • Which path does the plan render for the product manifests?: k8s/devops, the product base that devops-cli ships. The plan renders no path under k8s/overlays/homelab/, which step 17 deletes. (best practice) [sources: CONTEXT.md]
    • Chosen: k8s/devops. It is the product base that devops-cli ships, and it stays in this repository.
    • Rejected: k8s/overlays/homelab/devops. Step 17 deletes it, so a render of that path fails.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

#4533, #4558

Activity

  1. added
    source/agent
    on Nov 11, 2026
  2. added
    type/feature
    scope/telemetry
    status/new
    value/medium
    effort/low
    on Nov 11, 2026
  3. dan-petty commented on Nov 11, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/feature. The feat prefix of the title gives the type.
    • Scope: scope/telemetry. The (telemetry) scope of the title gives the scope.
    • Priority: P2-Medium. Improves observability filtering but does not block a release or fix a failure.
    • Value: Medium. Lets one Grafana variable filter all three telemetry signals for one repository.
    • Effort: Low. Body states about 2 hours to build across four small file changes.
    • Related: fix(telemetry): Service counters read true across pods and repos #3495, which asks for a different change. Both deal with repository labels in Service metrics, but #3495 fixes counter accuracy while the candidate standardises the repo name value.
  4. added
    priority/p2-medium
    on Nov 11, 2026
  5. devops-cli-service commented on Nov 11, 2026

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at 818ac6f while the items below stay open. The next refine round looks at the item again when they close, or when a person replies in a comment or edits the body.

  6. devops-cli-service commented on Nov 14, 2026

    @devops-cli-service
    Contributor

    Waiting for the alternatives check to run. The next refine round looks at the item again after the check records a verdict.

  7. devops-cli-service commented on Nov 19, 2026

    @devops-cli-service
    Contributor

    The result in the alternatives block of the issue body changed. Before this check: no check. A person decides what the new result means for the item.

    Searches (10)

    Tools considered:

    Searches run:

    • k8s-monitoring podLogsViaLoki annotations map pod annotation to Loki stream label, results: 5
    • OpenTelemetry semantic conventions vcs.repository.name vcs.owner.name span attributes, results: 5
    • grafana k8s-monitoring values podLogsViaLoki annotations documentation, results: 5
    • opentelemetry semantic conventions VCS attributes vcs.provider.name github, results: 5
    • site:opentelemetry.io vcs.repository.name, results: 5
    • site:grafana.com docs k8s-monitoring podLogsViaLoki annotations, results: 5
    • grafana k8s monitoring chart Loki pod logs annotations, results: 5
    • OpenTelemetry VCS semantic conventions, results: 5
    • "vcs.repository.name" semantic conventions, results: 5
    • "podLogsViaLoki" annotations Loki, results: 5

    Sources:

  8. added
    status/ready
    and removed
    status/new
    on Nov 19, 2026
  9. devops-cli-service commented on Nov 19, 2026

    @devops-cli-service
    Contributor

    Next step: the stage job writes the plan of the item. See the section Proposed design of the body.

  10. 20 remaining items

  11. added
    status/ready
    on Nov 26, 2026
  12. devops-cli-service commented on Nov 26, 2026

    @devops-cli-service
    Contributor

    Next step: the stage job writes the plan of the item. See the section Proposed design of the body.

  13. added
    status/planned
    and removed
    status/ready
    on Nov 26, 2026
  14. dan-petty commented on Nov 27, 2026

    @dan-petty
    OwnerAuthor

    Finding from the homelab half (dan-petty/homelab#270, pull request dan-petty/homelab#440): the stage pods carry no annotation roadmap.devops-cli/repository, so their log lines get no repo stream label.

    The pull request maps the pod annotation to the Loki stream label repo with the chart value podLogsViaLoki.annotations: {repo: roadmap.devops-cli/repository}. A live test with the rendered collector config gave repo="dan-petty/homelab" on the lines of a pod with the annotation, and no repo label on a pod with no annotation.

    Evidence of 2026-11-27:

    • kubectl -n devops get pods -o json: 12 of 12 pods of the Jobs implement and fix-checks carry the annotation with the casefolded owner/name. 0 of 34 stage pods carry it. The stage pods carry the labels roadmap.devops-cli/owner, roadmap.devops-cli/repo and roadmap.devops-cli/item.
    • Cause: build_job sets the annotation only when the caller passes repo (src/devops_cli/k8s/cluster_job.py:314-322). _submit of the stage row calls api.create(...) with labels=stage_job_labels(ref, item.number) and no repo (src/devops_cli/roadmap/stage/stage_submit.py:325-332). The runner rows pass repo (_options in src/devops_cli/roadmap/job_launcher.py).
    • ADR 0022 section 3 puts the annotation on each Service Job and pod, and section 6 reads the log label from it.

    The criterion "{repo="<owner>/<name>"} returns the lines of a unit pod" holds for the stage pods only when the stage Job writes the annotation. #6594 asks for the annotation on the stage Workflow; the stage Job of today has none.

    The homelab change does not join the two pod labels in place of the annotation: RepoRef changes a part that is no label value, so the joined value is not always key.

  15. added
    owner/agent
    status/in-progress
    status/in-review
    and removed
    status/planned
    status/in-progress
    on Nov 30, 2026
  16. devops-cli-service commented on Nov 30, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-30 19:09 UTC

  17. removed
    status/in-review
    owner/agent
    on Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/lowpriority/p2-mediumscope/telemetrysource/agenttype/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions