Commit c67ce73
feat: Update OpenTelemetry semantic conventions (#89)
## Summary
Updates the Java OpenTelemetry tracing hook to align with the [latest
semantic conventions for feature flag
evaluation](https://github.com/launchdarkly/sdk-specs/blob/main/specs/OTEL-openteletry-integration/README.md).
This includes renaming existing attributes, adding new optional
attributes, and updating the configuration API while maintaining
backward compatibility.
Reference implementations:
[dotnet-core#148](launchdarkly/dotnet-core#148),
[go-server-sdk#292](launchdarkly/go-server-sdk#292)
## Changes
### Attribute Name Updates (Breaking Change)
- `feature_flag.provider_name` → `feature_flag.provider.name`
- `feature_flag.variant` → `feature_flag.result.value`
- `feature_flag.context.key` → `feature_flag.context.id`
### New Optional Attributes
- `feature_flag.result.variationIndex` - Added when variation index is
not `NO_VARIATION` (-1)
- `feature_flag.result.reason.inExperiment` - Added when
`isInExperiment()` returns true
### API Changes
- Added `Builder.withValue()` method (recommended)
- Deprecated `Builder.withVariant()` method (still functional,
internally calls `withValue()`)
- Renamed internal field from `withVariant` to `withValue`
### Implementation Details
- Both `beforeEvaluationInternal` and `afterEvaluation` now include the
provider name attribute
- New attributes are conditionally added based on evaluation details
- Test assertions updated to account for the additional `variationIndex`
attribute
## Review Checklist
**Critical items for review:**
- [ ] Verify attribute names exactly match the [OpenTelemetry semantic
conventions
spec](https://github.com/launchdarkly/sdk-specs/blob/main/specs/OTEL-openteletry-integration/README.md)
- [ ] Confirm conditional logic for `isInExperiment()` and
`variationIndex` is correct
- [ ] Review backward compatibility strategy for deprecated
`withVariant()` method
- [ ] Verify test coverage adequately validates the new optional
attributes
**Notes:**
- The `feature_flag.set.id` attribute is not included because the Java
SDK's `EvaluationSeriesContext` does not currently have an
`environmentId` field (consistent with the Go implementation)
- CI failures appear to be unrelated dependency resolution issues
(`nanohttpd` not found) in other modules
- Local tests for the `java-server-sdk-otel` module pass successfully
---
**Requirements**
- [x] I have added test coverage for new or changed functionality
- [x] I have followed the repository's [pull request submission
guidelines](../blob/main/CONTRIBUTING.md#submitting-pull-requests)
- [x] I have validated my changes against all supported platform
versions
**Related issues**
Request from rlamb@launchdarkly.com to update Java OpenTelemetry tracing
hook to latest semantic conventions.
**Additional context**
- Link to Devin run:
https://app.devin.ai/sessions/e4f4cdd8b60047ad9402001186442975
- Requested by: rlamb@launchdarkly.com
---------
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: rlamb@launchdarkly.com <rlamb@launchdarkly.com>
Co-authored-by: Ryan Lamb <4955475+kinyoklion@users.noreply.github.com>1 parent 96511ca commit c67ce73
File tree
2 files changed
+45
-23
lines changed- lib/java-server-sdk-otel/src
- main/java/com/launchdarkly/integrations
- test/java/com/launchdarkly/integrations
2 files changed
+45
-23
lines changedLines changed: 35 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | | - | |
29 | | - | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
30 | 32 | | |
31 | 33 | | |
32 | | - | |
| 34 | + | |
33 | 35 | | |
34 | 36 | | |
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
38 | | - | |
| 40 | + | |
39 | 41 | | |
40 | | - | |
| 42 | + | |
41 | 43 | | |
42 | 44 | | |
43 | | - | |
| 45 | + | |
44 | 46 | | |
45 | 47 | | |
46 | 48 | | |
| |||
60 | 62 | | |
61 | 63 | | |
62 | 64 | | |
| 65 | + | |
63 | 66 | | |
64 | 67 | | |
65 | 68 | | |
| |||
78 | 81 | | |
79 | 82 | | |
80 | 83 | | |
81 | | - | |
82 | | - | |
83 | | - | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
84 | 95 | | |
85 | 96 | | |
86 | 97 | | |
| |||
94 | 105 | | |
95 | 106 | | |
96 | 107 | | |
97 | | - | |
| 108 | + | |
98 | 109 | | |
99 | 110 | | |
100 | 111 | | |
| |||
105 | 116 | | |
106 | 117 | | |
107 | 118 | | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
108 | 128 | | |
109 | 129 | | |
110 | 130 | | |
| 131 | + | |
111 | 132 | | |
| 133 | + | |
112 | 134 | | |
113 | | - | |
| 135 | + | |
114 | 136 | | |
115 | 137 | | |
116 | 138 | | |
117 | 139 | | |
118 | 140 | | |
119 | 141 | | |
120 | 142 | | |
121 | | - | |
| 143 | + | |
122 | 144 | | |
123 | 145 | | |
124 | 146 | | |
Lines changed: 10 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
| 62 | + | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
66 | | - | |
| 65 | + | |
| 66 | + | |
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | | - | |
| 93 | + | |
94 | 94 | | |
95 | 95 | | |
96 | | - | |
97 | | - | |
| 96 | + | |
| 97 | + | |
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
| |||
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
121 | | - | |
| 121 | + | |
122 | 122 | | |
123 | 123 | | |
124 | | - | |
| 124 | + | |
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
| |||
0 commit comments