Skip to content

Tag RADIS telemetry per service in observability overlay#219

Merged
samuelvkwong merged 6 commits into
mainfrom
feat/per-service-otel-tagging
May 8, 2026
Merged

Tag RADIS telemetry per service in observability overlay#219
samuelvkwong merged 6 commits into
mainfrom
feat/per-service-otel-tagging

Conversation

@samuelvkwong
Copy link
Copy Markdown
Collaborator

@samuelvkwong samuelvkwong commented Apr 27, 2026

Summary

  • Restructures `docker-compose.override.yml.example` so `service.namespace` and `deployment.environment` are defined once at the top in a shared YAML anchor.
  • Each of the 4 services merges the shared anchor and adds only its own `SERVICE_COMPONENT` env var (`init`, `web`, `default_worker`, `llm_worker`).
  • Header documents the per-stack `sed` workflow for switching `production` → `staging`/`development` after copying the example.

Why

OpenObserve telemetry was tagged with a single `service.name` per stack, collapsing all containers under one identity. With this overlay every signal carries:

Attribute Value
`service.name` `${STACK_NAME}` (e.g. `radis_prod`, `radis_staging`)
`service.component` the compose service that emitted it
`service.namespace` `openradx`
`deployment.environment` `production` (default) / `staging` / `development`

This makes telemetry filterable per stack, per component, and per deployment environment.

Dependency

`service.component` is set via a custom `SERVICE_COMPONENT` env var that the `adit-radis-shared` telemetry helper reads — see openradx/adit-radis-shared#186. `pyproject.toml` will need updating from tag `0.21.0` to that branch (or a follow-up tag) before this PR's effect is visible end-to-end.

Sibling PR

Test plan

  • `docker compose config --quiet` parses the new overlay successfully
  • All 4 services produce unique `SERVICE_COMPONENT` values matching their compose keys
  • `OTEL_RESOURCE_ATTRIBUTES` is identical across services and `OTEL_SERVICE_NAME` resolves to `${STACK_NAME}`
  • After deploying with the new shared-lib version, verify in OpenObserve that records carry the four attributes above

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Refactor
    • Reorganized Docker Compose observability configuration to separate network and environment definitions for improved modularity and maintainability.

Restructure the overlay so service.namespace and deployment.environment live
once in a shared env anchor; each service merges that anchor and adds only
its own SERVICE_COMPONENT value (consumed by adit_radis_shared/telemetry.py).
service.name comes from OTEL_SERVICE_NAME=${STACK_NAME}, dynamically resolved
by the existing CLI helper.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 27, 2026

Warning

Rate limit exceeded

@samuelvkwong has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 59 minutes and 58 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6a2e82a7-c21d-42d6-86df-ed54dd469f15

📥 Commits

Reviewing files that changed from the base of the PR and between 7fdc030 and 6edc40b.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (2)
  • docker-compose.override.yml.example
  • pyproject.toml
📝 Walkthrough

Walkthrough

The docker-compose.override.yml.example file refactors observability configuration by splitting a monolithic x-observability anchor into two modular anchors (x-observability-net and x-observability-env). Each service now inherits both anchors separately and explicitly declares its SERVICE_COMPONENT label.

Changes

Observability Configuration Modularization

Layer / File(s) Summary
Anchor Definitions
docker-compose.override.yml.example
New x-observability-net anchor defines shared networks (default, openradx-observability). New x-observability-env anchor defines shared OTEL environment variables and resource attributes.
Network Configuration
docker-compose.override.yml.example
Top-level networks section added to declare openradx-observability as external.
Service Updates
docker-compose.override.yml.example
All four services (init, web, default_worker, llm_worker) now inherit from *observability-net and *observability-env separately and add explicit SERVICE_COMPONENT label. Old monolithic x-observability anchor is removed.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • openradx/radis#191: Directly related as it involves Docker Compose observability configuration changes; this PR refactors the x-observability anchor structure introduced or modified in that PR.

Poem

🐰 Anchors split like carrot sticks so neat,
Observability networks and env, complete!
Each service knows its role with pride,
Modular configs, side by side!
A cleaner compose, hopping with delight! 🥕✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title accurately describes the main change: refactoring the observability configuration to tag telemetry per service using modular YAML anchors.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/per-service-otel-tagging

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the observability configuration in docker-compose.override.yml.example by introducing separate anchors for network and environment settings and adding comprehensive documentation. Feedback suggests improving maintainability by leveraging Docker Compose variable interpolation for the environment setting instead of manual sed commands. Additionally, it is recommended to use the ${VAR:-} syntax for STACK_NAME and ENVIRONMENT to avoid 'variable not set' warnings and ensure consistency across configurations.

Comment on lines +13 to +17
# 2. If this is a staging or development deployment, edit the
# `deployment.environment=production` value inside `OTEL_RESOURCE_ATTRIBUTES`
# below to `staging` or `development`:
# sed -i 's/deployment.environment=production/deployment.environment=staging/' \
# docker-compose.override.yml
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Instead of recommending a manual sed workflow to update the environment tag, it's more idiomatic and maintainable to leverage Docker Compose's variable interpolation. Since the ENVIRONMENT variable is already defined in the project's example.env, we can use it directly in the configuration below.

#   2. If this is a staging or development deployment, set the `ENVIRONMENT` 
#      variable in your `.env` file to `staging` or `development`. 
#      The `deployment.environment` attribute below will automatically 
#      pick it up.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The linked discussion clarifies that the sed approach is intended as a one-time setup step for the user after copying the example file, rather than a runtime requirement. Given this context, the current implementation is acceptable as it provides a clear, explicit instruction for the initial configuration of the environment-specific deployment tag.

Comment on lines +31 to +32
OTEL_SERVICE_NAME: ${STACK_NAME}
OTEL_RESOURCE_ATTRIBUTES: "service.namespace=openradx,deployment.environment=production"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency with docker-compose.base.yml and to avoid "variable not set" warnings when running docker compose outside of the CLI wrapper, use the ${VAR:-} syntax for STACK_NAME. Additionally, use the ENVIRONMENT variable for the deployment environment attribute as suggested in the header to simplify per-stack configuration.

  OTEL_SERVICE_NAME: ${STACK_NAME:-}
  OTEL_RESOURCE_ATTRIBUTES: "service.namespace=openradx,deployment.environment=${ENVIRONMENT:-production}"

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the link. I have reviewed the context provided in the linked discussion. Given that STACK_NAME is guaranteed to be injected by the CLI wrapper as described in the file header, the current implementation is acceptable. I will retract the suggestion regarding the :- syntax for STACK_NAME.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docker-compose.override.yml.example`:
- Around line 16-17: The sed -i example is not portable to BSD/mac sed; update
the example around the commented line containing "sed -i
's/deployment.environment=production/deployment.environment=staging/'" to show a
portable alternative: document both the GNU form (sed -i 's/.../.../') and the
BSD/mac form that requires a zero-length backup suffix (sed -i '' 's/.../.../'),
or replace with a portable one-liner (e.g., using perl -pi -e) and mention which
variant to use on macOS vs Linux so users on both platforms can run the command
without errors.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 270b8046-32f6-4b34-8382-08c2cd617285

📥 Commits

Reviewing files that changed from the base of the PR and between d2b909e and 7fdc030.

📒 Files selected for processing (1)
  • docker-compose.override.yml.example

Comment on lines +16 to +17
# sed -i 's/deployment.environment=production/deployment.environment=staging/' \
# docker-compose.override.yml
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Make the sed -i example portable across GNU/BSD sed.

The current command works on GNU sed but fails on macOS/BSD sed without a backup suffix argument. Consider documenting both forms (or use a portable alternative) to avoid setup friction.

Suggested doc tweak
-#        sed -i 's/deployment.environment=production/deployment.environment=staging/' \
-#          docker-compose.override.yml
+#        # GNU sed (Linux):
+#        sed -i 's/deployment.environment=production/deployment.environment=staging/' \
+#          docker-compose.override.yml
+#        # BSD sed (macOS):
+#        sed -i '' 's/deployment.environment=production/deployment.environment=staging/' \
+#          docker-compose.override.yml
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docker-compose.override.yml.example` around lines 16 - 17, The sed -i example
is not portable to BSD/mac sed; update the example around the commented line
containing "sed -i
's/deployment.environment=production/deployment.environment=staging/'" to show a
portable alternative: document both the GNU form (sed -i 's/.../.../') and the
BSD/mac form that requires a zero-length backup suffix (sed -i '' 's/.../.../'),
or replace with a portable one-liner (e.g., using perl -pi -e) and mention which
variant to use on macOS vs Linux so users on both platforms can run the command
without errors.

samuelvkwong and others added 4 commits May 7, 2026 10:34
Swarm interpolates {{.Task.Slot}} to the replica ordinal so telemetry.py
in adit-radis-shared can suffix service.component with `-N` (e.g.
default_worker-1, -2, -3). Outside Swarm the literal template is passed
through and the shared helper drops it, leaving dev signals clean.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@samuelvkwong samuelvkwong merged commit 653e0c6 into main May 8, 2026
2 checks passed
@samuelvkwong samuelvkwong deleted the feat/per-service-otel-tagging branch May 8, 2026 23:03
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.

1 participant