@juspay/neurolink 9.44.1 → 9.48.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -167,6 +167,33 @@ export NEUROLINK_OPENOBSERVE_OTLP_ENDPOINT
167
167
 
168
168
  select_compose
169
169
 
170
+ # Write or update OTEL_EXPORTER_OTLP_ENDPOINT in ~/.neurolink/.env so the
171
+ # proxy picks it up automatically without any manual export.
172
+ upsert_neurolink_env() {
173
+ local neurolink_dir="${HOME}/.neurolink"
174
+ local env_file="${neurolink_dir}/.env"
175
+ local endpoint="http://localhost:${NEUROLINK_OTLP_HTTP_PORT}"
176
+ local key="OTEL_EXPORTER_OTLP_ENDPOINT"
177
+
178
+ mkdir -p "${neurolink_dir}"
179
+ chmod 700 "${neurolink_dir}" 2>/dev/null || true
180
+
181
+ if [[ -f "${env_file}" ]] && grep -Eq "^[[:space:]]*(export[[:space:]]+)?${key}=" "${env_file}"; then
182
+ # Replace existing line in-place (portable sed -i)
183
+ sed -i.bak -E "s|^[[:space:]]*(export[[:space:]]+)?${key}=.*|${key}=${endpoint}|" "${env_file}"
184
+ rm -f "${env_file}.bak"
185
+ else
186
+ # Ensure the new entry starts on its own line if the file lacks a trailing newline
187
+ if [[ -f "${env_file}" ]] && [[ -s "${env_file}" ]] && [[ "$(tail -c 1 "${env_file}")" != "" ]]; then
188
+ echo "" >> "${env_file}"
189
+ fi
190
+ echo "${key}=${endpoint}" >> "${env_file}"
191
+ fi
192
+ chmod 600 "${env_file}" 2>/dev/null || true
193
+
194
+ echo " Wrote ${key}=${endpoint} to ${env_file}"
195
+ }
196
+
170
197
  command="${1:-setup}"
171
198
 
172
199
  case "${command}" in
@@ -175,6 +202,7 @@ case "${command}" in
175
202
  wait_for_http "OpenObserve" "${NEUROLINK_OPENOBSERVE_URL}/healthz"
176
203
  wait_for_http "OTEL collector" "http://localhost:${NEUROLINK_OTEL_HEALTH_PORT}/"
177
204
  node "${IMPORT_SCRIPT}" --replace-by-title
205
+ upsert_neurolink_env
178
206
  cat <<EOF
179
207
  Local proxy observability is ready.
180
208
 
@@ -183,12 +211,12 @@ OpenObserve login user: ${NEUROLINK_OPENOBSERVE_USER}
183
211
  OpenObserve password source: ${ENV_FILE} (NEUROLINK_OPENOBSERVE_PASSWORD)
184
212
  OTLP HTTP endpoint: http://localhost:${NEUROLINK_OTLP_HTTP_PORT}
185
213
 
186
- Set this before starting the proxy:
187
- export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:${NEUROLINK_OTLP_HTTP_PORT}
214
+ OTEL endpoint written to ~/.neurolink/.env — the proxy will pick it up automatically on next start.
188
215
  EOF
189
216
  ;;
190
217
  up|start)
191
218
  compose up -d
219
+ upsert_neurolink_env
192
220
  ;;
193
221
  down|stop)
194
222
  compose down