From e30a744b349112ba2aa84994285c932791461f39 Mon Sep 17 00:00:00 2001 From: Bram Schuur Date: Tue, 17 Nov 2026 14:56:33 +0100 Subject: [PATCH] fix(open-telemetry): encode an unset service.namespace as the empty string --- .../component-mappings/namespaces.sty | 2 +- .../component-mappings/service-instances.sty | 5 +++- .../settings/component-mappings/services.sty | 4 +-- .../monitor.sty | 2 +- .../monitor.sty | 2 +- .../service-span-duration/monitor.sty | 2 +- .../service-span-error-ratio/monitor.sty | 2 +- .../asynchronous-consumer-peer.sty | 25 ++++++++++------- .../asynchronous-producer-consumer.sty | 28 ++++++++++++------- .../asynchronous-producer-peer.sty | 22 +++++++++------ .../relation-mappings/executes-ecs-task.sty | 5 ++-- .../relation-mappings/executes-function.sty | 5 ++-- .../relation-mappings/executes-host.sty | 5 ++-- .../relation-mappings/k8s-pod-to-otel.sty | 5 ++-- .../relation-mappings/provided-by.sty | 5 ++-- .../relation-mappings/synchronous.sty | 6 ++-- stackpacks/open-telemetry/stackpack.yaml | 2 +- 17 files changed, 70 insertions(+), 57 deletions(-) diff --git a/stackpacks/open-telemetry/settings/component-mappings/namespaces.sty b/stackpacks/open-telemetry/settings/component-mappings/namespaces.sty index eebe21b..fbf7bc3 100644 --- a/stackpacks/open-telemetry/settings/component-mappings/namespaces.sty +++ b/stackpacks/open-telemetry/settings/component-mappings/namespaces.sty @@ -9,7 +9,7 @@ nodes: - "METRICS" resource: action: "'CREATE'" - condition: "'service.namespace' in resource.attributes" + condition: "'service.namespace' in resource.attributes && resource.attributes['service.namespace'] != ''" vars: - name: "namespace" value: "resource.attributes['service.namespace']" diff --git a/stackpacks/open-telemetry/settings/component-mappings/service-instances.sty b/stackpacks/open-telemetry/settings/component-mappings/service-instances.sty index 07a4bc0..625d152 100644 --- a/stackpacks/open-telemetry/settings/component-mappings/service-instances.sty +++ b/stackpacks/open-telemetry/settings/component-mappings/service-instances.sty @@ -12,7 +12,10 @@ nodes: condition: "'service.instance.id' in resource.attributes" vars: - name: "namespace" - value: "resource.attributes['service.namespace']" + value: >- + 'service.namespace' in resource.attributes ? + resource.attributes['service.namespace'] : + '' - name: "service" value: "resource.attributes['service.name']" - name: "version" diff --git a/stackpacks/open-telemetry/settings/component-mappings/services.sty b/stackpacks/open-telemetry/settings/component-mappings/services.sty index f1a1485..8b65363 100644 --- a/stackpacks/open-telemetry/settings/component-mappings/services.sty +++ b/stackpacks/open-telemetry/settings/component-mappings/services.sty @@ -13,9 +13,9 @@ nodes: vars: - name: "namespace" value: >- - resource.attributes['service.namespace'] != '' ? + 'service.namespace' in resource.attributes ? resource.attributes['service.namespace'] : - 'default' + '' - name: "service" value: "resource.attributes['service.name']" - name: "version" diff --git a/stackpacks/open-telemetry/settings/monitors/service-instance-span-duration/monitor.sty b/stackpacks/open-telemetry/settings/monitors/service-instance-span-duration/monitor.sty index d25ed8b..06880dd 100644 --- a/stackpacks/open-telemetry/settings/monitors/service-instance-span-duration/monitor.sty +++ b/stackpacks/open-telemetry/settings/monitors/service-instance-span-duration/monitor.sty @@ -13,7 +13,7 @@ nodes: unit: s threshold: 5 titleTemplate: Span duration - urnTemplate: "urn:opentelemetry:namespace/${service_namespace}:service/${service_name}:serviceInstance/${service_instance_id}" + urnTemplate: "urn:opentelemetry:namespace/${'service_namespace' in labels ? labels.service_namespace : ''}:service/${service_name}:serviceInstance/${service_instance_id}" description: | Monitors the duration of the server and consumer spans. When the 95th percentile of the duration is greater than the threshold (default 5s) the monitor has a Deviating state. function: urn:stackpack:common:monitor-function:threshold diff --git a/stackpacks/open-telemetry/settings/monitors/service-instance-span-error-ratio/monitor.sty b/stackpacks/open-telemetry/settings/monitors/service-instance-span-error-ratio/monitor.sty index 60e27e4..fbbb743 100644 --- a/stackpacks/open-telemetry/settings/monitors/service-instance-span-error-ratio/monitor.sty +++ b/stackpacks/open-telemetry/settings/monitors/service-instance-span-error-ratio/monitor.sty @@ -9,7 +9,7 @@ nodes: unit: percent threshold: 5 titleTemplate: Span error ratio - urnTemplate: "urn:opentelemetry:namespace/${service_namespace}:service/${service_name}:serviceInstance/${service_instance_id}" + urnTemplate: "urn:opentelemetry:namespace/${'service_namespace' in labels ? labels.service_namespace : ''}:service/${service_name}:serviceInstance/${service_instance_id}" description: | Percentage of server and consumer spans that are in an error state for the service instance. function: urn:stackpack:common:monitor-function:threshold diff --git a/stackpacks/open-telemetry/settings/monitors/service-span-duration/monitor.sty b/stackpacks/open-telemetry/settings/monitors/service-span-duration/monitor.sty index 021e761..beb81ae 100644 --- a/stackpacks/open-telemetry/settings/monitors/service-span-duration/monitor.sty +++ b/stackpacks/open-telemetry/settings/monitors/service-span-duration/monitor.sty @@ -13,7 +13,7 @@ nodes: unit: s threshold: 5 titleTemplate: Span duration - urnTemplate: "urn:opentelemetry:namespace/${service_namespace}:service/${service_name}" + urnTemplate: "urn:opentelemetry:namespace/${'service_namespace' in labels ? labels.service_namespace : ''}:service/${service_name}" description: | Monitors the duration of the server and consumer spans. When the 95th percentile of the duration is greater than the threshold (default 5s) the monitor has a Deviating state. function: urn:stackpack:common:monitor-function:threshold diff --git a/stackpacks/open-telemetry/settings/monitors/service-span-error-ratio/monitor.sty b/stackpacks/open-telemetry/settings/monitors/service-span-error-ratio/monitor.sty index e3a2ede..00e8ff5 100644 --- a/stackpacks/open-telemetry/settings/monitors/service-span-error-ratio/monitor.sty +++ b/stackpacks/open-telemetry/settings/monitors/service-span-error-ratio/monitor.sty @@ -9,7 +9,7 @@ nodes: unit: percent threshold: 5 titleTemplate: Span error ratio - urnTemplate: "urn:opentelemetry:namespace/${service_namespace}:service/${service_name}" + urnTemplate: "urn:opentelemetry:namespace/${'service_namespace' in labels ? labels.service_namespace : ''}:service/${service_name}" description: | Percentage of server and consumer spans that are in an error state for the service. function: urn:stackpack:common:monitor-function:threshold diff --git a/stackpacks/open-telemetry/settings/relation-mappings/asynchronous-consumer-peer.sty b/stackpacks/open-telemetry/settings/relation-mappings/asynchronous-consumer-peer.sty index d5579e4..9d2240b 100644 --- a/stackpacks/open-telemetry/settings/relation-mappings/asynchronous-consumer-peer.sty +++ b/stackpacks/open-telemetry/settings/relation-mappings/asynchronous-consumer-peer.sty @@ -16,23 +16,28 @@ nodes: condition: >- 'client' in datapoint.attributes && 'server' in datapoint.attributes && - 'client_service.namespace' in datapoint.attributes && - 'server_service.namespace' in datapoint.attributes && 'connection_type' in datapoint.attributes && datapoint.attributes['connection_type'] == 'messaging_system' && 'client_peer.service' in datapoint.attributes vars: - - name: "sourceId" + - name: "clientServiceNamespace" + value: "'client_service.namespace' in datapoint.attributes ? datapoint.attributes['client_service.namespace'] : ''" + - name: "serverServiceNamespace" + value: "'server_service.namespace' in datapoint.attributes ? datapoint.attributes['server_service.namespace'] : ''" + - name: "server" + value: "datapoint.attributes['server']" + - name: "serverServiceInstanceId" value: >- 'server_service.instance.id' in datapoint.attributes ? - "urn:opentelemetry:namespace/" + datapoint.attributes['server_service.namespace'] + ":service/" + datapoint.attributes['server'] + ":serviceInstance/" + datapoint.attributes['server_service.instance.id'] : - "urn:opentelemetry:namespace/" + datapoint.attributes['server_service.namespace'] + ":service/" + datapoint.attributes['server'] + ":serviceInstance/" + datapoint.attributes['server'] - - name: "targetId" - value: >- - 'urn:opentelemetry:namespace/' + datapoint.attributes['client_service.namespace'] + ':service/' + datapoint.attributes['client_peer.service'] + datapoint.attributes['server_service.instance.id'] : + datapoint.attributes['server'] + - name: "peerService" + value: "datapoint.attributes['client_peer.service']" output: - sourceId: "vars.sourceId" - targetId: "vars.targetId" + sourceId: >- + 'urn:opentelemetry:namespace/' + vars.serverServiceNamespace + ':service/' + vars.server + ':serviceInstance/' + vars.serverServiceInstanceId + targetId: >- + 'urn:opentelemetry:namespace/' + vars.clientServiceNamespace + ':service/' + vars.peerService typeName: "'asynchronous'" dependencyType: "'CONNECTION'" expireAfter: 900000 diff --git a/stackpacks/open-telemetry/settings/relation-mappings/asynchronous-producer-consumer.sty b/stackpacks/open-telemetry/settings/relation-mappings/asynchronous-producer-consumer.sty index adb84d7..91ee103 100644 --- a/stackpacks/open-telemetry/settings/relation-mappings/asynchronous-producer-consumer.sty +++ b/stackpacks/open-telemetry/settings/relation-mappings/asynchronous-producer-consumer.sty @@ -16,25 +16,33 @@ nodes: condition: >- 'client' in datapoint.attributes && 'server' in datapoint.attributes && - 'client_service.namespace' in datapoint.attributes && - 'server_service.namespace' in datapoint.attributes && 'connection_type' in datapoint.attributes && datapoint.attributes['connection_type'] == 'messaging_system' && !('client_peer.service' in datapoint.attributes) vars: - - name: "sourceId" + - name: "clientServiceNamespace" + value: "'client_service.namespace' in datapoint.attributes ? datapoint.attributes['client_service.namespace'] : ''" + - name: "serverServiceNamespace" + value: "'server_service.namespace' in datapoint.attributes ? datapoint.attributes['server_service.namespace'] : ''" + - name: "client" + value: "datapoint.attributes['client']" + - name: "server" + value: "datapoint.attributes['server']" + - name: "clientServiceInstanceId" value: >- 'client_service.instance.id' in datapoint.attributes ? - "urn:opentelemetry:namespace/" + datapoint.attributes['client_service.namespace'] + ":service/" + datapoint.attributes['client'] + ":serviceInstance/" + datapoint.attributes['client_service.instance.id'] : - "urn:opentelemetry:namespace/" + datapoint.attributes['client_service.namespace'] + ":service/" + datapoint.attributes['client'] + ":serviceInstance/" + datapoint.attributes['client'] - - name: "targetId" + datapoint.attributes['client_service.instance.id'] : + datapoint.attributes['client'] + - name: "serverServiceInstanceId" value: >- 'server_service.instance.id' in datapoint.attributes ? - "urn:opentelemetry:namespace/" + datapoint.attributes['server_service.namespace'] + ":service/" + datapoint.attributes['server'] + ":serviceInstance/" + datapoint.attributes['server_service.instance.id'] : - "urn:opentelemetry:namespace/" + datapoint.attributes['server_service.namespace'] + ":service/" + datapoint.attributes['server'] + ":serviceInstance/" + datapoint.attributes['server'] + datapoint.attributes['server_service.instance.id'] : + datapoint.attributes['server'] output: - sourceId: "vars.sourceId" - targetId: "vars.targetId" + sourceId: >- + 'urn:opentelemetry:namespace/' + vars.clientServiceNamespace + ':service/' + vars.client + ':serviceInstance/' + vars.clientServiceInstanceId + targetId: >- + 'urn:opentelemetry:namespace/' + vars.serverServiceNamespace + ':service/' + vars.server + ':serviceInstance/' + vars.serverServiceInstanceId typeName: "'asynchronous'" dependencyType: "'CONNECTION'" expireAfter: 900000 diff --git a/stackpacks/open-telemetry/settings/relation-mappings/asynchronous-producer-peer.sty b/stackpacks/open-telemetry/settings/relation-mappings/asynchronous-producer-peer.sty index e65c035..82e3026 100644 --- a/stackpacks/open-telemetry/settings/relation-mappings/asynchronous-producer-peer.sty +++ b/stackpacks/open-telemetry/settings/relation-mappings/asynchronous-producer-peer.sty @@ -16,22 +16,26 @@ nodes: condition: >- 'client' in datapoint.attributes && 'server' in datapoint.attributes && - 'client_service.namespace' in datapoint.attributes && 'connection_type' in datapoint.attributes && datapoint.attributes['connection_type'] == 'messaging_system' && 'client_peer.service' in datapoint.attributes vars: - - name: "sourceId" + - name: "clientServiceNamespace" + value: "'client_service.namespace' in datapoint.attributes ? datapoint.attributes['client_service.namespace'] : ''" + - name: "client" + value: "datapoint.attributes['client']" + - name: "clientServiceInstanceId" value: >- 'client_service.instance.id' in datapoint.attributes ? - "urn:opentelemetry:namespace/" + datapoint.attributes['client_service.namespace'] + ":service/" + datapoint.attributes['client'] + ":serviceInstance/" + datapoint.attributes['client_service.instance.id'] : - "urn:opentelemetry:namespace/" + datapoint.attributes['client_service.namespace'] + ":service/" + datapoint.attributes['client'] + ":serviceInstance/" + datapoint.attributes['client'] - - name: "targetId" - value: >- - 'urn:opentelemetry:namespace/' + datapoint.attributes['client_service.namespace'] + ':service/' + datapoint.attributes['client_peer.service'] + datapoint.attributes['client_service.instance.id'] : + datapoint.attributes['client'] + - name: "peerService" + value: "datapoint.attributes['client_peer.service']" output: - sourceId: "vars.sourceId" - targetId: "vars.targetId" + sourceId: >- + 'urn:opentelemetry:namespace/' + vars.clientServiceNamespace + ':service/' + vars.client + ':serviceInstance/' + vars.clientServiceInstanceId + targetId: >- + 'urn:opentelemetry:namespace/' + vars.clientServiceNamespace + ':service/' + vars.peerService typeName: "'asynchronous'" dependencyType: "'CONNECTION'" expireAfter: 900000 diff --git a/stackpacks/open-telemetry/settings/relation-mappings/executes-ecs-task.sty b/stackpacks/open-telemetry/settings/relation-mappings/executes-ecs-task.sty index b48aad8..0b362cd 100644 --- a/stackpacks/open-telemetry/settings/relation-mappings/executes-ecs-task.sty +++ b/stackpacks/open-telemetry/settings/relation-mappings/executes-ecs-task.sty @@ -15,10 +15,9 @@ nodes: value: "resource.attributes['aws.ecs.task.id']" - name: "namespace" value: >- - 'service.namespace' in resource.attributes && - resource.attributes['service.namespace'] != '' ? + 'service.namespace' in resource.attributes ? resource.attributes['service.namespace'] : - 'default' + '' - name: "service" value: "resource.attributes['service.name']" - name: "instanceId" diff --git a/stackpacks/open-telemetry/settings/relation-mappings/executes-function.sty b/stackpacks/open-telemetry/settings/relation-mappings/executes-function.sty index dc35c52..5c6deeb 100644 --- a/stackpacks/open-telemetry/settings/relation-mappings/executes-function.sty +++ b/stackpacks/open-telemetry/settings/relation-mappings/executes-function.sty @@ -15,10 +15,9 @@ nodes: value: "resource.attributes['faas.id']" - name: "namespace" value: >- - 'service.namespace' in resource.attributes && - resource.attributes['service.namespace'] != '' ? + 'service.namespace' in resource.attributes ? resource.attributes['service.namespace'] : - 'default' + '' - name: "service" value: "resource.attributes['service.name']" - name: "instanceId" diff --git a/stackpacks/open-telemetry/settings/relation-mappings/executes-host.sty b/stackpacks/open-telemetry/settings/relation-mappings/executes-host.sty index b91cef5..0c3f807 100644 --- a/stackpacks/open-telemetry/settings/relation-mappings/executes-host.sty +++ b/stackpacks/open-telemetry/settings/relation-mappings/executes-host.sty @@ -15,10 +15,9 @@ nodes: value: "resource.attributes['host.id']" - name: "namespace" value: >- - 'service.namespace' in resource.attributes && - resource.attributes['service.namespace'] != '' ? + 'service.namespace' in resource.attributes ? resource.attributes['service.namespace'] : - 'default' + '' - name: "service" value: "resource.attributes['service.name']" - name: "instanceId" diff --git a/stackpacks/open-telemetry/settings/relation-mappings/k8s-pod-to-otel.sty b/stackpacks/open-telemetry/settings/relation-mappings/k8s-pod-to-otel.sty index da973a0..4db079e 100644 --- a/stackpacks/open-telemetry/settings/relation-mappings/k8s-pod-to-otel.sty +++ b/stackpacks/open-telemetry/settings/relation-mappings/k8s-pod-to-otel.sty @@ -22,10 +22,9 @@ nodes: value: "resource.attributes['k8s.pod.name']" - name: "serviceNamespace" value: >- - 'service.namespace' in resource.attributes && - resource.attributes['service.namespace'] != '' ? + 'service.namespace' in resource.attributes ? resource.attributes['service.namespace'] : - 'default' + '' - name: "service" value: >- 'service.name' in resource.attributes ? diff --git a/stackpacks/open-telemetry/settings/relation-mappings/provided-by.sty b/stackpacks/open-telemetry/settings/relation-mappings/provided-by.sty index 1162cdf..52522e0 100644 --- a/stackpacks/open-telemetry/settings/relation-mappings/provided-by.sty +++ b/stackpacks/open-telemetry/settings/relation-mappings/provided-by.sty @@ -13,10 +13,9 @@ nodes: vars: - name: "namespace" value: >- - 'service.namespace' in resource.attributes && - resource.attributes['service.namespace'] != '' ? + 'service.namespace' in resource.attributes ? resource.attributes['service.namespace'] : - 'default' + '' - name: "service" value: "resource.attributes['service.name']" - name: "instanceId" diff --git a/stackpacks/open-telemetry/settings/relation-mappings/synchronous.sty b/stackpacks/open-telemetry/settings/relation-mappings/synchronous.sty index 6ee708b..5f208cd 100644 --- a/stackpacks/open-telemetry/settings/relation-mappings/synchronous.sty +++ b/stackpacks/open-telemetry/settings/relation-mappings/synchronous.sty @@ -16,15 +16,13 @@ nodes: condition: >- 'client' in datapoint.attributes && 'server' in datapoint.attributes && - 'client_service.namespace' in datapoint.attributes && - 'server_service.namespace' in datapoint.attributes && 'connection_type' in datapoint.attributes && datapoint.attributes['connection_type'] == '' vars: - name: "clientServiceNamespace" - value: "datapoint.attributes['client_service.namespace']" + value: "'client_service.namespace' in datapoint.attributes ? datapoint.attributes['client_service.namespace'] : ''" - name: "serverServiceNamespace" - value: "datapoint.attributes['server_service.namespace']" + value: "'server_service.namespace' in datapoint.attributes ? datapoint.attributes['server_service.namespace'] : ''" - name: "client" value: "datapoint.attributes['client']" - name: "server" diff --git a/stackpacks/open-telemetry/stackpack.yaml b/stackpacks/open-telemetry/stackpack.yaml index 43859e5..fde883a 100644 --- a/stackpacks/open-telemetry/stackpack.yaml +++ b/stackpacks/open-telemetry/stackpack.yaml @@ -1,5 +1,5 @@ name: "open-telemetry" -version: "0.1.5" +version: "0.1.6" schemaVersion: "2.0" displayName: "Open Telemetry" categories: [ "Open Telemetry" ]