Skip to content

Commit 5fda28c

Browse files
committed
added test, reverted telementry name to 'opentelemetry'
1 parent 727f7d3 commit 5fda28c

File tree

2 files changed

+43
-9
lines changed

2 files changed

+43
-9
lines changed

Sources/Instrumentation/SDKResourceExtension/DataSource/TelemetryDataSource.swift

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,7 @@ public class TelemetryDataSource: ITelemetryDataSource {
2121
}
2222

2323
public var name: String {
24-
#if os(tvOS)
25-
return "tvOS"
26-
#elseif os(watchOS)
27-
return "watchOS"
28-
#elseif os(macOS)
29-
return "macOS"
30-
#else
31-
return "iOS"
32-
#endif
24+
"opentelemetry"
3325
}
3426

3527
public var version: String? {
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// Copyright 2021, OpenTelemetry Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
//
15+
import Foundation
16+
17+
import OpenTelemetryApi
18+
import OpenTelemetrySdk
19+
@testable import ResourceExtension
20+
import XCTest
21+
22+
class ResourcePropogationTests : XCTestCase {
23+
func testPropogation() {
24+
let defaultResource = Resource()
25+
let appProvider = ApplicationResourceProvider(source: ApplicationDataSource())
26+
let telemetryProvider = TelemetryResourceProvider(source: TelemetryDataSource())
27+
let resultResource = DefaultResources().get()
28+
29+
let defaultValue = defaultResource.attributes[ResourceAttributes.serviceName.rawValue]?.description
30+
let resultValue = resultResource.attributes[ResourceAttributes.serviceName.rawValue]?.description
31+
let applicationName = appProvider.attributes[ResourceAttributes.serviceName.rawValue]?.description
32+
33+
34+
XCTAssertNotNil(defaultValue)
35+
XCTAssertNotNil(resultValue)
36+
XCTAssertNotNil(applicationName)
37+
XCTAssertEqual(resultValue, applicationName)
38+
XCTAssertNotEqual(resultValue, defaultValue)
39+
40+
41+
}
42+
}

0 commit comments

Comments
 (0)