Repository navigation
feat(java): add setAttributes and custom span/log processors - #861
Open
abelonogov-ld wants to merge 2 commits into
Open
abelonogov-ld wants to merge 2 commits into
abelonogov-ld wants to merge 2 commits into
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
This was referenced Oct 28, 2026
Co-authored-by: Cursor <cursoragent@cursor.com>
This was referenced Oct 29, 2026
Vadman97
approved these changes
Oct 29, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds global attributes and custom span/log processors to the Java server observability plugin. This is one of a set of matching PRs across RN, Android, iOS, Flutter, MAUI, Java and Python that share the same semantics (see #858, #859, #860, launchdarkly/swift-launchdarkly-observability#290).
Global attributes
LDObserve.setAttributes(Attributes)/LDObserve.removeAttributes(Collection<String>)keep one process-wide attribute set (AtomicReferenceto an immutable snapshot). Safe before init and thread-safe.LDObserve.getOpenTelemetry()), every log record, and metrics recorded throughLDObserve.LDObserve.shutdown()(process-wide lifetime).Custom processors (init-time options)
ObservabilityOptions.Builder.spanProcessors(List<SpanProcessor>)/logProcessors(List<LogRecordProcessor>), plusspanProcessor(...)/logProcessor(...)to add one at a time (mirrorscustomHeaders/customHeader).forceFlush/shutdownare forwarded and return a failed result instead of propagating.Dependency change:
opentelemetry-sdkmoves fromimplementationtoapi(compile scope in the published POM), becauseObservabilityOptionsnow exposes SDK processor types.checkPublishedPomenforces this. Same version; it was already a transitive runtime dependency.Not covered: metrics recorded on a meter obtained via
getOpenTelemetry()(onlyLDObservemetric methods merge globals); documented in the README.How did you test this change?
./gradlew :lib:build(javadoc, POM, classpath and fixture checks, tests) and./gradlew :lib:test -PldServerSdkVersion=7.10.1(as CI) pass: 146 tests, 0 failures.GlobalAttributesTest,SafeProcessorTest): merge/remove, name matching across types, per-call precedence, null/empty input, concurrent writes, span and log filling, throwing processors, flush/shutdown forwarding.PluginUserFlowTestwith a realLDClientand a local OTLP collector: globals set before start reach flag-evaluation, manual and error spans, logs and metrics; per-call values win; removed keys are not applied; spans keep start-time values; user processors run in order and their changes reach the exported payload; sampling still drops matching spans; throwing processors don't break export, flush or shutdown.javapconfirms every SDK method used exists in OpenTelemetry 1.38.0, the plugin's minimum.Are there any deployment considerations?
opentelemetry-sdkat compile scope instead of runtime scope; consumers see SDK types on their compile classpath.LDClientwith a different SDK key doesn't add its processors, consistent with how its other options are already ignored.Note
Overview
Adds process-wide global attributes and user-defined OpenTelemetry processors to the Java observability plugin, aligned with other LaunchDarkly SDKs.
Global attributes: New
LDObserve.setAttributes/removeAttributeskeep a thread-safe, merge-by-key store (safe before plugin init, survives shutdown). Globals are applied to exported spans and logs via dedicated processors inOtelManager, and to metrics recorded throughLDObserveviaGlobalAttributes.merge. Per-call or span-builder attributes win on key conflicts; spans snapshot globals at start.Custom processors:
ObservabilityOptionsnow accepts orderedSpanProcessorandLogRecordProcessorlists (single-add helpers too). They run after global-attribute injection and before level filtering, sampling, and export; failures are wrapped inSafeSpanProcessor/SafeLogRecordProcessorso export continues.Packaging:
opentelemetry-sdkis promoted to compile-scopedapibecause processor types are part of the public options API; POM checks were updated.The Spring Boot e2e app sets UTM globals before startup and prints
[#1]expectations on each request so manual verification in LaunchDarkly is straightforward.Reviewed by Cursor Bugbot for commit be24b27. Bugbot is set up for automated code reviews on this repo. Configure here.