Skip to content

Implemented DuplicateChecker #35

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 17, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 38 additions & 30 deletions dist/exceptionless.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,37 @@ export interface IEnvironmentInfo {
runtime_version?: string;
data?: any;
}
export interface IParameter {
data?: any;
generic_arguments?: string[];
name?: string;
type?: string;
type_namespace?: string;
}
export interface IMethod {
data?: any;
generic_arguments?: string[];
parameters?: IParameter[];
is_signature_target?: boolean;
declaring_namespace?: string;
declaring_type?: string;
name?: string;
module_id?: number;
}
export interface IStackFrame extends IMethod {
file_name?: string;
line_number?: number;
column?: number;
}
export interface IInnerError {
message?: string;
type?: string;
code?: string;
data?: any;
inner?: IInnerError;
stack_trace?: IStackFrame[];
target_method?: IMethod;
}
export declare class ConfigurationDefaultsPlugin implements IEventPlugin {
priority: number;
name: string;
Expand Down Expand Up @@ -358,36 +389,13 @@ export declare class SubmissionMethodPlugin implements IEventPlugin {
name: string;
run(context: EventPluginContext, next?: () => void): void;
}
export interface IParameter {
data?: any;
generic_arguments?: string[];
name?: string;
type?: string;
type_namespace?: string;
}
export interface IMethod {
data?: any;
generic_arguments?: string[];
parameters?: IParameter[];
is_signature_target?: boolean;
declaring_namespace?: string;
declaring_type?: string;
name?: string;
module_id?: number;
}
export interface IStackFrame extends IMethod {
file_name?: string;
line_number?: number;
column?: number;
}
export interface IInnerError {
message?: string;
type?: string;
code?: string;
data?: any;
inner?: IInnerError;
stack_trace?: IStackFrame[];
target_method?: IMethod;
export declare class DuplicateCheckerPlugin implements IEventPlugin {
priority: number;
name: string;
private recentlyProcessedErrors;
run(context: EventPluginContext, next?: () => void): void;
private getNow();
private checkDuplicate(error, log);
}
export interface IError extends IInnerError {
modules?: IModule[];
Expand Down
69 changes: 66 additions & 3 deletions dist/exceptionless.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/exceptionless.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/exceptionless.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/exceptionless.min.js.map

Large diffs are not rendered by default.

69 changes: 66 additions & 3 deletions dist/exceptionless.node.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/exceptionless.node.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/plugins/EventPluginManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { ModuleInfoPlugin } from './default/ModuleInfoPlugin';
import { RequestInfoPlugin } from './default/RequestInfoPlugin';
import { EnvironmentInfoPlugin } from './default/EnvironmentInfoPlugin';
import { SubmissionMethodPlugin } from './default/SubmissionMethodPlugin';
import { DuplicateCheckerPlugin } from './default/DuplicateCheckerPlugin';

export class EventPluginManager {
public static run(context:EventPluginContext, callback:(context?:EventPluginContext) => void): void {
Expand Down Expand Up @@ -43,6 +44,7 @@ export class EventPluginManager {
public static addDefaultPlugins(config:Configuration): void {
config.addPlugin(new ConfigurationDefaultsPlugin());
config.addPlugin(new ErrorPlugin());
config.addPlugin(new DuplicateCheckerPlugin());
config.addPlugin(new ModuleInfoPlugin());
config.addPlugin(new RequestInfoPlugin());
config.addPlugin(new EnvironmentInfoPlugin());
Expand Down
82 changes: 82 additions & 0 deletions src/plugins/default/DuplicateCheckerPlugin-spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import { ContextData } from '../ContextData';
import { EventPluginContext } from '../EventPluginContext';
import { DuplicateCheckerPlugin } from './DuplicateCheckerPlugin';
import { ErrorPlugin } from './ErrorPlugin';
import { createFixture } from './EventPluginTestFixture';

describe('DuplicateCheckerPlugin', () => {

let target: DuplicateCheckerPlugin;
let now: number;

beforeEach(() => {
target = new DuplicateCheckerPlugin();
(<any>target).getNow = () => now;
now = 0;
});

function run(exception: Error) {
let context: EventPluginContext;
let contextData: ContextData;
({
context,
contextData
} = createFixture());

contextData.setException(exception);

let errorPlugin = new ErrorPlugin();
errorPlugin.run(context);
target.run(context);

return context;
}

it('should ignore duplicate within window', () => {
let exception = createException([{
name: 'methodA'
}]);
run(exception);
let contextOfSecondRun = run(exception);
expect(contextOfSecondRun.cancelled).toBeTruthy();
});

it('shouldn\'t ignore error without stack', () => {
let exception = createException();
run(exception);
let contextOfSecondRun = run(exception);
expect(contextOfSecondRun.cancelled).toBeFalsy();
});

it('shouldn\'t ignore different stack within window', () => {
let exception1 = createException([{
name: 'methodA'
}]);
run(exception1);
let exception2 = createException([{
name: 'methodB'
}]);
let contextOfSecondRun = run(exception2);
expect(contextOfSecondRun.cancelled).toBeFalsy();
});

it('shouldn\'t ignore duplicate after window', () => {
let exception = createException([{
name: 'methodA'
}]);
run(exception);

now = 3000;
let contextOfSecondRun = run(exception);
expect(contextOfSecondRun.cancelled).toBeFalsy();
});
});

function createException(stack?) {
try {
throw new Error();
} catch (e) {
e.testStack = stack;
return e;
}
}
Loading