Skip to content

Commit 153b8f2

Browse files
authored
Merge pull request #2275 from beyonnex-io/add-span-metrics-reporting-configuration
add feature toggle for configuring trace span metric reporting
2 parents 7ff4ef6 + b505030 commit 153b8f2

File tree

11 files changed

+56
-2
lines changed

11 files changed

+56
-2
lines changed

base/model/src/main/java/org/eclipse/ditto/base/model/signals/FeatureToggle.java

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,15 @@ public final class FeatureToggle {
5454
*/
5555
public static final String JSON_KEY_VALIDATION_ENABLED = "ditto.devops.feature.json-key-validation-enabled";
5656

57+
/**
58+
* System property name of the property defining whether when tracing is activated span metrics are also recorded
59+
* and exposed as Prometheus metrics. This is a built-in default of Kamon, Ditto's used tracing library, but can
60+
* be deactivated to reduce the amount of recorded metrics.
61+
*
62+
* @since 3.8.7
63+
*/
64+
public static final String TRACING_SPAN_METRICS_ENABLED = "ditto.devops.feature.tracing-span-metrics-enabled";
65+
5766
/**
5867
* Resolves the system property {@value MERGE_THINGS_ENABLED}.
5968
*/
@@ -79,6 +88,11 @@ public final class FeatureToggle {
7988
*/
8089
private static final boolean IS_JSON_KEY_VALIDATION_ENABLED = resolveProperty(JSON_KEY_VALIDATION_ENABLED);
8190

91+
/**
92+
* Resolves the system property {@value TRACING_SPAN_METRICS_ENABLED}.
93+
*/
94+
private static final boolean IS_TRACING_SPAN_METRICS_ENABLED = resolveProperty(TRACING_SPAN_METRICS_ENABLED);
95+
8296
private static boolean resolveProperty(final String propertyName) {
8397
final String propertyValue = System.getProperty(propertyName, Boolean.TRUE.toString());
8498
return !Boolean.FALSE.toString().equalsIgnoreCase(propertyValue);
@@ -183,10 +197,21 @@ public static boolean isPreserveKnownMqttHeadersFeatureEnabled() {
183197
/**
184198
* Returns whether JSON key validation is enabled based on the system property {@value JSON_KEY_VALIDATION_ENABLED}.
185199
*
186-
* @return whether JSON key validation is enabled based on the system property
200+
* @return whether JSON key validation is enabled.
187201
* @since 3.7.5
188202
*/
189203
public static boolean isJsonKeyValidationEnabled() {
190204
return IS_JSON_KEY_VALIDATION_ENABLED;
191205
}
206+
207+
/**
208+
* Returns whether tracing span metric reporting is enabled based on the system property
209+
* {@value TRACING_SPAN_METRICS_ENABLED}.
210+
*
211+
* @return whether tracing span metric reporting is enabled.
212+
* @since 3.8.7
213+
*/
214+
public static boolean isTracingSpanMetricsEnabled() {
215+
return IS_TRACING_SPAN_METRICS_ENABLED;
216+
}
192217
}

base/service/src/main/java/org/eclipse/ditto/base/service/DittoService.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,8 @@ private void injectSystemPropertiesLimits(final C serviceSpecificConfig) {
421421
Boolean.toString(rawConfig.getBoolean(FeatureToggle.PRESERVE_KNOWN_MQTT_HEADERS_ENABLED)));
422422
System.setProperty(FeatureToggle.JSON_KEY_VALIDATION_ENABLED,
423423
Boolean.toString(rawConfig.getBoolean(FeatureToggle.JSON_KEY_VALIDATION_ENABLED)));
424+
System.setProperty(FeatureToggle.TRACING_SPAN_METRICS_ENABLED,
425+
Boolean.toString(rawConfig.getBoolean(FeatureToggle.TRACING_SPAN_METRICS_ENABLED)));
424426
System.setProperty(DittoSystemProperties.DITTO_LIMITS_POLICY_IMPORTS_LIMIT,
425427
Integer.toString(limitsConfig.getPolicyImportsLimit()));
426428
final MetricsConfig metricsConfig = serviceSpecificConfig.getMetricsConfig();

deployment/helm/ditto/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ description: |
1616
A digital twin is a virtual, cloud based, representation of his real world counterpart
1717
(real world “Things”, e.g. devices like sensors, smart heating, connected cars, smart grids, EV charging stations etc).
1818
type: application
19-
version: 3.8.7 # chart version is effectively set by release-job
19+
version: 3.8.8 # chart version is effectively set by release-job
2020
appVersion: 3.8.6
2121
keywords:
2222
- iot-chart

deployment/helm/ditto/templates/connectivity-deployment.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,8 @@ spec:
216216
value: "{{ .Values.global.featureFlags.preserveKnownMqttHeadersEnabled }}"
217217
- name: DITTO_DEVOPS_FEATURE_JSON_KEY_VALIDATION_ENABLED
218218
value: "{{ .Values.global.featureFlags.jsonKeyValidationEnabled }}"
219+
- name: DITTO_DEVOPS_FEATURE_TRACING_SPAN_METRICS_ENABLED
220+
value: "{{ .Values.global.featureFlags.tracingSpanMetricsEnabled }}"
219221
- name: PEKKO_COORDINATED_SHUTDOWN_PHASES_CLUSTER_SHARDING_SHUTDOWN_REGION
220222
value: "{{ .Values.connectivity.config.cluster.coordinatedShutdown.phases.clusterShardingShutdownRegion.timeout }}"
221223
- name: PEKKO_COORDINATED_SHUTDOWN_PHASES_CLUSTER_EXITING_TIMEOUT

deployment/helm/ditto/templates/gateway-deployment.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@ spec:
201201
value: "{{ .Values.global.featureFlags.historicalApisEnabled }}"
202202
- name: DITTO_DEVOPS_FEATURE_JSON_KEY_VALIDATION_ENABLED
203203
value: "{{ .Values.global.featureFlags.jsonKeyValidationEnabled }}"
204+
- name: DITTO_DEVOPS_FEATURE_TRACING_SPAN_METRICS_ENABLED
205+
value: "{{ .Values.global.featureFlags.tracingSpanMetricsEnabled }}"
204206
- name: PEKKO_COORDINATED_SHUTDOWN_PHASES_CLUSTER_SHARDING_SHUTDOWN_REGION
205207
value: "{{ .Values.gateway.config.cluster.coordinatedShutdown.phases.clusterShardingShutdownRegion.timeout }}"
206208
- name: PEKKO_COORDINATED_SHUTDOWN_PHASES_CLUSTER_EXITING_TIMEOUT

deployment/helm/ditto/templates/policies-deployment.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,8 @@ spec:
210210
value: "{{ .Values.global.featureFlags.historicalApisEnabled }}"
211211
- name: DITTO_DEVOPS_FEATURE_JSON_KEY_VALIDATION_ENABLED
212212
value: "{{ .Values.global.featureFlags.jsonKeyValidationEnabled }}"
213+
- name: DITTO_DEVOPS_FEATURE_TRACING_SPAN_METRICS_ENABLED
214+
value: "{{ .Values.global.featureFlags.tracingSpanMetricsEnabled }}"
213215
- name: PEKKO_COORDINATED_SHUTDOWN_PHASES_CLUSTER_SHARDING_SHUTDOWN_REGION
214216
value: "{{ .Values.policies.config.cluster.coordinatedShutdown.phases.clusterShardingShutdownRegion.timeout }}"
215217
- name: PEKKO_COORDINATED_SHUTDOWN_PHASES_CLUSTER_EXITING_TIMEOUT

deployment/helm/ditto/templates/things-deployment.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@ spec:
214214
value: "{{ .Values.global.featureFlags.historicalApisEnabled }}"
215215
- name: DITTO_DEVOPS_FEATURE_JSON_KEY_VALIDATION_ENABLED
216216
value: "{{ .Values.global.featureFlags.jsonKeyValidationEnabled }}"
217+
- name: DITTO_DEVOPS_FEATURE_TRACING_SPAN_METRICS_ENABLED
218+
value: "{{ .Values.global.featureFlags.tracingSpanMetricsEnabled }}"
217219
- name: PEKKO_COORDINATED_SHUTDOWN_PHASES_CLUSTER_SHARDING_SHUTDOWN_REGION
218220
value: "{{ .Values.things.config.cluster.coordinatedShutdown.phases.clusterShardingShutdownRegion.timeout }}"
219221
- name: PEKKO_COORDINATED_SHUTDOWN_PHASES_CLUSTER_EXITING_TIMEOUT

deployment/helm/ditto/templates/thingssearch-deployment.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,8 @@ spec:
210210
value: "{{ .Values.global.limits.maxAuthSubjectsCount }}"
211211
- name: DITTO_DEVOPS_FEATURE_JSON_KEY_VALIDATION_ENABLED
212212
value: "{{ .Values.global.featureFlags.jsonKeyValidationEnabled }}"
213+
- name: DITTO_DEVOPS_FEATURE_TRACING_SPAN_METRICS_ENABLED
214+
value: "{{ .Values.global.featureFlags.tracingSpanMetricsEnabled }}"
213215
- name: PEKKO_COORDINATED_SHUTDOWN_PHASES_CLUSTER_SHARDING_SHUTDOWN_REGION
214216
value: "{{ .Values.thingsSearch.config.cluster.coordinatedShutdown.phases.clusterShardingShutdownRegion.timeout }}"
215217
- name: PEKKO_COORDINATED_SHUTDOWN_PHASES_CLUSTER_EXITING_TIMEOUT

deployment/helm/ditto/values.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ global:
155155
# jsonKeyValidationEnabled controls whether for each json object, each JSON key should be validated against a regex pattern
156156
# excluding control characters to be used as JSON keys. This can have quite a performance impact.
157157
jsonKeyValidationEnabled: true
158+
# tracingSpanMetricsEnabled controls whether when tracing is enabled, spans should automatically create metrics for span durations
159+
# reported as Prometheus histogram "span_processing_time_seconds".
160+
# As Ditto tracks a lot of spans, enabling those metrics can cause a lot of additional metrics and overhead.
161+
tracingSpanMetricsEnabled: true
158162
# logging the logging configuration for Ditto
159163
logging:
160164
# sysout holds the logging to SYSOUT config

internal/utils/config/src/main/resources/ditto-devops.conf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,12 @@ ditto.devops {
2828
// enables/disables the validation of json keys in JsonKeyValidator
2929
json-key-validation-enabled = true
3030
json-key-validation-enabled = ${?DITTO_DEVOPS_FEATURE_JSON_KEY_VALIDATION_ENABLED}
31+
32+
// enables/disables the reporting of span metrics by Kamon tracing
33+
// When tracing is activated, span metrics are also recorded and exposed as Prometheus metrics.
34+
// This is a built-in default of Kamon, Ditto's used tracing library, but can
35+
// be deactivated to reduce the amount of recorded metrics.
36+
tracing-span-metrics-enabled = true
37+
tracing-span-metrics-enabled = ${?DITTO_DEVOPS_FEATURE_TRACING_SPAN_METRICS_ENABLED}
3138
}
3239
}

0 commit comments

Comments
 (0)