Skip to content

Go: add more frameworks - #16915

Merged
JinHai-CN merged 3 commits into
infiniflow:mainfrom
JinHai-CN:fix548
Jul 14, 2026
Merged

JinHai-CN merged 3 commits into
infiniflow:mainfrom
JinHai-CN:fix548

Conversation

@JinHai-CN

Copy link
Copy Markdown
Member

Summary

  1. Add hooks for server init
  2. Add hooks for router init
  3. Add jaeger and otel related config

@coderabbitai

coderabbitai Bot commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The PR adds EE server lifecycle hooks, EE router extension points, OpenTelemetry and Jaeger configuration, and an AlmostEqual64 floating-point comparison helper.

Changes

EE and observability scaffolding

Layer / File(s) Summary
OpenTelemetry and Jaeger configuration
internal/server/config.go, conf/service_conf.yaml, docker/service_conf.yaml.template, docker/.env, docker/docker-compose-base.yml
Adds OpenTelemetry settings to application configuration and an optional Jaeger Compose service with configurable OTLP and UI ports.
EE server lifecycle
internal/server/server_ee.go, cmd/ragflow_server.go
Initializes an EEServer, adds guarded startup and shutdown functions, and invokes them from main().
EE router wiring
internal/admin/router.go, internal/admin/router_ee.go, internal/router/router.go, internal/router/router_ee.go
Adds empty EE router hooks and invokes them during admin and regular router setup.
Floating-point comparison helper
internal/common/number.go
Adds AlmostEqual64, comparing float64 values with a 1e-9 absolute tolerance.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested labels: 💞 feature

Suggested reviewers: yuzhichang, 6ba3i

Poem

I’m a rabbit hopping through routes,
With traces blooming from startup sprouts.
Jaeger waits, the server wakes,
Tiny float comparisons keep errors in place.
EE hooks sit ready, neat and bright—
A carrot-powered launch tonight! 🐇

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title is too vague and does not reflect the server/router hooks and Jaeger/OpenTelemetry config changes. Rename it to something like "Add server and router init hooks with Jaeger/OpenTelemetry config".
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Description check ✅ Passed The description satisfies the required Summary section and covers the main changes, though it is brief.

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.

@JinHai-CN JinHai-CN added the ci Continue Integration label Jul 14, 2026
@JinHai-CN
JinHai-CN marked this pull request as ready for review July 14, 2026 13:04
@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jul 14, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Nitpick comments (1)
conf/service_conf.yaml (1)

54-59: 🚀 Performance & Scalability | 🔵 Trivial

Avoid full stdout tracing in production defaults.

sample_ratio: 1.0 together with stdout: true can emit every span to application logs and materially increase log volume and runtime overhead. Confirm this file is development-only; otherwise use safer defaults and enable verbose tracing explicitly.

🤖 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 `@conf/service_conf.yaml` around lines 54 - 59, Update the otel defaults in the
service configuration so production deployments do not emit every span to
stdout: reduce or disable sample_ratio and set stdout to false unless this file
is confirmed to be development-only. Preserve verbose tracing as an explicit
opt-in configuration.
🤖 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 `@cmd/ragflow_server.go`:
- Around line 371-375: Ensure the startup failure path around server.StartServer
explicitly invokes server.ShutdownServer before os.Exit(1), or propagate the
error to a caller that performs deferred cleanup. Preserve shutdown handling for
successful startup and ensure EE cleanup occurs on every exit path.

In `@docker/docker-compose-base.yml`:
- Around line 276-283: Update the Jaeger service configuration to use Jaeger v2
YAML configuration instead of the COLLECTOR_OTLP_ENABLED environment toggle:
mount the repository’s Jaeger config file into the container, pass it via the
image command’s --config option, and ensure the config defines the OTLP gRPC and
HTTP receivers exposed by the existing ports.

In `@docker/service_conf.yaml.template`:
- Line 69: Update the OTLP configuration’s secure setting in
service_conf.yaml.template to read from an environment variable mapped to
OtelConfig.Secure instead of hard-coding false. Preserve the existing
configuration structure and ensure deployments can enable TLS through that
variable.

In `@internal/common/number.go`:
- Around line 178-180: Update AlmostEqual64 to use a strict math.Abs(a-b) <
epsilon comparison, matching the repository’s existing epsilon semantics. Add or
update tests to verify values exactly 1e-9 apart are not considered equal while
values below the threshold remain equal.

---

Nitpick comments:
In `@conf/service_conf.yaml`:
- Around line 54-59: Update the otel defaults in the service configuration so
production deployments do not emit every span to stdout: reduce or disable
sample_ratio and set stdout to false unless this file is confirmed to be
development-only. Preserve verbose tracing as an explicit opt-in configuration.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: eb4fbd10-b693-4bda-9205-c929a9b02fec

