/// <summary> /// Process http outgoing request /// </summary> private void OnEventStart(object value) { var request = AgentUtil.FetchPropertyUsingReflection(value, "Request"); if (request is HttpWebRequest webRequest) { // Skip AWS SDK Request since it is instrumented using the SDK if (HttpRequestUtil.IsTraceable(webRequest)) { HttpRequestUtil.ProcessRequest(webRequest); try { var currentSubsegment = AWSXRayRecorder.Instance.GetEntity() as Subsegment; if (currentSubsegment != null) { CurrentHttpWebRequests.TryAdd(webRequest, currentSubsegment); } } catch (EntityNotAvailableException e) { AWSXRayRecorder.Instance.TraceContext.HandleEntityMissing(AWSXRayRecorder.Instance, e, "Subsegment is not available in trace context."); } } } }
private void AddLocalized(Vector3 v) { v = AgentUtil.Sigmoid(transform.InverseTransformVector(v)); obs.Add(v.x); obs.Add(v.y); obs.Add(v.z); }
private void OnEventStop(object value) { var context = AgentUtil.FetchPropertyUsingReflection(value, "HttpContext"); if (context is HttpContext httpContext) { AspNetCoreRequestUtil.ProcessResponse(httpContext); } }
private void OnEventException(object value) { // The value passed in is not castable, use fetch from reflection. var exc = AgentUtil.FetchPropertyUsingReflection(value, "Exception"); if (exc is Exception exception) { AspNetCoreRequestUtil.ProcessException(exception); } }
public void TestGetUserIdFirebirdSql() { DbConnectionStringBuilder builder = new DbConnectionStringBuilder() { ConnectionString = FirebirdSqlConnectionString }; object result = AgentUtil.GetUserId(builder); Assert.AreEqual("SYSDBA", result.ToString()); }
public void TestGetUserIdPostgreSql() { DbConnectionStringBuilder builder = new DbConnectionStringBuilder() { ConnectionString = PostgreSqlConnectionString }; object result = AgentUtil.GetUserId(builder); Assert.AreEqual("postgres", result.ToString()); }
public void TestGetUserIdSqlite() { DbConnectionStringBuilder builder = new DbConnectionStringBuilder() { ConnectionString = SqliteConnectionString }; object result = AgentUtil.GetUserId(builder); Assert.IsNull(result); }
public void TestGetUserIdSqlServer() { DbConnectionStringBuilder builder = new DbConnectionStringBuilder() { ConnectionString = SqlServerConnectionString }; object result = AgentUtil.GetUserId(builder); Assert.AreEqual("myUsername", result.ToString()); }
private void OnEventStart(object value) { // The value passed in is not castable, use fetch from reflection instead. var request = AgentUtil.FetchPropertyUsingReflection(value, "Request"); if (request is HttpRequestMessage httpRequestMessage) { // Skip AWS SDK Request since it is instrumented using the SDK if (HttpRequestUtil.IsTraceable(httpRequestMessage) && CurrentHttpRequestMessages.TryAdd(httpRequestMessage, null)) { HttpRequestUtil.ProcessRequest(httpRequestMessage); } } }
private void OnEventException(object value) { // The value passed in is not castable, use fetch from reflection instead. var request = AgentUtil.FetchPropertyUsingReflection(value, "Request"); var exc = AgentUtil.FetchPropertyUsingReflection(value, "Exception"); if (request is HttpRequestMessage httpRequestMessage && exc is Exception exception) { if (CurrentHttpRequestMessages.TryRemove(httpRequestMessage, out _)) { HttpRequestUtil.ProcessException(exception); } } }
private void OnEventStop(object value) { // This class serves for tracing Sql command from both System.Data.SqlClient and Microsoft.Data.SqlClient and using fetch property works // fot both of these two cases var command = AgentUtil.FetchPropertyUsingReflection(value, "Command"); if (command is DbCommand dbcommand) { if (CurrentDbCommands.TryRemove(dbcommand, out _)) { SqlRequestUtil.EndSubsegment(); } } }
/// <summary> /// Process exception /// </summary> private void OnEventException(object value) { var request = AgentUtil.FetchPropertyUsingReflection(value, "Request"); var status = AgentUtil.FetchPropertyUsingReflection(value, "StatusCode"); if (request is HttpWebRequest webRequest && status is HttpStatusCode httpStatusCode) { if (CurrentHttpWebRequests.TryRemove(webRequest, out var currentSubsegment)) { HttpRequestUtil.HandleStatus(httpStatusCode, currentSubsegment); HttpRequestUtil.EndSubsegment(currentSubsegment); } } }
private void OnEventStop(object value) { // The value passed in is not castable, use fetch from reflection instead. var request = AgentUtil.FetchPropertyUsingReflection(value, "Request"); var response = AgentUtil.FetchPropertyUsingReflection(value, "Response"); if (request is HttpRequestMessage httpRequestMessage && response is HttpResponseMessage httpResponseMessage) { if (CurrentHttpRequestMessages.TryRemove(httpRequestMessage, out _)) { HttpRequestUtil.ProcessResponse(httpResponseMessage); // End subsegment here HttpRequestUtil.EndSubsegment(); } } }
private void OnEventStart(object value) { // This class serves for tracing Sql command from both System.Data.SqlClient and Microsoft.Data.SqlClient and using fetch property works // fot both of these two cases var command = AgentUtil.FetchPropertyUsingReflection(value, "Command"); if (command is DbCommand dbcommand) { // Skip processing EntityFramework Core request if (SqlRequestUtil.IsTraceable() && CurrentDbCommands.TryAdd(dbcommand, null)) { SqlRequestUtil.BeginSubsegment(dbcommand); SqlRequestUtil.ProcessCommand(dbcommand); } } }
/// <summary> /// Process http response /// </summary> private void OnEventStop(object value) { var request = AgentUtil.FetchPropertyUsingReflection(value, "Request"); var response = AgentUtil.FetchPropertyUsingReflection(value, "Response"); if (request is HttpWebRequest webRequest && response is HttpWebResponse webResponse) { if (CurrentHttpWebRequests.TryRemove(webRequest, out var currentSubsegment)) { if (webResponse != null) { HttpRequestUtil.ProcessResponse(webResponse.StatusCode, webResponse.ContentLength, currentSubsegment); } HttpRequestUtil.EndSubsegment(currentSubsegment); } } }