Skip to content

Commit 0d4f90c

Browse files
authored
Fix ios number conversion and upgrade otel (signalfx#70)
1 parent 3b107fc commit 0d4f90c

4 files changed

Lines changed: 100 additions & 75 deletions

File tree

example/ios/Podfile.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ PODS:
497497
- RCT-Folly (= 2021.07.22.00)
498498
- React-Core
499499
- SocketRocket (0.6.1)
500-
- splunk-otel-react-native (0.3.0):
500+
- splunk-otel-react-native (0.3.1):
501501
- DeviceKit (~> 4.0)
502502
- PLCrashReporter (~> 1.11)
503503
- React-Core
@@ -739,10 +739,10 @@ SPEC CHECKSUMS:
739739
ReactCommon: 91ece8350ebb3dd2be9cef662abd78b6948233c0
740740
RNScreens: 3c2d122f5e08c192e254c510b212306da97d2581
741741
SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17
742-
splunk-otel-react-native: a9aa98bc64460b78fb470365cc465cdd7feba82b
742+
splunk-otel-react-native: 1e84229010d68b5e9ca1f7e48414a7c678444fa3
743743
Yoga: 86fed2e4d425ee4c6eab3813ba1791101ee153c6
744744
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a
745745

746-
PODFILE CHECKSUM: 43525f2fc52f01068fed659b4b70dfe433901dd5
746+
PODFILE CHECKSUM: 5009b8cc36e00dbdd65a448c2f8e5dfab9669070
747747

748748
COCOAPODS: 1.11.3

ios/ZipkinTransform.swift

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ struct ZipkinTransform {
111111
let spanId = otelSpan["id"] as? String ?? "0000000000000000"
112112
let name = otelSpan["name"] as? String ?? "unknown"
113113
let jsTags = otelSpan["tags"] as? Dictionary<String, Any> ?? [:]
114+
let timestamp = anyToUInt64(otelSpan["timestamp"])
115+
let duration = anyToUInt64(otelSpan["duration"])
114116

115117
var tags: Dictionary<String, String> = [:]
116118

@@ -134,8 +136,8 @@ struct ZipkinTransform {
134136
id: spanId,
135137
kind: otelSpan["kind"] as? String,
136138
name: name,
137-
timestamp: otelSpan["timestamp"] as? UInt64 ?? 0,
138-
duration: otelSpan["duration"] as? UInt64 ?? 0,
139+
timestamp: timestamp,
140+
duration: duration,
139141
remoteEndpoint: nil,
140142
annotations: [],
141143
tags: tags)
@@ -155,3 +157,26 @@ extension ZipkinSpan {
155157
self.annotations.append(ZipkinAnnotation(timestamp: UInt64(timestamp.timeIntervalSince1970 * 1e6), value: name))
156158
}
157159
}
160+
161+
fileprivate func anyToUInt64(_ v: Any?) -> UInt64 {
162+
if v == nil {
163+
return 0
164+
}
165+
166+
switch v {
167+
case is Double:
168+
let doubleValue = v as! Double
169+
if (doubleValue >= 0.0) {
170+
return UInt64(doubleValue)
171+
}
172+
return 0
173+
case is Int:
174+
let intValue = v as! Int
175+
if (intValue >= 0) {
176+
return UInt64(intValue)
177+
}
178+
return 0
179+
default:
180+
return 0
181+
}
182+
}

package-lock.json

Lines changed: 64 additions & 64 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,12 @@
101101
]
102102
},
103103
"dependencies": {
104-
"@opentelemetry/api": "^1.4.1",
105-
"@opentelemetry/core": "^1.14.0",
106-
"@opentelemetry/resources": "^1.14.0",
107-
"@opentelemetry/sdk-trace-base": "^1.14.0",
108-
"@opentelemetry/sdk-trace-web": "^1.14.0",
109-
"@opentelemetry/semantic-conventions": "^1.14.0"
104+
"@opentelemetry/api": "^1.7.0",
105+
"@opentelemetry/core": "1.20.0",
106+
"@opentelemetry/resources": "1.20.0",
107+
"@opentelemetry/sdk-trace-base": "1.20.0",
108+
"@opentelemetry/sdk-trace-web": "1.20.0",
109+
"@opentelemetry/semantic-conventions": "1.20.0"
110110
},
111111
"publishConfig": {
112112
"access": "public"

0 commit comments

Comments
 (0)