18 days ago
Hi Railway Team,
I'm setting up OpenTelemetry (OTLP) for my Spring Boot application and need to configure the service.instance.id resource attribute. This attribute must be unique per replica instance to correctly distinguish traces, metrics, and logs when running multiple replicas of the same service.
I've looked through the available Railway-provided environment variables but cannot find one that provides a unique identifier per replica.
Railway exposes variables like:
- RAILWAY_SERVICE_ID – same across all replicas
- RAILWAY_DEPLOYMENT_ID – same across all replicas of the same
deployment
What I need is a variable that is unique to each individual replica instance, so I can use it as the value for OTEL_RESOURCE_ATTRIBUTES=service.instance.id=<unique-replica-id>
Could you let me know:
1. Is there an existing environment variable that is unique per replica that I may have overlooked?
2. If not, are is there any workaround to generate a UUID at startup? But a deterministic, platform-provided identifier would be much preferred for consistent observability.
Thank you for your help!
Best regards,
Alex
1 Replies
18 days ago
i solved it with:
ENTRYPOINT ["sh", "-c", "export OTEL_RESOURCE_ATTRIBUTES=\"${OTEL_RESOURCE_ATTRIBUTES},service.instance.id=${RAILWAY_REPLICA_ID}\" && exec java -jar /app/app.jar"]
Status changed to Solved brody • 17 days ago