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

Enable Access to Dependency Request Objects in DependencyCollector #900

Closed

Description

Opening this item per comments on the pull request -- consolidating discussions referenced items.

#issues:
#820
#747
#587
#897

Please reference the issues and pull request for additional details and\or discussion.

Consumers of the dependency collection package would like to be able to populate additional data in the tracked telemetry through implementing ITelemetryInitializer classes. At present, this is not possible given only the data passed in the call to Initialize() is the dependency telemetry item itself with pre-defined fields populated from within the dependency collector.

The ask is to track key data in the dependency collection and provide access to it as part of the ITelemetry item passed to the initializers.

Here is a sample of intended use -- reporting a debug-id value from an http response:

public class SampleTelemetryInitializer : ITelemetryInitializer
{
    private const string DebugHeaderName = "debug-id";

    public void Initialize(ITelemetry telemetry)
    {
        var dependencyTelemetry = telemetry as DependencyTelemetry;
        if (dependencyTelemetry != null && dependencyTelemetry.TryGetOperationDetail("HttpResponse", out var reponseObject))
        {
            IEnumerable<string> debugData = null;

            var response = reponseObject as HttpResponseMessage;
            if (response?.Headers?.TryGetValues(DebugHeaderName, out debugData) ?? false)
            {
                if (debugData != null)
                {
                    dependencyTelemetry.Properties.Add(DebugHeaderName, string.Join(",", debugData));
                }
            }
        }
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions