Skip to content

fix(otelutil,search-service): env-skip OTLP and env-drive search indices#166

Merged
GITMateuszCharczuk merged 1 commit into
mainfrom
claude/otelutil-and-spotlight-env
May 8, 2026
Merged

fix(otelutil,search-service): env-skip OTLP and env-drive search indices#166
GITMateuszCharczuk merged 1 commit into
mainfrom
claude/otelutil-and-spotlight-env

Conversation

@Joey0538
Copy link
Copy Markdown
Collaborator

@Joey0538 Joey0538 commented May 8, 2026

Summary

Two small dev-loop quality fixes pulled out of the PR #148 dev-stack rebase. Both are env-driven and have no prod behavior change beyond their explicit env triggers.

pkg/otelutil

InitTracer no longer attempts to dial an OTLP gRPC collector when neither OTEL_EXPORTER_OTLP_ENDPOINT nor OTEL_EXPORTER_OTLP_TRACES_ENDPOINT is set. Installs only the W3C TraceContext propagator (so trace IDs still flow between services) and returns a no-op shutdown. Stops the traces export: connection refused log spam in local dev / CI runs that don't have a collector. Behavior is unchanged once either env is set.

search-service

  • New SPOTLIGHT_INDEX env var (,required), plumbed through handlerConfig into searchRooms. handler.go was hardcoding the package-level const SpotlightIndex = "spotlight" which 404s against the site-suffixed concrete indices written by search-sync-worker.
  • USER_ROOM_INDEX tightened from envDefault:"" to ,required — same failure mode otherwise (empty default → silently zero results).
  • deploy/docker-compose.yml pins both env vars to the concrete site-local indices so make up works against a fresh dev stack. Prod uses aliases owned by ops/IaC.

Test plan

  • make lint clean
  • make test clean (full repo)
  • go build ./... clean
  • make up against a fresh stack: search-service starts, searchRooms returns data instead of 404
  • Service running without OTEL_EXPORTER_OTLP_* env: no traces export: connection refused lines

Notes

https://claude.ai/code/session_01UkLD7hpaypxjeh5zbEWTjp


Generated by Claude Code

Summary by CodeRabbit

  • New Features

    • Search service now supports configurable Elasticsearch index names for user room and spotlight data via environment variables.
    • Telemetry initialization is now optional—skips OTLP exporter setup when endpoints are not configured.
  • Chores

    • Updated Docker Compose configuration with new required index name settings.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 8, 2026

Review Change Stack

Warning

Rate limit exceeded

@Joey0538 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 50 minutes and 42 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: b0efe5a0-c396-4bf7-a8e7-6c6480e76356

📥 Commits

Reviewing files that changed from the base of the PR and between b56c932 and 8b890a9.

📒 Files selected for processing (7)
  • pkg/otelutil/otel.go
  • search-service/deploy/docker-compose.yml
  • search-service/handler.go
  • search-service/handler_test.go
  • search-service/integration_test.go
  • search-service/main.go
  • search-service/query_rooms.go
📝 Walkthrough

Walkthrough

This PR introduces two independent changes: conditional OTLP tracer initialization that skips exporter creation when endpoint environment variables are unset, and configurable Elasticsearch index selection in the search service via required environment variables and handler configuration wiring.

Changes

OTLP Tracer Conditional Initialization

Layer / File(s) Summary
Conditional Initialization Logic
pkg/otelutil/otel.go
Adds os import and implements early-return in InitTracer when OTLP endpoint env vars are unset, setting TraceContext propagator and returning no-op shutdown instead of creating an exporter.

Configurable Elasticsearch Indices

