Chunk distribution diagnostics

For testing purposes, I would like to log the peer from which each chunk is fetched, when a pin is executed.
Is there any way to achieve this?

I could do
"ipfs ls <file_hash>"
and then
"ipfs dht findprovs <chunk_hash>"
for all the chunks, to get a list of providers for each chunk of the file.

But is this list the priority order IPFS uses to get the chunks?

I think you can do this using the debug output as described in the linked thread.

@leerspace thanks for the info.
I’m afraid i cannot use "--debug" in my usecase.

Is there any chance, when a chunk is needed, IPFS alters the list returned by "ipfs dht findprovs <chunk_hash>" by considering other network metrics?

If we assume that there will be no peer downtimes, is it safe to say that each chunk will be fetched from the first peer of the above list?

EDIT:
The method i mentioned above is not working as expected, since "ls <file_hash>" fetches the file and adds local peer as a provider.

I don’t for sure, but I’d be really surprised if it does. Regardless of which peer the block is requested from first (even if you ignore your peer ID showing up in the list), there’s no guarantee they’ll be the first to send it; even if we assume that all nodes are friendly, the first node might be too busy to respond in a timely fashion due to processing other requests.

This doesn’t solve your issue, but you can prevent this behavior by changing the reprovider strategy in your node’s config.

When using "dag get <file_hash>" instead of "ls <file_hash>" the local peer is added to the hash providers, but the contents of the hash are not downloaded!

So i guess i can use this (followed by "dht findprovs <chunk_hash>") to know, if not the actual sender of a chunk, how many peers is each chunk stored in, without downloading the entire file to local peer.

Can someone of the code gurus confirm that?

EDIT:
@leerspace i saw your answer after i wrote this, i will dig into it.
I am (slowly) approaching what i want to achieve: Having the knowledge of where the chunks of a specific hash are stored, but without altering the provider list of any hash involved.