Implement the compressed spans algorithm in the agent as described in https://github.com/elastic/apm/issues/432.