Skip to content

DependencyTelemetry.TryGetOperationDetail isn't as helpful as it could be #1350

@IanKemp

Description

@IanKemp

See microsoft/ApplicationInsights-dotnet-server#897.

  1. There is no indication as to what values can be passed as the key.
  2. There is no type-safety in the values returned.

tl;dr there's no way for anyone to know that they can call

if (myDependencyTelemetryInstance.TryGetOperationDetail("HttpRequest", out var rawMsg)
    && rawMsg is HttpRequestMessage message)
{
    // do something with message
}

The only reason I know to do the above is because I trawled through issues and PRs in this repo. Most people probably won't be as patient, and they shouldn't need to be.

Suggestion

  1. Publicly expose relevant RemoteDependencyConstants keys.
  2. Add specific overloads on DependencyTelemetry that reflect what HttpCoreDiagnosticSourceListener and HttpProcessing are storing:
  bool TryGetHttpRequestOperationDetail(out HttpRequestMessage message);
  bool TryGetHttpResponseOperationDetail(out HttpResponseMessage message);
  bool TryGetHttpResponseHeadersOperationDetail(out WebHeaderCollection headers);
  1. Actually publicise the existence of these predefined keys and values in the official docs for DependencyTelemetry.TryGetOperationDetail.

Metadata

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