googleinterns / cloud-operations-api-mock

Apache License 2.0
5 stars 3 forks source link

Store spans in memory and check for duplicate span names #13

Closed the-ericwang35 closed 4 years ago

the-ericwang35 commented 4 years ago

As per this comment from the proto, we cannot create spans with duplicate names. To make this check, we need to store the spans we receive in memory. This PR implements this by using a map of {spanName: span} in order to check for duplicates and also allow retrieval of spans by name in O(1) time .

This will also bridge into future PRs where we provide some additional custom RPCs for testing purposes, where we allow users to retrieve the data that they've exported (for example, retrieving how many spans have been created, etc.)