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.

AI SDK does not collect HttpClient calls when response does not have content #739

Closed

Description

When an HTTP response contains only headers and not content (content-size = 0) then AI SDK (2.5-beta1) does not collect such calls as dependencies.

Repro

The following snippet for failure case should track 1) request (failed); 2) dependency (failed); 3) exception:

        public async Task<string> GetStringFromBackend(
            [FromUri] int numRetries,
            [FromUri] int dataStoreDelayInMS,
            [FromUri] double dataStoreFailureRatio)
        {
            while (true)
            {
                try
                {
                    string result = $"Hello from Backend: {DateTime.Now};";
                    using (var client = new HttpClient())
                    {
                        var response =
                            await
                                client.GetStringAsync(
                                        $"http://localhost.fiddler:8085/api/datastore/GetStringFromDataStore?delayInMS={dataStoreDelayInMS}&failureRatio={dataStoreFailureRatio}")
                                    .ConfigureAwait(false);
                        result += response;
                    }

                    return result;
                }
                catch (Exception ex)
                {
                    this.telemetry.TrackException(ex);

                    if (numRetries > 0)
                    {
                        --numRetries;
                        continue;
                    } 

                    throw new HttpResponseException(HttpStatusCode.InternalServerError);
                }
            }
        }

But with below response it tracks only request and exception but not dependency:

HTTP/1.1 500 Internal Server Error
Cache-Control: no-cache
Pragma: no-cache
Expires: -1
Server: Microsoft-IIS/8.5
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Sat, 11 Nov 2017 00:45:27 GMT
Content-Length: 0

After modification the response and including content AI SDK successfully tracks all three documents:

HTTP/1.1 500 Internal Server Error
Cache-Control: no-cache
Pragma: no-cache
Content-Length: 50
Content-Type: text/plain; charset=utf-8
Expires: -1
Server: Microsoft-IIS/8.5
X-AspNet-Version: 4.0.30319
Request-Context: appId=cid-v1:d79f37bd-6fea-487e-af26-f67978f70410
X-Powered-By: ASP.NET
Date: Sat, 11 Nov 2017 06:36:47 GMT

Reference ID: 346bacae-df64-4162-b55d-76711d062ae3

Workaround

Add some content to response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions