LinkedIn connections API returns inconsistent numbers - linkedin

This looks like an old problem, but I am hoping that there is a new solution.
I make the following call:
https://api.linkedin.com/v1/people/~/connections:(email-address,first-name,last-name,headline,picture-url;secure=true,public-profile-url,id)?count=%ld&start=%ld
where count is 100 and start is 0. I then look at the returned _total count, and if it is greater than the returned _count + _start, then I issue the above call again with a new value for _start = _count + _start.
My expectation is that eventually, _start + _count is equal to _total, and I can stop requesting connections. However, with each call, this is what I see:
03:30:44.540 Induco[3873:413590] LinkedIn returned: count 100, start 0, total 807
03:30:45.288 Induco[3873:413590] LinkedIn returned: count 100, start 100, total 807
03:30:46.045 Induco[3873:413590] LinkedIn returned: count 100, start 200, total 807
03:30:46.818 Induco[3873:413590] LinkedIn returned: count 100, start 300, total 807
03:30:47.501 Induco[3873:413590] LinkedIn returned: count 100, start 400, total 807
03:30:48.192 Induco[3873:413590] LinkedIn returned: count 100, start 500, total 807
03:30:48.899 Induco[3873:413590] LinkedIn returned: count 100, start 600, total 807
03:30:49.457 Induco[3873:413590] LinkedIn returned: count 83, start 700, total 807
03:30:49.686 Induco[3873:413590] LinkedIn returned: count 0, start 783, total 807
03:30:49.933 Induco[3873:413590] LinkedIn returned: count 0, start 783, total 807
03:30:50.196 Induco[3873:413590] LinkedIn returned: count 0, start 783, total 807
03:30:50.475 Induco[3873:413590] LinkedIn returned: count 0, start 783, total 807
03:30:50.873 Induco[3873:413590] LinkedIn returned: count 0, start 783, total 807
03:30:51.140 Induco[3873:413590] LinkedIn returned: count 0, start 783, total 807
03:30:51.379 Induco[3873:413590] LinkedIn returned: count 0, start 783, total 807
03:30:51.673 Induco[3873:413590] LinkedIn returned: count 0, start 783, total 807
03:30:51.943 Induco[3873:413590] LinkedIn returned: count 0, start 783, total 807
It seems that LinkedIn will not return some number of my connections, and I have no way of knowing that, and my app will continue to query the server endlessly (or until the throttle limit is reached).
As an experiment, I set the count value at 100000 and still get:
03:53:12.610 Induco[3931:437503] LinkedIn returned: count 783, start 0, total 807
03:53:12.910 Induco[3931:437503] LinkedIn returned: count 0, start 783, total 807
Again, I can't seem to get all 807 connections. My research indicates that LinkedIn may be withholding private connections from me, however, this doesn't seem to be the right way to do so, given that we are to rely on the count, start and total figures in order to know whether we should stop querying for more connections. And to make matters more confusing, there are returned connections where the first name, last name values, among others, are set to "private". Hello?
Has anyone run into this and resolved it?

I guess the workaround is to keep asking and then stop when LinkedIn starts returning a 0 count.
Oh, LinkedIn, must you be so difficult?

Related

Are my unacknowledged kafka messages dropped due to network latency?

I have rdkafka producer written the following way, where localhost:9095 is tunneled to a digital ocean server in Germany with a kafka broker, whereas i, the localhost, am in New York.
I am noticing that at around ~150 miliseconds of thread::sleep(Duration::from_millis(150)) the last few of my messages stop being acknowledged by the callback (messages 8 and 9 for example),as if they didn't arrive. I know they did because i see the Kafka topic.
I'm wondering if my guess is correct that it is solely the latency between NY and Germany that dictates how long the broker takes to respond or if there is some config max.response.wait.ms setting i can set for acknowledgements to arrive sooner.
Of course if i increase the sleep time to ~200ms and higher i can see each message logged loud and clear. If i decrease sleep to 50ms the producer drops before any messages are sent and they never arrive to the topic... right?
let producer :ThreadedProducer< ProducerLogger> = ClientConfig::new()
.set("bootstrap.servers", "localhost:9095")
.create_with_context(ProducerLogger{})
.expect("Failed to create producer");
for i in 1..10{
let mut data = [0u8; 8];
rand::thread_rng().fill_bytes(&mut data);
println!("Sedndg msg with data {:x?}", data);
producer.send(
BaseRecord::to("rt-test")
.key(&format!("key-{}",i))
.payload(&format!("payload-{}",i))
)
.expect("couldn't send message");
// producer.flush(Duration::from_secs(1));
thread::sleep(Duration::from_millis(150)) // <--- Parameter to play with
}
Sedndg msg with data [da, 44, 1c, f0, 6, 1d, da, 9b]
Sedndg msg with data [37, 82, b2, 58, e2, 91, 40, 33]
Sedndg msg with data [8d, f8, 5c, df, 68, 12, a1, 26]
Sedndg msg with data [bd, 13, 7c, 81, 62, 5c, 93, 75]
Produced message key-1 successfully. Offset: 193. Partition :0
Produced message key-2 successfully. Offset: 194. Partition :0
Produced message key-3 successfully. Offset: 195. Partition :0
Produced message key-4 successfully. Offset: 196. Partition :0
Sedndg msg with data [d, 9d, 1c, 73, a7, 9f, b4, 2]
Produced message key-5 successfully. Offset: 197. Partition :0
Sedndg msg with data [c9, 1a, 3b, 8c, 31, cc, 84, f4]
Produced message key-6 successfully. Offset: 198. Partition :0
Sedndg msg with data [8a, 33, 26, 92, 2a, bf, d1, 7d]
Produced message key-7 successfully. Offset: 199. Partition :0
Sedndg msg with data [78, eb, e2, 41, 8d, b9, 29, 68]

AppInsights query to display RPS of each request

Below Application Insights query gets response time of each request.
Can we extend above query and also display RequestPerSeconds for each request ?
// this query calculates request duration percentiles and count by name
let start=datetime("2021-04-13T18:35:00.000Z");
let end=datetime("2021-04-13T18:52:00.000Z");
let timeGrain=5m;
let dataset=requests
// additional filters can be applied here
| where timestamp > start and timestamp < end
| where client_Type != "Browser"
;
dataset
// change 'operation_Name' on the below line to segment by a different property
| summarize count_=sum(itemCount), avg(duration), percentiles(duration, 50, 95, 99) by operation_Name
// calculate duration percentiles and count for all requests (overall)
| union(dataset
| summarize count_=sum(itemCount), avg(duration), percentiles(duration, 50, 95, 99)
| extend operation_Name="Overall")
Output
Operation_Name, count_, avg_duration, percentiles_duration_50, percentiles_duration_95, percentiles_duration_99
Request1,15,2.1,2.3,2.3,2.5
Request2, 10, 1.1,1.2,1.3,1.2
Thanks,
Anil
Per my understanding, RequestPerSeconds means request total counts / total seconds,
Based on your query, you can add
req_count_per_sec = todecimal(sum(itemCount))/todecimal(datetime_diff('second',end,start))

Json output from Vegeta HTTP load testing

I am using Vegeta to make some stress test but I am having some trouble while generating a json report. Running the following command I am able to see text results:
vegeta attack -targets="./vegeta_sagemaker_True.txt" -rate=10 -duration=2s | vegeta report -output="attack.json" -type=text
Requests [total, rate] 20, 10.52
Duration [total, attack, wait] 2.403464884s, 1.901136s, 502.328884ms
Latencies [mean, 50, 95, 99, max] 945.385864ms, 984.768025ms, 1.368113304s, 1.424427549s, 1.424427549s
Bytes In [total, mean] 5919, 295.95
Bytes Out [total, mean] 7104, 355.20
Success [ratio] 95.00%
Status Codes [code:count] 200:19 400:1
Error Set:
400
When I run the same command changing -type-text to -type=json I receive really weird numbers ad they don't make sense for me:
{
"latencies": {
"total": 19853536952,
"mean": 992676847,
"50th": 972074984,
"95th": 1438787021,
"99th": 1636579198,
"max": 1636579198
},
"bytes_in": {
"total": 5919,
"mean": 295.95
},
"bytes_out": {
"total": 7104,
"mean": 355.2
},
"earliest": "2019-04-24T14:32:23.099072+02:00",
"latest": "2019-04-24T14:32:25.00025+02:00",
"end": "2019-04-24T14:32:25.761337546+02:00",
"duration": 1901178000,
"wait": 761087546,
"requests": 20,
"rate": 10.519793517492838,
"success": 0.95,
"status_codes": {
"200": 19,
"400": 1
},
"errors": [
"400 "
]
}
Does anyone know why this should be happening?
Thanks!
These numbers are nanoseconds -- the internal representation of time.Duration in Go.
For example, the latencies.mean in the JSON is 992676847, which means 992676847 nanoseconds, that is 992676847/1000/1000 = 992.676847ms.
Actually, in vegeta, if you declare type as text (-type=text), it will use NewTextReporter, and print the time.Duration as a user-friendly string. If you declare type as json (-type=json), it will use NewJSONReporter and return time.Duration's internal representation:
A Duration represents the elapsed time between two instants as an int64 nanosecond count. The representation limits the largest representable duration to approximately 290 years.

compare 2 files based on 2 fields and give unmatched records using awk

I have 2 csv files with same format.
File 1:
account, desc, user, date
123, savings, 777, 22092014
234, current, 773, 22092014
456, savings, 772, 22092014
File 2:
account, desc, user, date
123, savings, 778, 22092014
765, savings, 779, 22092014
Keys from the files are 1st and 3rd fields from both the files. output should be only the record with modified key from both the files.user for account "123" is changed in second file.
We need only this record to be part of output file
123, savings, 778, 22092014
awk 'NR==FNR {user[$1]=$3; next} $1 in user && user[$1] != $3' file1 file2
123, savings, 778, 22092014

Two lines on a line graph with non proportional values

I am trying to get a googlecharts line graph to show me two line graphs with a Y axis of date and an x axis of total amount of substance used. It will be a line graph comparing, for example the total amount of alcohol consumed to tobacco consumed in total per each day.
The area i'm struggling with is figuring out how to show these lines more closely in relation to each other. The amount of total alcohol consumed in a day might be something like 1000mL with a range of 900 to 1100 while tobacco might just be something like 3 with a range of 2 - 4. As you can see, on a line graph these lines will be very far away from each other, and not really showing the correlation.
What would be the best system to do this with?
What you want is a combo chart. I started with the example code from the Combo Chart, changed the last column, and added the second axis. The parameter you care most about is the targetAxisIndex parameter.
function drawVisualization() {
// Create and populate the data table.
var data = google.visualization.arrayToDataTable([
['Month', 'Bolivia', 'Ecuador', 'Madagascar', 'Papua New Guinea', 'Rwanda', 'Average'],
['2004/05', 165, 938, 522, 998, 450, 614.6/100],
['2005/06', 135, 1120, 599, 1268, 288, 682/100],
['2006/07', 157, 1167, 587, 807, 397, 623/100],
['2007/08', 139, 1110, 615, 968, 215, 609.4/100],
['2008/09', 136, 691, 629, 1026, 366, 569.6/100]
]);
// Create and draw the visualization.
var ac = new google.visualization.ComboChart(document.getElementById('visualization'));
ac.draw(data, {
title : 'Monthly Coffee Production by Country',
width: 600,
height: 400,
vAxis: {title: "Cups"},
hAxis: {title: "Month"},
seriesType: "bars",
series: {5: {type: "line", "targetAxisIndex": "1"}}
});
}

Resources