This page contains information regarding Star Trek: Discovery, and thus may contain spoilers.
A fly was a type of winged insect. On Earth, they were known as pests that sometimes carried diseases. Means of trapping and/or killing flies include such household tools as fly swatters and flypaper.
The remains of these insects could be preserved in the resin amber. In early 2365, in his log, Captain Jean-Luc Picard of the USS Enterprise-D described his situation in the void as being "... like a fly in amber trapped." (TNG: "Where Silence Has Lease")
When Sito Jaxa suggested that it would be good to be a spider under the table of the observation lounge, Sam Lavelle compared this to be a fly on the wall. They were talking about the meeting of the senior staff in the observation lounge and were curious what they were talking about. (TNG: "Lower Decks")
Doctor Tolian Soran once stated that there was a time when he wouldn't hurt a fly, and then the Borg came, destroyed his homeworld, and showed him that the one constant in the whole universe was death. (Star Trek Generations)
Roy was a holographic fly created by Doctor Lewis Zimmerman in the 2370s for Starfleet Intelligence as a new form of micro-surveillance on the "Trojan Horse Project". When his mission was complete, Dr. Zimmerman kept him around on Jupiter Station as a pet. He nonetheless often landed on The Doctor's food. (VOY: "Life Line")