Migrate server-side apm.addLabels to OTel dual-write helpers#259619
Migrate server-side apm.addLabels to OTel dual-write helpers#259619
Conversation
|
Pinging @elastic/fleet (Team:Fleet) |
|
Pinging @elastic/obs-presentation-team (Team:obs-presentation) |
src/platform/plugins/shared/telemetry_collection_manager/server/plugin.ts
Show resolved
Hide resolved
| { | ||
| attributes: { | ||
| 'span.type': type, | ||
| ...(labels ? prefixKeys(labels, 'kibana.') : {}), |
...flows_execution_engine/server/workflow_context_manager/workflow_execution_runtime_manager.ts
Show resolved
Hide resolved
nkhristinin
left a comment
There was a problem hiding this comment.
DE changes LGTM, code review only
x-pack/platform/plugins/shared/alerting/server/task_runner/log_alerts.ts
Show resolved
Hide resolved
|
Pinging @elastic/security-detection-rule-management (Team:Detection Rule Management) |
|
Just wanted to call out for awareness regarding the dual-write helpers. When adding a label So if the goal is to have 100% backwards compatibility with existing queries, etc. that would use these attributes an option could be to transform The alternative is, to keep it as is and then to adjust all the existing assets that rely on labels. |
maximpn
left a comment
There was a problem hiding this comment.
Rule Management changes LGTM
|
@AlexanderWert Thanks for the input. we are moving away from APM totally so i would much rather have the nesting |
Squashed OTel dual-write (addSpanLabels / addTransactionLabels) and migrated server call sites. Replaces messy merge history with a single commit on current main. Ref #224830
ApprovabilityVerdict: Needs human review This PR introduces new OTel dual-write helpers and migrates ~15 call sites across multiple team-owned packages. While the migration pattern is consistent, it adds new runtime behavior (OTel span attributes) and touches code owned by ~10 different teams - none of which the author owns. The designated code owners should review changes to their observability instrumentation. No code changes detected at You can customize Macroscope's approvability policy. Learn more. |
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Public APIs missing comments
History
|
Summary
Creates dual-write helper functions (
addSpanLabels,addTransactionLabels) in@kbn/apm-utilsthat write labels to both APM and OpenTelemetry simultaneously, then migrates all actionable server-sideaddLabelscall sites to use these helpers.This ensures contextual metadata (execution context, rule IDs, connector types, feature flags, etc.) is preserved regardless of which telemetry backend is active. The change is purely additive — existing APM labels continue to work unchanged.
What changed
@kbn/apm-utils:addSpanLabelsandaddTransactionLabelsthat dual-write to APMaddLabelsand OTeltrace.getActiveSpan()?.setAttributes(). OTel attributes are auto-prefixed withkibana., with anotelAttributesescape hatch for custom attribute names.withSpanfix: Now dual-writes thelabelsoption to OTel span attributes even when APM IS started (previously OTel labels were only written when APM was off).apm_tracer.ts).root/index.tsunchanged (item 1) — dynamic global labels remain APM-only since OTel resources are immutable after provider creation.telemetry_collection_manager/plugin.ts— labels removed since they were already set viawithActiveSpanattributes on span creation.Closes #224830
Checklist
release_note:breakinglabel should be applied in these situations.release_note:*label is applied per the guidelinesbackport:*labels.Identify risks
setAttributesis a cheap in-memory operation. Both agents are already loaded.