-
-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Seperate internal metrics declaration model from the v1 (de)seri… (#652)
* Create version-specific serialization objects We need to support both serializing and deserializing the metric config. Currently, Promitor relies on the model matching the yaml schema, and just using the standard serialization from YamlDotNet. The problem with this is that if we introduce multiple config formats, we end up with a situation where the model objects used by the application don't match both (or either) of the config formats anymore, and so serialization won't work. Given that most of the tests currently rely on this serialization, it would end up with a pretty complicated change to sort this. So that we can still generate the old `v1` format, what I've done is created separate serialization objects for both config versions. This means that if you need to write out a config in a certain format, you can use those objects to define the configuration. NOTE: this commit doesn't compile but I want to add the files like this to make it easier to see what I'm doing as I make further changes. It can be rebased into future commits if it makes sense. * Implement builder pattern for v1 models Renamed all the models in the v1 namespace to `<ModelName>Builder` and added a `Build()` method to each of them. The reason for this is to distinguish between the model objects used by the application, and the models used for serialization. I've also added additional constructors to the resource model objects. The reason I did this was to make it easier for me to be sure that the builders were populating all of the properties on each object. I've left the default constructors in place. * Remove GetSecretValue from builder I've removed the `GetSecretValue()` method from the v1 `SecretBuilder` object because it's only needed by the model object, not the serialization objects. * Convert tests to use v1 config builders - Updated the tests to use the v1 builders. This should exactly match the previous behaviour. - Temporarily added an extra `Serialize()` method to `ConfigurationSerializer`. This is to allow the tests to serialize the v1 configuration objects. This will need to be removed / rethought before these changes are complete. * Rename "Builder" objects I've renamed the v1 config objects from `{Type}Builder` to `{Type}V1` since they aren't really builders. I'll remove the `Build()` methods in a further commit once there's an alternate way of mapping them. * Use AutoMapper to map between config and runtime - Added AutoMapper and created a profile for mapping between the V1 config model and the runtime model. - Removed the IVersionedConfigurationSerializer interface because it was forcing the version deserializers to return the runtime model. - Added a test to verify the AutoMapper config is valid. I haven't added any specific tests yet because there aren't any custom mappings. * Fix tests after AutoMapper changes A lot of the tests rely on fully serializing and then deserializing into the runtime model. Because of that, I've just updated them for now to use the v1 mapper profile and actually use AutoMapper in the tests. * Remove `Build()` method from config objects I've removed the `Build()` method from all the v1 config objects since it is no-longer required now that AutoMapper is handling the mapping. * Reorder MetricDefinition constructor arguments * Remove redundant type parameter
- Loading branch information
1 parent
6938750
commit c569c67
Showing
83 changed files
with
975 additions
and
361 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 13 additions & 1 deletion
14
...e.Scraping/Configuration/Model/Metrics/ResourceTypes/ContainerInstanceMetricDefinition.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 13 additions & 1 deletion
14
...e.Scraping/Configuration/Model/Metrics/ResourceTypes/ContainerRegistryMetricDefinition.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 13 additions & 1 deletion
14
...mitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/CosmosDbMetricDefinition.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 14 additions & 1 deletion
15
...r.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/GenericAzureMetricDefinition.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
...re.Scraping/Configuration/Model/Metrics/ResourceTypes/NetworkInterfaceMetricDefinition.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 13 additions & 1 deletion
14
...tor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/PostgreSqlMetricDefinition.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 13 additions & 1 deletion
14
...tor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/RedisCacheMetricDefinition.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 14 additions & 1 deletion
15
...ore.Scraping/Configuration/Model/Metrics/ResourceTypes/ServiceBusQueueMetricDefinition.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
...r.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/StorageQueueMetricDefinition.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
...Core.Scraping/Configuration/Model/Metrics/ResourceTypes/VirtualMachineMetricDefinition.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 0 additions & 12 deletions
12
...Core.Scraping/Configuration/Serialization/Interfaces/IVersionedConfigurationSerializer.cs
This file was deleted.
Oops, something went wrong.
8 changes: 4 additions & 4 deletions
8
src/Promitor.Core.Scraping/Configuration/Serialization/v1/Core/AggregationDeserializer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
src/Promitor.Core.Scraping/Configuration/Serialization/v1/Core/AzureMetadataDeserializer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.