Skip to content
This repository has been archived by the owner on Jun 10, 2020. It is now read-only.

Request tracking improvements #716

Merged
merged 6 commits into from
Jul 11, 2018
Merged

Conversation

lmolkova
Copy link
Member

@lmolkova lmolkova commented Jul 6, 2018

Fix Issue #709 and #613.
In order to make RequestTrackingTelemetryModule reusable in custom configuration (in particular for Azure Functions) we want to

  1. prevent response header injection when configured so - Azure function work for IoT scenarios and it hurts there
  2. prevent exception collection - Azure functions track exceptions in a different way
  3. make sure request.Source is set: OperationCorrelationTelemetryInititalzier was responsible for setting it, but it is overkill and this could be merged with the request tracking module.
  • I ran Unit Tests locally.

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

  • Changes in public surface reviewed

  • Design discussion issue #

  • CHANGELOG.md updated with one line description of the fix, and a link to the original issue.

  • The PR will trigger build, unit tests, and functional tests automatically. If your PR was submitted from fork - mention one of committers to initiate the build for you.
    If you want to to re-run the build/tests, the easiest way is to simply Close and Re-Open this same PR. (Just click 'close pull request' followed by 'open pull request' buttons at the bottom of the PR)

  • Please follow [these] (https://github.com/Microsoft/ApplicationInsights-aspnetcore/blob/develop/Readme.md) instructions to build and test locally.

Copy link
Contributor

@cijothomas cijothomas left a comment

Choose a reason for hiding this comment

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

Looks good. Please address the comment about breaking change in ConfigureTelemetryModule method.

@@ -236,14 +252,16 @@ public static IServiceCollection AddApplicationInsightsTelemetryProcessor(this I
/// <returns>
/// The <see cref="IServiceCollection"/>.
/// </returns>
public static IServiceCollection ConfigureTelemetryModule<T>(this IServiceCollection services, Action<T> configModule) where T : ITelemetryModule
public static IServiceCollection ConfigureTelemetryModule<T>(this IServiceCollection services,
Action<T, ApplicationInsightsServiceOptions> configModule) where T : ITelemetryModule
Copy link
Contributor

Choose a reason for hiding this comment

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

If we change the signature of this public method, existing customers will break upon upgrading. Can you avoid this breaking change?

Copy link
Member Author

Choose a reason for hiding this comment

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

good point, I'll add an overload

@@ -393,7 +397,7 @@ public void OnEndRequestFromDifferentInstrumentationKey()
Assert.True(requestTelemetry.Duration.TotalMilliseconds >= 0);
Assert.True(requestTelemetry.Success);
Assert.Equal(CommonMocks.InstrumentationKey, requestTelemetry.Context.InstrumentationKey);
Assert.Equal("", requestTelemetry.Source);
Assert.Equal("DIFFERENT_INSTRUMENTATION_KEY_HASH", requestTelemetry.Source);
Copy link
Member Author

Choose a reason for hiding this comment

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

this guy was validating the request telemetry without OperationCorrelationTelemetryIntitializer that set Source. Not sure what it was testing though :)

public class RequestTrackingTelemetryModuleTest
{
[Fact]
public void RequestTrackingTelemetryModuleDoesNoThrowWhenAppIdProviderisNull()
{
RequestTrackingTelemetryModule requestTrackingTelemetryModule = new RequestTrackingTelemetryModule(null);
}

[Fact]
public void RequestTrackingTelemetryModuleDoesNoThrowIfInitializeAfterDispose()
Copy link
Member Author

Choose a reason for hiding this comment

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

I ended up deleting this test, because I don't understand why RequestTrackingTelemetryModule should work after it was disposed. Is there a real-life scenario and why we have such a requirement?

services.AddSingleton<ITelemetryModule, DependencyTrackingTelemetryModule>();
services.ConfigureTelemetryModule<DependencyTrackingTelemetryModule>((module) => {
services.ConfigureTelemetryModule<DependencyTrackingTelemetryModule>((module, o) =>
Copy link
Contributor

Choose a reason for hiding this comment

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

dont need 2nd argument o.

Copy link
Member Author

Choose a reason for hiding this comment

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

I marked it as obsolete and want to get rid of it at some point. Do you want to keep it?

@@ -235,15 +251,37 @@ public static IServiceCollection AddApplicationInsightsTelemetryProcessor(this I
/// <param name="configModule">Action used to configure the module.</param>
/// <returns>
/// The <see cref="IServiceCollection"/>.
/// </returns>
/// </returns>
[Obsolete("Use ConfigureTelemetryModule overaload that accepts ApplicationInsightsServiceOptions.")]
Copy link
Contributor

Choose a reason for hiding this comment

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

overaload =>overload

@lmolkova
Copy link
Member Author

@cijothomas ping :)

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.

LGTM. One thing I miss in this repo is public surface analyzer to review changes in public surface quickly

@lmolkova lmolkova merged commit ab2cf1b into develop Jul 11, 2018
@lmolkova lmolkova deleted the lmolkova/RequestTrackingImprovmenets branch July 12, 2018 23:13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants