Skip to content

Commit 6fc9920

Browse files
author
Ignacio Bonafonte
authored
Merge pull request #362 from nachoBonafonte/main
Allow OTEL_RESOURCE_ATTRIBUTES to be read from main Info.plist file
2 parents 93fd1d3 + 5ed1ef3 commit 6fc9920

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Sources/OpenTelemetrySdk/Resources/EnvVarResource.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,15 @@ public struct EnvVarResource {
1313
private static let labelKeyValueSplitter = Character("=")
1414

1515
/// This resource information is loaded from the OC_RESOURCE_LABELS
16-
/// environment variable.
16+
/// environment variable or from the Info.plist file of the application loading the framework.
1717
public static let resource = Resource().merging(other: Resource(attributes: parseResourceAttributes(rawEnvAttributes: ProcessInfo.processInfo.environment[otelResourceAttributesEnv])))
1818
private init() {}
1919

2020
public static func get(environment: [String: String] = ProcessInfo.processInfo.environment) -> Resource {
21-
return Resource().merging(other: Resource(attributes: parseResourceAttributes(rawEnvAttributes: environment[otelResourceAttributesEnv])))
21+
let attributesToRead = environment[otelResourceAttributesEnv] ??
22+
Bundle.main.infoDictionary?[otelResourceAttributesEnv] as? String
23+
24+
return Resource().merging(other: Resource(attributes: parseResourceAttributes(rawEnvAttributes: attributesToRead)))
2225
}
2326

2427
/// Creates a label map from the OC_RESOURCE_LABELS environment variable.

0 commit comments

Comments
 (0)