Trace Attributes

You can add/edit a custom trace attribute using the following APIs, passing a string key and a string value.

let urlPattern = "*.example.com/*"
let urlPredicate = NSPredicate(format: "SELF LIKE[c] '\(urlPattern)'")
APM.addNetworkTraceAttributesForURL(matching: urlPredicate, owner: self) { trace in
    return [
        "trace": "example"
    ]
}
[IBGAPM addNetworkTraceAttributesForURLMatchingPredicate:[NSPredicate predicateWithFormat:@"SELF LIKE[c] '%@'", @"*.example.com/*"]
                                                   owner:self
                                            usingHandler:^NSDictionary<NSString *,NSString *> * _Nullable(IBGNetworkTrace * _Nonnull networkTrace) {
    return @{
        @"type": @"example"
    };
}];
APM.addOnNetworkTraceListener(new OnNetworkTraceListener(
    new UrlPredicate() {
        @Override
        public boolean check(@NonNull String url) {
            // Add filter here the URL 
            // return boolean
        }
    }); 
    {
        @Override
        public Map<String, String> addAttributesOnFinish(NetworkTrace trace) {
            Map<String, String> map;
            map.put("Key", "Value");
            // Up to five attributes
            return map;
        }
    }
);
APM.addOnNetworkTraceListener(
    object: OnNetworkTraceListener(
                UrlPredicate { url:String ->
                    // Add filter here the URL 
                    // return boolean
                }
    )
    {
        override fun addAttributesOnFinish(trace: NetworkTrace?): MutableMap<String, String?> {
            // Return map of Pairs (i.e. keys and values)
            return mutableMapOf(
                        // Up to five attributes
                    Pair("Key", "Value")
            )
        }
    }
)