private void DoStartSpan <TResult>(IDbCommand command, DbCommandInterceptionContext <TResult> interceptCtx, string dbgOriginalCaller) { if (Agent.Instance.Tracer.CurrentTransaction == null) { _logger.Debug()?.Log("There's' no current transaction - skipping starting span for DB-operation-started event"); return; } LogEvent("DB operation started - starting a new span...", command, interceptCtx, dbgOriginalCaller); var span = DbSpanCommon.StartSpan(Agent.Instance, command); interceptCtx.SetUserState(_userStateKey, span); }
private void HandleStartCommand(object payloadData, PropertyFetcherSet propertyFetcherSet) { try { if (propertyFetcherSet.StartCorrelationId.Fetch(payloadData) is Guid operationId && propertyFetcherSet.StartCommand.Fetch(payloadData) is IDbCommand dbCommand) { var span = DbSpanCommon.StartSpan(_apmAgent, dbCommand); _spans.TryAdd(operationId, span); } } catch (Exception ex) { //ignore _logger.Error()?.LogException(ex, "Exception was thrown while handling 'command started event'"); } }