private static void SetBody <TRequest>(BaseScope scope, ServerCallContext context, TRequest request, SentryAspNetCoreOptions options) where TRequest : class, IMessage { var httpContext = context.GetHttpContext(); var extractors = httpContext.RequestServices .GetService <IEnumerable <IProtobufRequestPayloadExtractor> >(); if (extractors == null) { return; } var dispatcher = new ProtobufRequestExtractionDispatcher(extractors, options, () => options.MaxRequestBodySize); var adapter = new GrpcRequestAdapter <TRequest>(request); var message = dispatcher.ExtractPayload(adapter); if (message != null) { // Convert message into JSON format for readability string jsonData = JsonFormatter.Default.Format(message); scope.Request.Data = jsonData; } }
/// <summary> /// Whether a <see cref="User"/> has been set to the scope with any of its fields non null. /// </summary> /// <param name="scope"></param> /// <returns>True if a User was set to the scope. Otherwise, false.</returns> public static bool HasUser(this BaseScope scope) => scope.InternalUser != null && (scope.InternalUser.Email != null || scope.InternalUser.Id != null || scope.InternalUser.Username != null || scope.InternalUser.InternalOther?.Count > 0 || scope.InternalUser.IpAddress != null);
public void Apply_Sdk_SourceNone_TargetSingle_DoesNotModifyTarget() { var sut = _fixture.GetSut(); var target = new BaseScope(null); target.Sdk.AddPackage("nuget:Sentry", "1.0"); var expected = target.Sdk.Packages.Single(); sut.Apply(target); Assert.Same(expected, target.Sdk.InternalPackages.Single()); }
public void Apply_Sdk_SourceSingle_TargetNone_CopiesPackage() { var sut = _fixture.GetSut(); sut.Sdk.AddPackage("nuget:Sentry.Extensions.Logging", "2.0.0-preview10"); var target = new BaseScope(null); sut.Apply(target); Assert.Equal(sut.Sdk.InternalPackages, target.Sdk.InternalPackages); }
private static void Example8() { var baseScope = new BaseScope(); baseScope.ICanBeTaken = 4; baseScope.GetAllOfThem(); var assemblyScope = new AssemblyScope(); assemblyScope.GetWhatYouCan(); var inheritanceScope = new InheritanceScope(); inheritanceScope.GetSomeOfThem(); }
public void Apply_Sdk_SourceSingle_AddsIntegrations() { var sut = _fixture.GetSut(); sut.Sdk.AddPackage("nuget:Sentry.Extensions.Logging", "2.0.0-preview10"); var target = new BaseScope(null); sut.Sdk.AddPackage("nuget:Sentry.AspNetCore", "1.0.0"); sut.Apply(target); Assert.Equal(2, target.Sdk.InternalPackages.Count); }
private static void SetBody(BaseScope scope, HttpContext context, SentryAspNetCoreOptions options) { var extractors = context.RequestServices.GetService <IEnumerable <IRequestPayloadExtractor> >(); if (extractors == null) { return; } var dispatcher = new RequestBodyExtractionDispatcher(extractors, options, () => options.MaxRequestBodySize); var body = dispatcher.ExtractPayload(new HttpRequestAdapter(context.Request)); if (body != null) { scope.Request.Data = body; } }
/// <summary> /// Gets the specified provider based on the scope specified /// </summary> /// <param name="Scope">Scope</param> /// <returns>The specified provider</returns> public IProvider GetProvider(BaseScope Scope) { return(Providers.FirstOrDefault(x => x.ProviderScope.Equals(Scope))); }
/// <summary> /// Adds a breadcrumb to the scope. /// </summary> /// <param name="scope">The scope.</param> /// <param name="message">The message.</param> /// <param name="category">The category.</param> /// <param name="type">The type.</param> /// <param name="dataPair">The data key-value pair.</param> /// <param name="level">The level.</param> public static void AddBreadcrumb( this BaseScope scope, string message, string?category, string?type, (string, string)?dataPair = null,
public void Apply_Null_Source_DoesNotThrow() { BaseScope sut = null; sut.Apply(null); }
/// <summary> /// Sets the scope for the mapping /// </summary> /// <param name="Scope">The scope to use</param> /// <returns>Mapping object</returns> public virtual IMapping SetScope(BaseScope Scope) { this.Scope = Scope; Implementation = ProviderManager.GetProvider(Scope).CreateImplementation(Implementation, MappingManager); return(this); }
public AcgDebugDrawCardDirective(BaseScope rootScope) { this.rootScope = rootScope; link = linkFn; }
/// <summary> /// Determines if the objects are equal /// </summary> /// <param name="obj">Object to check against</param> /// <returns>True if they are equal, false otherwise</returns> public override bool Equals(object obj) { BaseScope Tempobj = obj as BaseScope; return(Tempobj != null && Tempobj.Name == Name); }