Skip to content

feat(observability): support custom ports for self-hosted Laminar#2447

Open
Shimada666 wants to merge 1 commit intoOpenHands:mainfrom
Shimada666:feat/laminar-self-hosted-ports
Open

feat(observability): support custom ports for self-hosted Laminar#2447
Shimada666 wants to merge 1 commit intoOpenHands:mainfrom
Shimada666:feat/laminar-self-hosted-ports

Conversation

@Shimada666
Copy link

Summary

  • Add LMNR_HTTP_PORT and LMNR_GRPC_PORT environment variables to configure custom ports for self-hosted Laminar instances
  • Self-hosted Laminar uses port 8001 (gRPC) and 8000 (HTTP), but maybe_init_laminar() defaults to 8443/443 (cloud ports), making self-hosted setups unusable without workarounds
  • Fully backward compatible: when unset, defaults remain unchanged

Problem

When using a self-hosted Laminar instance (via docker compose), the gRPC port is 8001 and HTTP port is 8000. However, maybe_init_laminar() calls Laminar.initialize() without port arguments, so it always defaults to the cloud ports (gRPC: 8443, HTTP: 443).

Current workarounds are unintuitive:

  1. Pre-initialize Laminar before importing the SDK to prevent re-initialization
  2. Use raw OTEL_EXPORTER_OTLP_TRACES_* environment variables instead of LMNR_* variables

Solution

Read optional LMNR_HTTP_PORT and LMNR_GRPC_PORT environment variables and pass them to Laminar.initialize() on the Laminar backend path only. The OTEL backend path is unaffected since its ports are controlled by OTEL_EXPORTER_OTLP_TRACES_ENDPOINT.

Usage

LMNR_PROJECT_API_KEY=your_key
LMNR_BASE_URL=http://your-laminar-host
LMNR_HTTP_PORT=8000
LMNR_GRPC_PORT=8001

Test plan

  • Verified with self-hosted Laminar (Docker Compose) — traces exported successfully
  • Without LMNR_HTTP_PORT/LMNR_GRPC_PORT set, behavior is identical to before (defaults to 443/8443)

🤖 Generated with Claude Code

Self-hosted Laminar uses port 8001 for gRPC and 8000 for HTTP, but
`maybe_init_laminar()` calls `Laminar.initialize()` without passing
port arguments, causing it to default to 8443/443 (cloud ports).

This makes self-hosted Laminar unusable without workarounds like
pre-initializing Laminar before importing the SDK or falling back
to raw OTEL environment variables.

Add support for `LMNR_HTTP_PORT` and `LMNR_GRPC_PORT` environment
variables, passed to `Laminar.initialize()` only on the Laminar
backend path. When unset, defaults remain unchanged (443/8443),
so this is fully backward compatible.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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