📥 Commits

Reviewing files that changed from the base of the PR and between bd7a3bb and b38574c.

📒 Files selected for processing (12)
  • cmd/ragflow_server.go
  • conf/service_conf.yaml
  • docker/.env
  • docker/docker-compose-base.yml
  • docker/service_conf.yaml.template
  • internal/admin/router.go
  • internal/admin/router_ee.go
  • internal/common/number.go
  • internal/router/router.go
  • internal/router/router_ee.go
  • internal/server/config.go
  • internal/server/server_ee.go

Comment thread cmd/ragflow_server.go
Comment on lines +371 to +375
if err = server.StartServer(); err != nil {
common.Error("Failed to start EE server", err)
os.Exit(1)
}
defer server.ShutdownServer()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Locate the relevant file and nearby startup/shutdown code.
git ls-files cmd/ragflow_server.go
echo '--- outline ---'
ast-grep outline cmd/ragflow_server.go --view expanded || true
echo '--- line count ---'
wc -l cmd/ragflow_server.go
echo '--- target slice ---'
sed -n '330,430p' cmd/ragflow_server.go

Repository: infiniflow/ragflow

Length of output: 4016


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the server lifecycle methods referenced from main.
rg -n "func .*StartServer|func .*ShutdownServer|StartServer\(|ShutdownServer\(" cmd . -g '!**/vendor/**' -g '!**/node_modules/**'

Repository: infiniflow/ragflow

Length of output: 541


🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n "func .*StartServer|func .*ShutdownServer|StartServer\(|ShutdownServer\(" cmd . -g '!**/vendor/**' -g '!**/node_modules/**'

Repository: infiniflow/ragflow

Length of output: 541


🏁 Script executed:

#!/bin/bash
set -euo pipefail

sed -n '211,430p' cmd/ragflow_server.go

Repository: infiniflow/ragflow

Length of output: 5714


Run EE shutdown before any os.Exit path. defer server.ShutdownServer() is skipped by the later os.Exit(1) branches, so a mode startup failure can bypass EE cleanup and discard shutdown errors. Return the error to the caller or call ShutdownServer() explicitly before exiting.

🤖 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 `@cmd/ragflow_server.go` around lines 371 - 375, Ensure the startup failure
path around server.StartServer explicitly invokes server.ShutdownServer before
os.Exit(1), or propagate the error to a caller that performs deferred cleanup.
Preserve shutdown handling for successful startup and ensure EE cleanup occurs
on every exit path.

Comment on lines +276 to +283
image: jaegertracing/jaeger:${JAEGER_VERSION:-2.19.0}
ports:
- ${JAEGER_OTLP_GRPC_PORT:-4317}:4317
- ${JAEGER_OTLP_HTTP_PORT:-4318}:4318
- ${JAEGER_UI_PORT:-16686}:16686
env_file: .env
environment:
- COLLECTOR_OTLP_ENABLED=true

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the relevant compose section and any Jaeger-related config references.
sed -n '250,310p' docker/docker-compose-base.yml

printf '\n--- search for Jaeger config references ---\n'
rg -n --hidden -S 'JAEGER_VERSION|COLLECTOR_OTLP_ENABLED|--config|jaegertracing/jaeger|jaeger:' docker .github . || true

Repository: infiniflow/ragflow

Length of output: 5846


🏁 Script executed:

#!/bin/bash
set -euo pipefail

python3 - <<'PY'
import urllib.request, ssl
urls = [
    "https://www.jaegertracing.io/docs/2.19/deployment/configuration/",
    "https://www.jaegertracing.io/docs/2.19/",
]
ctx = ssl.create_default_context()
for url in urls:
    print(f"=== {url} ===")
    try:
        with urllib.request.urlopen(url, context=ctx, timeout=20) as r:
            data = r.read().decode("utf-8", "replace")
        # Print only the first few matching snippets for relevant terms.
        for term in ["COLLECTOR_OTLP_ENABLED", "--config", "OTLP", "environment variables", "command line"]:
            idx = data.find(term)
            if idx != -1:
                start = max(0, idx - 250)
                end = min(len(data), idx + 700)
                print(data[start:end].replace("\n", " "))
                print("\n---")
    except Exception as e:
        print(f"ERROR: {e}")
PY

Repository: infiniflow/ragflow

Length of output: 559


🌐 Web query:

Jaeger 2.19 COLLECTOR_OTLP_ENABLED config environment variable --config deployment configuration

💡 Result:

