diff --git a/intg/src/main/java/org/apache/atlas/AtlasConfiguration.java b/intg/src/main/java/org/apache/atlas/AtlasConfiguration.java index 318eac6a61..5a789c6a9a 100644 --- a/intg/src/main/java/org/apache/atlas/AtlasConfiguration.java +++ b/intg/src/main/java/org/apache/atlas/AtlasConfiguration.java @@ -144,7 +144,7 @@ public enum AtlasConfiguration { * OTEL Configuration */ OTEL_RESOURCE_ATTRIBUTES("OTEL_RESOURCE_ATTRIBUTES", "service.name=atlas"), - OTEL_SERVICE_NAME(" OTEL_SERVICE_NAME", "atlas"), + OTEL_SERVICE_NAME("OTEL_SERVICE_NAME", "atlas"), OTEL_EXPORTER_OTLP_ENDPOINT("OTEL_EXPORTER_OTLP_ENDPOINT", "http://localhost:4317"); diff --git a/webapp/src/main/java/org/apache/atlas/Atlas.java b/webapp/src/main/java/org/apache/atlas/Atlas.java index a2d9531c82..411a1b1c70 100755 --- a/webapp/src/main/java/org/apache/atlas/Atlas.java +++ b/webapp/src/main/java/org/apache/atlas/Atlas.java @@ -186,11 +186,23 @@ private static void setApplicationHome() { private static OpenTelemetry initializeOpenTelemetry() { - List customResourceAttr = - Arrays.asList(AtlasConfiguration.OTEL_RESOURCE_ATTRIBUTES.getStringArray()); + String otelResourceAttributes = System.getenv("OTEL_RESOURCE_ATTRIBUTES"); + + List customResourceAttr = null; + + if (otelResourceAttributes != null) { + // Split the environment variable by commas + String[] values = otelResourceAttributes.split(","); + customResourceAttr = Arrays.asList(values); + } else { + customResourceAttr = Arrays.asList(AtlasConfiguration.OTEL_RESOURCE_ATTRIBUTES.getStringArray()); + } + + String serviceName = System.getenv("OTEL_SERVICE_NAME") != null ? System.getenv("OTEL_SERVICE_NAME") : AtlasConfiguration.OTEL_SERVICE_NAME.getString(); + String otelEndpoint = System.getenv("OTEL_EXPORTER_OTLP_ENDPOINT") != null ? System.getenv("OTEL_EXPORTER_OTLP_ENDPOINT") : AtlasConfiguration.OTEL_EXPORTER_OTLP_ENDPOINT.getString(); ResourceBuilder resourceBuilder = Resource.getDefault().toBuilder() - .put(ResourceAttributes.SERVICE_NAME, AtlasConfiguration.OTEL_SERVICE_NAME.getString()); + .put(ResourceAttributes.SERVICE_NAME, serviceName); // Iterate through the ArrayList and add each attribute for (String attribute : customResourceAttr) { @@ -212,7 +224,7 @@ private static OpenTelemetry initializeOpenTelemetry() { .addLogRecordProcessor( BatchLogRecordProcessor.builder( OtlpGrpcLogRecordExporter.builder() - .setEndpoint(AtlasConfiguration.OTEL_EXPORTER_OTLP_ENDPOINT.getString()) + .setEndpoint(otelEndpoint) .build() ) .build()