Skip to content

Commit 2b10d24

Browse files
fix: report service.name and service.version as resource attributes (#236)
## Summary - `service.name` (and `service.version`) were missing from exported spans/logs/metrics. The value was only applied to the **instrumentation scope**, not the OpenTelemetry **resource**, so backends saw an empty `service.name`. - This is a regression from #176, which removed the lines that copied `options.serviceName` / `options.serviceVersion` into the resource attributes. They had been present since Oct 2025 (#36). - Restores those resource attributes in `Observability.add(metadata:into:)` and re-adds the `service.name` / `service.version` constants to `SemanticConvention`. ## Changes - `SemanticConvention`: re-add `serviceName` (`service.name`) and `serviceVersion` (`service.version`). - `Observability.add(metadata:into:)`: populate `service.name` / `service.version` resource attributes from `options.serviceName` / `options.serviceVersion`. ## Test plan - [ ] Build the SDK and TestApp. - [ ] Emit a span/log/metric and confirm the exported OTLP `resource.attributes` now includes `service.name` (and `service.version`). - [ ] Confirm the value reflects `ObservabilityOptions.serviceName` (e.g. `observability-ios-test-app` in the TestApp). Made with [Cursor](https://cursor.com) Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 8673cad commit 2b10d24

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

Sources/LaunchDarklyObservability/API/SemanticConvention.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ public enum SemanticConvention {
66
public static let telemetrySdkName = "telemetry.sdk.name"
77
public static let telemetryDistroName = "telemetry.distro.name"
88
public static let telemetryDistroVersion = "telemetry.distro.version"
9+
public static let serviceName = "service.name"
10+
public static let serviceVersion = "service.version"
911
public static let serviceNamespace = "service.namespace"
1012
public static let systemCpuUtilization = "system.cpu.utilization"
1113
public static let systemMemoryAppUsageBytes = "system.memory.app_usage_bytes"

Sources/LaunchDarklyObservability/Plugin/Observability.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ extension Observability {
9494
}
9595

9696
func add(metadata: EnvironmentMetadata, into resourceAttributes: inout [String: AttributeValue]) {
97+
resourceAttributes[SemanticConvention.serviceName] = .string(options.serviceName)
98+
resourceAttributes[SemanticConvention.serviceVersion] = .string(options.serviceVersion)
9799
resourceAttributes[SemanticConvention.launchdarklySdkVersion] = .string(String(format: "%@/%@", metadata.sdkMetadata.name, metadata.sdkMetadata.version))
98100
resourceAttributes[SemanticConvention.highlightProjectId] = .string(metadata.credential)
99101
resourceAttributes[SemanticConvention.telemetrySdkName] = .string("opentelemetry")

0 commit comments

Comments
 (0)