In Jaeger v2 (including version 2.19.0), the environment variable COLLECTOR_OTLP_ENABLED is no longer used [1][2]. Jaeger v2 significantly changes configuration management compared to v1, moving away from relying on specific environment variables for feature toggles [3][4]. Key points regarding Jaeger v2 configuration: 1. Unified Configuration: Jaeger v2 must be configured using a YAML configuration file [3][5]. You provide this file to the Jaeger binary or container using the --config command line argument [5]. 2. OTLP Receivers: The OTLP receiver is managed within the YAML configuration file under the receivers section, following the OpenTelemetry Collector configuration format [3][4]. Unlike v1, where an environment variable was required to toggle the feature, the OTLP receiver is configured directly within the pipeline definitions in your YAML file [4]. 3. Environment Variable Usage: While Jaeger v2 does not use legacy environment variables like COLLECTOR_OTLP_ENABLED, it does allow you to reference environment variables within your YAML configuration file using the ${env:VAR_NAME:-default} syntax [3]. This is useful for injecting dynamic values (such as hostnames or ports) into your configuration [3][6]. 4. Command Line Overrides: You can also override specific configuration values directly via the command line using the --set flag, which is particularly useful for the all-in-one distribution [3][6]. Example: --set=receivers.otlp.protocols.grpc.endpoint=0.0.0.0:4317 [3][6].

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Map the relevant file and inspect nearby context.
python3 - <<'PY'
from pathlib import Path
p = Path('docker/docker-compose-base.yml')
for i, line in enumerate(p.read_text().splitlines(), 1):
    if 260 <= i <= 290:
        print(f"{i:4}: {line}")
PY

printf '\n--- Jaeger-related files in repo ---\n'
git ls-files | rg '(^|/)jaeger|docker-compose-base\.yml|compose.*yml$'

Repository: infiniflow/ragflow

Length of output: 1211


🏁 Script executed:

#!/bin/bash
set -euo pipefail

for f in docker/docker-compose.yml docker/docker-compose-macos.yml docker/docker-compose-CN-oc9.yml agent/sandbox/docker-compose.yml; do
  echo "=== $f ==="
  if [ -f "$f" ]; then
    rg -n -A6 -B4 'jaegertracing/jaeger|COLLECTOR_OTLP_ENABLED|--config|jaeger:' "$f" || true
  else
    echo "missing"
  fi
  echo
done

Repository: infiniflow/ragflow

Length of output: 316


Configure Jaeger v2 with a YAML config. COLLECTOR_OTLP_ENABLED=true is a v1-style toggle and won’t configure OTLP in jaegertracing/jaeger:2.19.0; mount a config file and pass --config so the OTLP receivers are defined.

🤖 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/docker-compose-base.yml` around lines 276 - 283, Update the Jaeger
service configuration to use Jaeger v2 YAML configuration instead of the
COLLECTOR_OTLP_ENABLED environment toggle: mount the repository’s Jaeger config
file into the container, pass it via the image command’s --config option, and
ensure the config defines the OTLP gRPC and HTTP receivers exposed by the
existing ports.

otel:
host: ${OTEL_HOST:-0.0.0.0}
port: ${OTEL_PORT:-4318}
secure: false

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Make OTLP transport security configurable.

Hard-coding secure: false prevents Docker deployments from enabling TLS, even though OtelConfig.Secure is exposed. Map this value to an environment variable so production collectors can require secure transport.

Proposed fix
-  secure: false
+  secure: ${OTEL_SECURE:-false}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
secure: false
secure: ${OTEL_SECURE:-false}
🤖 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/service_conf.yaml.template` at line 69, Update the OTLP
configuration’s secure setting in service_conf.yaml.template to read from an
environment variable mapped to OtelConfig.Secure instead of hard-coding false.
Preserve the existing configuration structure and ensure deployments can enable
TLS through that variable.

Comment thread internal/common/number.go
Comment on lines +178 to +180
func AlmostEqual64(a, b float64) bool {
const epsilon = 1e-9
return math.Abs(a-b) <= epsilon

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Match the repository’s strict epsilon semantics.

internal/agent/tool/retrieval_nlp_test.go:35-37 treats values as equal only when math.Abs(a-b) < 1e-9; this implementation uses <=, changing the result for values exactly 1e-9 apart. Use < epsilon unless the inclusive boundary is intentional, and add a boundary test.

🤖 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 `@internal/common/number.go` around lines 178 - 180, Update AlmostEqual64 to
use a strict math.Abs(a-b) < epsilon comparison, matching the repository’s
existing epsilon semantics. Add or update tests to verify values exactly 1e-9
apart are not considered equal while values below the threshold remain equal.

@codecov

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.16%. Comparing base (55d5879) to head (b38574c).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #16915   +/-   ##
=======================================
  Coverage   93.16%   93.16%           
=======================================
  Files          10       10           
  Lines         717      717           
  Branches      118      118           
=======================================
  Hits          668      668           
  Misses         29       29           
  Partials       20       20           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JinHai-CN
JinHai-CN merged commit b506d8e into infiniflow:main Jul 14, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant