|
| 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