diff options
Diffstat (limited to 'config-model')
2 files changed, 34 insertions, 9 deletions
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/admin/otel/OpenTelemetryConfigGenerator.java b/config-model/src/main/java/com/yahoo/vespa/model/admin/otel/OpenTelemetryConfigGenerator.java index eceadaabc9e..e11f0b3a169 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/admin/otel/OpenTelemetryConfigGenerator.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/admin/otel/OpenTelemetryConfigGenerator.java @@ -280,16 +280,19 @@ public class OpenTelemetryConfigGenerator { if (zone == null) return "noCloud"; return zone.cloud().name().value(); } + private String getDeploymentCluster(ClusterSpec cluster) { - return String.join(".", applicationId.toFullString(), - zone.environment().value(), zone.region().value(), + String appString = applicationId == null ? "none.noapp.nope" : applicationId.toFullString(); + return String.join(".", appString, + zone == null ? "dev" : zone.environment().value(), + zone == null ? "local" : zone.region().value(), cluster.id().value()); } private Map<String, String> serviceAttributes(Service svc) { Map<String, String> dimvals = new LinkedHashMap<>(); - dimvals.put("service_name", svc.getServiceName()); // used to be "instance" - dimvals.put("service_type", svc.getServiceType()); // added, do we need it? + dimvals.put("instance", svc.getServiceName()); // should maybe be "local_service_name" ? + dimvals.put("instanceType", svc.getServiceType()); // maybe "local_service_type", or remove String cName = svc.getServicePropertyString("clustername", null); if (cName != null) { // what about "clusterid" below, is it always the same? @@ -303,9 +306,9 @@ public class OpenTelemetryConfigGenerator { if (hostResource != null) { hostResource.spec().membership().map(ClusterMembership::cluster).ifPresent(cluster -> { dimvals.put(PublicDimensions.DEPLOYMENT_CLUSTER, getDeploymentCluster(cluster)); - // same as above? + // overrides value above dimvals.put(PublicDimensions.INTERNAL_CLUSTER_TYPE, cluster.type().name()); - // same as above? + // alternative to above dimvals.put(PublicDimensions.INTERNAL_CLUSTER_ID, cluster.id().value()); cluster.group().ifPresent(group -> dimvals.put(PublicDimensions.GROUP_ID, group.toString())); }); diff --git a/config-model/src/test/java/com/yahoo/vespa/model/admin/otel/OpenTelemetryConfigGeneratorTest.java b/config-model/src/test/java/com/yahoo/vespa/model/admin/otel/OpenTelemetryConfigGeneratorTest.java index 8f43fed65d1..b555196b6cc 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/admin/otel/OpenTelemetryConfigGeneratorTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/admin/otel/OpenTelemetryConfigGeneratorTest.java @@ -4,10 +4,18 @@ package com.yahoo.vespa.model.admin.otel; import com.yahoo.config.model.ApplicationConfigProducerRoot.StatePortInfo; import com.yahoo.config.model.producer.TreeConfigProducer; import com.yahoo.config.model.test.MockRoot; +import com.yahoo.config.provision.ApplicationId; +import com.yahoo.config.provision.ClusterMembership; +import com.yahoo.config.provision.HostSpec; +import com.yahoo.config.provision.NodeResources; +import com.yahoo.vespa.model.AbstractService; +import com.yahoo.vespa.model.Host; +import com.yahoo.vespa.model.HostResource; import com.yahoo.vespa.model.AbstractService; import com.yahoo.vespa.model.PortAllocBridge; import org.junit.jupiter.api.Test; import java.util.List; +import java.util.Optional; import static org.junit.jupiter.api.Assertions.*; /** @@ -17,14 +25,28 @@ public class OpenTelemetryConfigGeneratorTest { @Test void testBuildsYaml() { - var generator = new OpenTelemetryConfigGenerator(null, null); + var app = ApplicationId.from("mytenant", "myapp", "myinstance"); + var generator = new OpenTelemetryConfigGenerator(null, app); var root = new MockRoot(); - var mockPort1 = new StatePortInfo("localhost", 19098, - new MockService(root, "sentinel")); + + var mockHost = new Host(root, "localhost2.local"); + var mockVersion = new com.yahoo.component.Version(8); + var mockCluster = ClusterMembership.from("container/feeding/2/3", mockVersion, Optional.empty()); + var noResource = NodeResources.unspecified(); + var mockHostSpec = new HostSpec("localhost1.local", + noResource, noResource, noResource, + mockCluster, + Optional.empty(), Optional.empty(), Optional.empty()); + var mockHostResource = new HostResource(mockHost, mockHostSpec); + var mockSvc1 = new MockService(root, "sentinel"); + mockSvc1.setHostResource(mockHostResource); + var mockPort1 = new StatePortInfo("localhost", 19098, mockSvc1); + var mockSvc2 = new MockService(root, "searchnode"); mockSvc2.setProp("clustername", "mycluster"); mockSvc2.setProp("clustertype", "mockup"); var mockPort2 = new StatePortInfo("other.host.local", 19102, mockSvc2); + generator.addStatePorts(List.of(mockPort1, mockPort2)); String yaml = generator.generate(); // System.err.println(">>>\n" + yaml + "\n<<<"); |