Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: accept duplicated service definitions #94

Merged
merged 1 commit into from
Oct 16, 2020

Conversation

gsanchezgavier
Copy link
Contributor

This PR allows two exporter with same metric namespace to have different definition files .

This approach just adds the entities from all definitions files that share the same service name to the same object.

In the future the entity discovery mechanism should be replaced and this approach will no longer be needed.

specs.SpecsByName[sd.Service] = sd
if spec, ok := specs.SpecsByName[sd.Service]; ok {
spec.Entities = append(spec.Entities, sd.Entities...)
specs.SpecsByName[sd.Service] = spec
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just curiosity, do you have to re-assign the variable in the map? Wouldn't it be sufficient to just append the entities?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was complaining that it was possible , but I will dig into that

Copy link
Contributor Author

@gsanchezgavier gsanchezgavier Oct 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's because the map references to a value and not a pointer. And there's no guarantee on the location of that value.
https://stackoverflow.com/questions/32751537/why-do-i-get-a-cannot-assign-error-when-setting-value-to-a-struct-as-a-value-i

@gsanchezgavier gsanchezgavier merged commit 108d60f into main Oct 16, 2020
@gsanchezgavier gsanchezgavier deleted the gsanchez/add_multiple_definition_files branch October 16, 2020 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants