Skip to content

Commit a612f56

Browse files
Hongyan JiangGitHub Enterprise
authored andcommitted
Prepare release 1.6.4
* Fix issue for setCaptureHeaders method not capture http response header
1 parent 72c9c1e commit a612f56

File tree

8 files changed

+47
-11
lines changed

8 files changed

+47
-11
lines changed

Changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
## 1.6.4
4+
- Fix issue for setCaptureHeaders method not capture http response headers
5+
36
## 1.6.3
47
- Fix duplicated beacons issue
58

Dev/InstanaAgentExample/AppDelegate.swift

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,27 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
1313
var window: UIWindow? // needed on iOS 12 or lower
1414

1515
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
16+
let myLog = OSLog(subsystem: "com.instana.ios.InstanaAgentExample", category: "Instana")
17+
1618
// App needs to explicitly get user consent for metric events subscription before catching crash payloads.
1719
let userYes = Instana.canSubscribeCrashReporting() &&
1820
(UserDefaults.standard.integer(forKey: metricSubscriptionKey) == metricSubscriptionFlagYes)
1921

2022
let options = InstanaSetupOptions(enableCrashReporting: userYes)
2123
// options.slowSendInterval = 60.0
2224
if !Instana.setup(key: InstanaKey, reportingURL: InstanaURL, options: options) {
23-
let myLog = OSLog(subsystem: "com.instana.ios.InstanaAgentExample", category: "Instana")
2425
os_log("Instana setup failed", log: myLog, type: .error)
2526
}
27+
28+
var headerFilterReg: [NSRegularExpression] = []
29+
do {
30+
let regex = try NSRegularExpression(pattern: "Content-Type", options: .caseInsensitive)
31+
headerFilterReg.append(regex)
32+
} catch {
33+
os_log("Error creating regular expression", log: myLog, type: .error)
34+
}
35+
Instana.setCaptureHeaders(matching: headerFilterReg)
36+
2637
return true
2738
}
2839

InstanaAgent.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Pod::Spec.new do |s|
1616
#
1717

1818
s.name = "InstanaAgent"
19-
s.version = "1.6.3"
19+
s.version = "1.6.4"
2020
s.summary = "Instana iOS agent."
2121

2222
# This description is used to generate tags and improve search results.

Sources/InstanaAgent/Beacons/Reporter.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,7 @@ public class Reporter {
137137
return true
138138
}
139139

140-
var maxFlushingTimeAllowed = 10.0 // in seconds
141-
if isInSlowSendMode {
142-
maxFlushingTimeAllowed += session.configuration.slowSendInterval
143-
}
140+
let maxFlushingTimeAllowed = 10.0 // in seconds
144141

145142
let diff = Date().timeIntervalSince1970 - lastFlushStartTime!
146143
if diff > maxFlushingTimeAllowed {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
struct VersionConfig {
2-
static let agentVersion = "1.6.3"
2+
static let agentVersion = "1.6.4"
33
}

Sources/InstanaAgent/Monitors/HTTP/HTTPMarker.swift

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,32 @@ protocol HTTPMarkerDelegate: AnyObject {
8484
///
8585
/// Note: Make sure you don't call any methods on this HTTPMarker after you called finish
8686
@objc public func finish(response: URLResponse?, error: Error?) {
87-
let statusCode = (response as? HTTPURLResponse)?.statusCode ?? 400
87+
let httpURLResponse = (response as? HTTPURLResponse)
88+
let statusCode = httpURLResponse?.statusCode ?? 400
8889
let size = response != nil ? HTTPMarker.Size(response!) : nil
90+
91+
var bothHeaders: HTTPHeader = [:]
92+
let filter = Instana.current?.monitors.http?.filter
93+
if filter != nil, filter!.needHeaderFields() {
94+
// this header means http request header
95+
header?.forEach { key, value in
96+
if filter!.shouldUseHeaderField(key: key) {
97+
bothHeaders[key] = value
98+
}
99+
}
100+
101+
(httpURLResponse?.allHeaderFields)?.forEach { key, value in
102+
let key = key as? String
103+
let value = value as? String
104+
if key != nil, value != nil, filter!.shouldUseHeaderField(key: key!) {
105+
bothHeaders[key!] = value!
106+
}
107+
}
108+
}
109+
89110
let result = HTTPCaptureResult(statusCode: statusCode,
90111
backendTracingID: response?.backendTracingID,
91-
header: header,
112+
header: bothHeaders,
92113
responseSize: responseSize ?? size,
93114
error: error)
94115
finish(result)

Sources/InstanaAgent/Monitors/HTTP/HTTPMonitorFilter.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ class HTTPMonitorFilter {
2727
return filtered
2828
}
2929

30-
private func shouldUseHeaderField(key: String) -> Bool {
30+
func needHeaderFields() -> Bool {
31+
return !headerFieldsRegEx.isEmpty
32+
}
33+
34+
func shouldUseHeaderField(key: String) -> Bool {
3135
for regex in headerFieldsRegEx {
3236
let range = NSRange(location: 0, length: key.utf16.count)
3337
if !regex.matches(in: key, range: range).isEmpty {

Tests/InstanaAgentTests/Configuration/InstanaSystemUtilsTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class InstanaSystemUtilsTests: InstanaTestCase {
55

66
func test_AgentVersion() {
77
// Then
8-
AssertTrue(InstanaSystemUtils.agentVersion == "1.6.3")
8+
AssertTrue(InstanaSystemUtils.agentVersion == "1.6.4")
99
}
1010

1111
func test_systemVersion() {

0 commit comments

Comments
 (0)