feat: set OTEL metrics temporality from the instance settings

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RbLzVfFDZ9pjBGHSzCSrNZ
This commit is contained in:
Ruben Fiszel
2026-09-10 16:56:25 +02:00
co-authored by Claude Opus 5
parent 8a7a9f485d
commit ce9fbd14bd
3 changed files with 37 additions and 0 deletions
+10
View File
@@ -732,6 +732,8 @@ struct OtelSetting {
otel_exporter_otlp_protocol: Option<String>,
#[serde(default, deserialize_with = "empty_as_none")]
otel_exporter_otlp_compression: Option<String>,
#[serde(default, deserialize_with = "empty_as_none")]
otel_exporter_otlp_metrics_temporality_preference: Option<String>,
}
pub async fn load_otel(db: &DB) {
@@ -788,6 +790,14 @@ pub async fn load_otel(db: &DB) {
std::env::set_var("OTEL_EXPORTER_OTLP_COMPRESSION", compression);
}
}
if let Some(temporality) = o.otel_exporter_otlp_metrics_temporality_preference {
unsafe {
std::env::set_var(
"OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE",
temporality,
);
}
}
println!("OTEL settings loaded: tracing ({tracing_enabled}), logs ({logs_enabled}), metrics ({metrics_enabled}), endpoint ({:?}), headers defined: ({})",
endpoint, headers.is_some());
} else {
@@ -631,6 +631,8 @@ pub struct OtelSettings {
pub otel_exporter_otlp_protocol: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub otel_exporter_otlp_compression: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub otel_exporter_otlp_metrics_temporality_preference: Option<String>,
}
/// Per-language HTTP request tracing proxy configuration.
@@ -31,6 +31,7 @@
import IndexerJobIndexSettings from './instanceSettings/IndexerJobIndexSettings.svelte'
import IndexerLogIndexSettings from './instanceSettings/IndexerLogIndexSettings.svelte'
import TextInput from './text_input/TextInput.svelte'
import Select from './select/Select.svelte'
import SettingCard from './instanceSettings/SettingCard.svelte'
interface Props {
@@ -694,6 +695,30 @@
<option value="http/protobuf">http/protobuf</option>
</select>
</div>
<div class="flex flex-col gap-1">
<label
for="OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE"
class="block text-xs font-semibold text-emphasis">Metrics temporality</label
>
<Select
id="OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE"
items={[
{ value: 'cumulative', label: 'cumulative' },
{ value: 'delta', label: 'delta' },
{ value: 'lowmemory', label: 'lowmemory' }
]}
placeholder="cumulative (default)"
clearable
disabled={!$enterpriseLicense}
bind:value={
$values[setting.key].otel_exporter_otlp_metrics_temporality_preference
}
/>
<span class="text-2xs font-normal text-secondary">
For delta-only intakes such as Datadog's, use lowmemory: counters and histograms
go out as delta, while gauges stay cumulative and keep reporting between updates.
</span>
</div>
{/if}
</div>
{:else if setting.fieldType == 'otel_tracing_proxy'}