-
Notifications
You must be signed in to change notification settings - Fork 6
feat: add OpenTelemetry instrumentation and containerization #43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
3024e39
c297d81
38e42d8
fcbc86b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| import { NextResponse } from 'next/server'; | ||
|
|
||
| export async function GET() { | ||
| try { | ||
| const apiUrl = process.env.AICONFIGURATOR_API_URL || 'http://localhost:7860'; | ||
|
|
||
| // Check if AIConfigurator API is reachable | ||
| const apiResponse = await fetch(`${apiUrl}/systems`, { | ||
| method: 'GET', | ||
| headers: { | ||
| 'Accept': 'application/json', | ||
| }, | ||
| }); | ||
|
coderabbitai[bot] marked this conversation as resolved.
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| if (!apiResponse.ok) { | ||
| return NextResponse.json( | ||
| { | ||
| status: 'degraded', | ||
| message: 'API connectivity issue', | ||
| api_status: apiResponse.status, | ||
| }, | ||
| { status: 200 } | ||
| ); | ||
| } | ||
|
|
||
| return NextResponse.json( | ||
| { | ||
| status: 'healthy', | ||
| message: 'ConfigIQ webapp is running', | ||
| timestamp: new Date().toISOString(), | ||
| }, | ||
| { status: 200 } | ||
| ); | ||
| } catch (error) { | ||
| return NextResponse.json( | ||
| { | ||
| status: 'unhealthy', | ||
| message: error instanceof Error ? error.message : 'Unknown error', | ||
| }, | ||
| { status: 200 } | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| ); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import { initOtel } from './lib/otel'; | ||
|
|
||
| export async function register() { | ||
| initOtel(); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import { NodeSDK } from '@opentelemetry/sdk-node'; | ||
| import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node'; | ||
| import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http'; | ||
| import { BatchSpanProcessor } from '@opentelemetry/sdk-trace-node'; | ||
|
|
||
| export function initOtel() { | ||
| const otelEndpoint = process.env.OTEL_EXPORTER_OTLP_ENDPOINT || 'http://localhost:4318'; | ||
|
|
||
| const sdk = new NodeSDK({ | ||
| traceExporter: new OTLPTraceExporter({ | ||
| url: `${otelEndpoint}/v1/traces`, | ||
| }), | ||
|
Comment on lines
+7
to
+12
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- tracked candidates ---'
git ls-files | rg '(^|/)(otel\.ts|package\.json|.*otel.*|.*test.*|.*spec.*)$' | head -200
printf '%s\n' '--- lib/otel.ts outline ---'
if command -v ast-grep >/dev/null 2>&1; then
ast-grep outline lib/otel.ts
fi
printf '%s\n' '--- lib/otel.ts ---'
cat -n lib/otel.ts
printf '%s\n' '--- OTLP endpoint references ---'
rg -n -C 3 'OTEL_EXPORTER_OTLP_ENDPOINT|OTLPTraceExporter|v1/traces|otelEndpoint' . \
-g '!node_modules' -g '!dist' -g '!build' | head -300Repository: redhat-performance/configiq Length of output: 2545 🏁 Script executed: #!/bin/bash
set -eu
node - <<'JS'
const cases = [
'http://localhost:4318',
'http://localhost:4318/',
'http://collector:4318/prefix',
'http://collector:4318/prefix/',
'http://collector:4318/prefix?token=x',
];
for (const endpoint of cases) {
const original = `${endpoint}/v1/traces`;
let suggested;
try {
const base = new URL(endpoint);
base.pathname = `${base.pathname.replace(/\/+$/, '')}/`;
suggested = new URL('v1/traces', base).toString();
} catch (error) {
suggested = `ERROR: ${error.message}`;
}
console.log(JSON.stringify({ endpoint, original, suggested }));
}
JSRepository: redhat-performance/configiq Length of output: 888 🌐 Web query:
💡 Result: The OpenTelemetry Protocol (OTLP) over HTTP specification defines specific behaviors regarding endpoint URLs and path suffixes [1][2]. When using the generic OTLP endpoint configuration ( Citations:
Normalize 🤖 Prompt for AI AgentsSource: MCP tools |
||
| instrumentations: [getNodeAutoInstrumentations()], | ||
| serviceName: 'configiq-webapp', | ||
| }); | ||
|
|
||
| sdk.start(); | ||
| console.log(`OpenTelemetry initialized with OTLP endpoint: ${otelEndpoint}`); | ||
|
|
||
| return sdk; | ||
|
Comment on lines
+17
to
+20
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- tracked candidates ---'
git ls-files | grep -E '(^|/)lib/otel\.ts$|(^|/)package\.json$|(^|/)next\.config\.(js|mjs|ts)$|(^|/)(Dockerfile|docker-compose[^/]*|.*\.ya?ml)$' || true
printf '%s\n' '--- lib/otel.ts ---'
cat -n lib/otel.ts
printf '%s\n' '--- package metadata and relevant references ---'
if [ -f package.json ]; then
cat -n package.json
fi
rg -n --glob '!node_modules' --glob '!dist' --glob '!build' \
'initTelemetry|otel|NodeSDK|traceExporter|SIGTERM|SIGINT|shutdown\(' . || trueRepository: redhat-performance/configiq Length of output: 3231 🏁 Script executed: #!/bin/bash
set -eu
cat -n lib/otel.ts
printf '%s\n' '--- package.json ---'
cat -n package.json
printf '%s\n' '--- relevant references ---'
rg -n --glob '!node_modules' 'NodeSDK|traceExporter|sdk\.start|shutdown\(|SIGTERM|SIGINT|otel' . || trueRepository: redhat-performance/configiq Length of output: 3134 🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- instrumentation.ts ---'
cat -n instrumentation.ts
printf '%s\n' '--- lockfiles and resolved OpenTelemetry versions ---'
for f in package-lock.json npm-shrinkwrap.json yarn.lock pnpm-lock.yaml; do
if [ -f "$f" ]; then
echo "[$f]"
rg -n -A8 -B3 '`@opentelemetry/sdk-node`|`@opentelemetry/sdk-trace-node`|`@opentelemetry/exporter-trace-otlp-http`' "$f" || true
fi
done
printf '%s\n' '--- shutdown and signal handling across tracked source ---'
rg -n --glob '*.{ts,tsx,js,mjs,cjs}' \
'process\.(on|once|exit|kill)|SIGTERM|SIGINT|beforeExit|shutdown\(' . || trueRepository: redhat-performance/configiq Length of output: 451 🌐 Web query:
💡 Result: In the OpenTelemetry JavaScript NodeSDK (including version 0.49.x), the Citations:
🏁 Script executed: #!/bin/bash
set -eu
cat -n instrumentation.ts
for f in package-lock.json npm-shrinkwrap.json yarn.lock pnpm-lock.yaml; do
if [ -f "$f" ]; then
echo "[$f]"
rg -n -A8 -B3 '`@opentelemetry/sdk-node`|`@opentelemetry/sdk-trace-node`|`@opentelemetry/exporter-trace-otlp-http`' "$f" || true
fi
done
rg -n --glob '*.{ts,tsx,js,mjs,cjs}' \
'process\.(on|once|exit|kill)|SIGTERM|SIGINT|beforeExit|shutdown\(' . || trueRepository: redhat-performance/configiq Length of output: 311 🏁 Script executed: #!/bin/bash
set -eu
python3 - <<'PY'
from pathlib import Path
import re
otel = Path("lib/otel.ts").read_text()
instrumentation = Path("instrumentation.ts").read_text()
package_lock = Path("package-lock.json").read_text() if Path("package-lock.json").exists() else ""
facts = {
"trace_exporter_configured": bool(re.search(r"traceExporter\s*:", otel)),
"sdk_start_called": bool(re.search(r"\bsdk\.start\(\)", otel)),
"sdk_shutdown_called": bool(re.search(r"\bsdk\.shutdown\(\)", otel)),
"signal_handlers_in_otel": bool(re.search(r"\b(SIGTERM|SIGINT)\b|process\.(on|once)", otel)),
"signal_handlers_in_instrumentation": bool(re.search(r"\b(SIGTERM|SIGINT)\b|process\.(on|once)", instrumentation)),
"node_sdk_dependency_declared": "`@opentelemetry/sdk-node`" in package_lock or "`@opentelemetry/sdk-node`" in Path("package.json").read_text(),
}
for name, value in facts.items():
print(f"{name}={value}")
if not (facts["trace_exporter_configured"] and facts["sdk_start_called"]):
raise SystemExit("expected SDK exporter/start configuration not found")
if facts["sdk_shutdown_called"] or facts["signal_handlers_in_otel"] or facts["signal_handlers_in_instrumentation"]:
raise SystemExit("the reported missing shutdown path is not established")
PYRepository: redhat-performance/configiq Length of output: 349 Flush queued spans during shutdown.
🤖 Prompt for AI AgentsSource: MCP tools |
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.