internal static void WriteTelemetry(NDJsonWriter content) { if (content == null) { return; } if (Debugger.IsAttached && Debugger.IsLogging()) { Debugger.Log(0, null, content.ToString()); } }
internal HttpMessage CreateTrackRequest(ReadOnlyMemory <byte> body) { var message = _pipeline.CreateMessage(); var request = message.Request; request.Method = RequestMethod.Post; var uri = new RawRequestUriBuilder(); uri.AppendRaw(host, false); uri.AppendRaw("/v2", false); uri.AppendPath("/track", false); request.Uri = uri; request.Headers.Add("Content-Type", "application/json"); request.Headers.Add("Accept", "application/json"); using var content = new NDJsonWriter(); request.Content = RequestContent.Create(body); return(message); }
internal HttpMessage CreateTrackRequest(IEnumerable <TelemetryItem> body) { var message = _pipeline.CreateMessage(); var request = message.Request; request.Method = RequestMethod.Post; var uri = new RawRequestUriBuilder(); uri.AppendRaw(host, false); uri.AppendRaw("/v2", false); uri.AppendPath("/track", false); request.Uri = uri; request.Headers.Add("Content-Type", "application/json"); request.Headers.Add("Accept", "application/json"); using var content = new NDJsonWriter(); foreach (var item in body) { content.JsonWriter.WriteObjectValue(item); content.WriteNewLine(); } request.Content = RequestContent.Create(content.ToBytes()); return(message); }