You may have to periodically clean the inside of the burner with a wire brush.
I have one of quite old fashioned design but still in perfect working order. Periodically, however, the spark fails to ignite the gas.
Burner with cap in situ
Cap removed & flipped to show the state they can get in
Close up of spark mechanism
When they get this type of build-up, it's probably time to get a small steel wire brush & a vacuum cleaner in there. You don't need to aim for pristine, just get the majority of the movable dirt & rust off it. The actual burner ring [the crenellated cast iron section round the edge] may be removable for easier scrubbing. It should be keyed so it will only go back in the correct orientation.
Also clean the underside of the cap.
With the cap off, [and without turning on the gas] check that the spark jumps nicely round the ignition area. It won't always jump to the same place, but should show a reasonably even spread around that area. When the cap goes back on, the majority of the sparks should jump to the cap itself, but that's hard to see.
Test the burner's function with the cap back on.
If it's still a bit hit & miss… turn it off again, make sure it's not hot, then grab the cap firmly & 'screw' it back & forth half an inch, pressing firmly towards the burner. Try again.
I often find this last action to be the cure. It scrapes just enough against the metal components to enable a better electrical connection & the burner is good to go for another 6 months.
Repeat this 'twisty scrubbing' action every time it starts to get intermittent & you won't need to fully clean the burner for another year. (Out of sight, out of mind;)