Layer / File(s) Summary
Configuration Structure
search-service/main.go
SearchConfig adds required SpotlightIndex field and makes UserRoomIndex required (removing empty default), both sourced from environment variables.
Handler Configuration
search-service/handler.go
handlerConfig gains SpotlightIndex field; searchRooms now uses h.cfg.SpotlightIndex for ES queries instead of hardcoded identifier.
Service Initialization
search-service/main.go
handlerConfig initialization wires cfg.Search.SpotlightIndex alongside existing index and request-shape configuration.
Tests and Deployment
search-service/handler_test.go, search-service/deploy/docker-compose.yml
Test handler setup and docker-compose now include explicit SpotlightIndex configuration; compose also defines SEARCH_USER_ROOM_INDEX and SEARCH_SPOTLIGHT_INDEX environment variables pinned to site-suffixed indices.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 The indices now dance to the config's sweet tune,
No hardcoded names under the moon,
And traces that whisper when endpoints are gone,
Graceful no-ops carry the dawn! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title clearly summarizes both main changes: OTLP env-skip logic and environment-driven search index configuration.
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 claude/otelutil-and-spotlight-env

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

@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.

🧹 Nitpick comments (1)
search-service/handler_test.go (1)

87-87: ⚡ Quick win

Remove the dead SpotlightIndex constant from production code or move it to _test.go.

The SpotlightIndex constant is declared in query_rooms.go but not used anywhere in production code. Handler and main use the config value (h.cfg.SpotlightIndex and cfg.Search.SpotlightIndex) instead. The constant only appears in tests (lines 87 and 238). Either remove it and replace test references with a local sentinel value, or move it into a test helper file.

🤖 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 `@search-service/handler_test.go` at line 87, Remove the unused production
constant SpotlightIndex from query_rooms.go and update tests to reference a
test-local sentinel instead: delete the SpotlightIndex declaration, then in
tests (e.g., handler_test.go lines referencing SpotlightIndex) replace those
references with a test-only constant defined in the _test.go file (or a test
helper), ensuring production uses h.cfg.SpotlightIndex /
cfg.Search.SpotlightIndex unchanged; update imports if you move the sentinel to
a helper test file.
🤖 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.

Nitpick comments:
In `@search-service/handler_test.go`:
- Line 87: Remove the unused production constant SpotlightIndex from
query_rooms.go and update tests to reference a test-local sentinel instead:
delete the SpotlightIndex declaration, then in tests (e.g., handler_test.go
lines referencing SpotlightIndex) replace those references with a test-only
constant defined in the _test.go file (or a test helper), ensuring production
uses h.cfg.SpotlightIndex / cfg.Search.SpotlightIndex unchanged; update imports
if you move the sentinel to a helper test file.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0eb23879-aadc-451f-8226-35ab38f9a5b6

📥 Commits

Reviewing files that changed from the base of the PR and between a2c2826 and b56c932.

📒 Files selected for processing (5)
  • pkg/otelutil/otel.go
  • search-service/deploy/docker-compose.yml
  • search-service/handler.go
  • search-service/handler_test.go
  • search-service/main.go

Two small dev-loop quality fixes bundled into one PR.

pkg/otelutil:
- InitTracer skips the OTLP gRPC exporter setup when neither
  OTEL_EXPORTER_OTLP_ENDPOINT nor OTEL_EXPORTER_OTLP_TRACES_ENDPOINT is
  set, installing only the W3C TraceContext propagator and returning a
  no-op shutdown. Stops `traces export: connection refused` log spam in
  local dev / CI when no OTel collector runs. With the env set, behavior
  is unchanged.

search-service:
- New SPOTLIGHT_INDEX env var (required), plumbed through handlerConfig
  into searchRooms. handler.go was hardcoding the package-level const
  `SpotlightIndex = "spotlight"` which 404s against site-suffixed
  indices written by search-sync-worker.
- Tighten USER_ROOM_INDEX from `envDefault:""` to `,required` so the
  empty-default 404 is caught at startup instead of silently returning
  zero results.
- deploy/docker-compose.yml pins both env vars to the concrete
  site-local indices so `make up` works against a fresh dev stack.
  Prod uses aliases owned by ops/IaC.

https://claude.ai/code/session_01UkLD7hpaypxjeh5zbEWTjp
@Joey0538 Joey0538 force-pushed the claude/otelutil-and-spotlight-env branch from b56c932 to 8b890a9 Compare May 8, 2026 09:32
Comment thread search-service/deploy/docker-compose.yml Outdated
Comment thread pkg/otelutil/otel.go Outdated
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.

3 participants