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

Modify all existing Telemetry types to implement IExtension #890

Merged
merged 31 commits into from
Aug 9, 2018

Conversation

cijothomas
Copy link
Contributor

@cijothomas cijothomas commented Aug 7, 2018

Following up on this PR (#875) which introduced the notion of IExtension ( #871) which enabled strongly typed extensions to existing types.

This PR makes all existing types (like RequestTelemetry, DependencyTelemetry etc) implement IExtension , thereby emitting serialization information. Current serialization logic is replaced with this one. With this, customers using non-AI backend/channel can use the existing types and serialize them to any format (bond,xml etc).

Note: Few items like updating public API in api analyzer is pending.

For significant contributions please make sure you have completed the following items:

  • Design discussion issue #
  • Changes in public surface reviewed
  • CHANGELOG.md updated with one line description of the fix, and a link to the original issue.
  • The PR will trigger build, unit test, and functional tests automatically. If your PR was submitted from fork - mention one of committers to initiate the build for you.

/// <summary>
/// Deeply clones the Extension of <see cref="AvailabilityTelemetry"/> object.
/// </summary>
IExtension IExtension.DeepClone()
Copy link
Contributor

Choose a reason for hiding this comment

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

this is not ideal. DeepClone needs to return ITelemetry so you can pass it to the processors and initializers. So maybe ITelemetry should be implementing IExtension?

{
serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName));
this.WriteEnvelopeProperties(serializationWriter);
Utils.CopyDictionary(this.Context.GlobalProperties, this.Data.properties);
Copy link
Contributor

Choose a reason for hiding this comment

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

serialize shouldn't mutate an object. Move dictionary copying some other place

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed this.

/// <inheritdoc/>
public void Serialize(ISerializationWriter serializationWriter)
{
serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName));
Copy link
Contributor

Choose a reason for hiding this comment

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

if AvailabilityTelemetry responsible for the entire envelope - it also need to serialize things like flags and samplingPercentage.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Its doing it next line.

Copy link
Contributor

@SergeyKanzhelev SergeyKanzhelev left a comment

Choose a reason for hiding this comment

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

See comments for AvailabilityTelemetry

IExtension for extensions.
ISerializableWithWriter for classes emitting serialization info.
…ializableWithWriter, ITelemetry dont implement the interface to avoid conufsion with the IExtension in ITelemetry
…ize method to follow the practise of NOT modifying data within serialize method.
@@ -3,16 +3,7 @@
/// <summary>
/// Interface for defining strongly typed extensions to telemetry types.
/// </summary>
public interface IExtension
public interface IExtension : ISerializableWithWriter, ICloneable
Copy link
Contributor

Choose a reason for hiding this comment

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

do we still need ISerializableWithWriter as a separate interface?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Its now used by all the InternalData classes. The main classes like RequestTelemetry invokes serialize on the InternalData..

@@ -52,9 +52,11 @@
<PackageReference Include="MicroBuild.Core" Version="0.3.0">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
<!--
<PackageReference Include="PublicApiAnalyzer" Version="1.0.0-alpha001">
Copy link
Contributor

Choose a reason for hiding this comment

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

unintended?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will enable it back once other comments are addressed. I chose to modify public.shipped.txt only after everything else is ready

Copy link
Contributor

Choose a reason for hiding this comment

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

I start review by looking at these files. Especially when there are so many files in PR. I'd appreciate if you can keep updating API files

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Understood. I have enabled it back and modified all public api files to reflect correct APIs. ( I disabled it because it was a disturbance while i was still tweaking API!)

/// <summary>
/// Partial class to implement ISerializableWithWriter
/// </summary>
internal partial class RemoteDependencyData : ISerializableWithWriter
Copy link
Contributor

Choose a reason for hiding this comment

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

perhaps Sanitize can be moved to this interface as well at some point

/// <summary>
/// Interface for defining method to Deeply clone the members.
/// </summary>
public interface ICloneable
Copy link
Contributor

Choose a reason for hiding this comment

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

The only consumer of this interface is IExtension. Why we need it as an interface then? Just define a method on that interface

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, removed.

Copy link
Contributor

@SergeyKanzhelev SergeyKanzhelev left a comment

Choose a reason for hiding this comment

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

Few more comments. Overall looks better

@cijothomas
Copy link
Contributor Author

@SergeyKanzhelev Pubic API files added back. Please continue reviewing.

@@ -178,6 +178,18 @@ public ITelemetry DeepClone()
return new AvailabilityTelemetry(this);
}

/// <inheritdoc/>
public void Serialize(ISerializationWriter serializationWriter)
Copy link
Contributor

Choose a reason for hiding this comment

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

Everything looks better now.... Now talk about usage of it - is it what our partners expect. I wonder if we need to have separate methods for envelope and separate for data part of it. This way envelope structure is not forced on consumer and there is a choice to optimize an envelope structure for specific channels. What do you think?

Copy link
Contributor

@SergeyKanzhelev SergeyKanzhelev left a comment

Choose a reason for hiding this comment

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

Will you switch to use these serializes instead of current one in a separate PR?

@cijothomas cijothomas merged commit 39518a7 into develop Aug 9, 2018
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.

2 participants