Skip to content
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

[Main][Task]27079894: Add a max retry count for Sender #2324

Merged
merged 7 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
12 changes: 10 additions & 2 deletions AISKU/Tests/Unit/src/SnippetInitialization.Tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,11 @@ export class SnippetInitializationTests extends AITestClass {
if(this.successSpy.called) {
let currentCount: number = 0;
this.successSpy.args.forEach(call => {
call[0].forEach(message => {
call[0].forEach(item => {
let message = item;
if (typeof item !== "string") {
message = item.item;
}
// Ignore the internal SendBrowserInfoOnUserInit message (Only occurs when running tests in a browser)
if (!message || message.indexOf("AI (Internal): 72 ") == -1) {
currentCount ++;
Expand Down Expand Up @@ -1066,7 +1070,11 @@ export class SnippetInitializationTests extends AITestClass {
if(this.successSpy.called) {
let currentCount: number = 0;
this.successSpy.args.forEach(call => {
call[0].forEach(message => {
call[0].forEach(item => {
let message = item.item;
if (typeof item === "string") {
message = item;
}
// Ignore the internal SendBrowserInfoOnUserInit message (Only occurs when running tests in a browser)
if (!message || message.indexOf("AI (Internal): 72 ") == -1) {
currentCount ++;
Expand Down
4 changes: 2 additions & 2 deletions AISKU/Tests/Unit/src/sender.e2e.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { Assert, AITestClass, PollingAssert} from "@microsoft/ai-test-framework"

export class SenderE2ETests extends AITestClass {
private readonly _instrumentationKey = 'b7170927-2d1c-44f1-acec-59f4e1751c11';
private readonly _bufferName = 'AI_buffer';
private readonly _sentBufferName = 'AI_sentBuffer';
private readonly _bufferName = 'AI_buffer_1';
private readonly _sentBufferName = 'AI_sentBuffer_1';

private _ai: IApplicationInsights;
private _sender: Sender;
Expand Down
6 changes: 5 additions & 1 deletion AISKU/Tests/Unit/src/validate.e2e.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,11 @@ export class ValidateE2ETests extends AITestClass {
.concat(() => {
let acceptedItems = 0;
this.successSpy.args.forEach(call => {
call[0].forEach(message => {
call[0].forEach(item => {
let message = item;
if (typeof item !== "string") {
message = item.item;
}
// Ignore the internal SendBrowserInfoOnUserInit message (Only occurs when running tests in a browser)
if (message.indexOf("AI (Internal): 72 ") == -1) {
acceptedItems ++;
Expand Down
364 changes: 301 additions & 63 deletions channels/applicationinsights-channel-js/Tests/Unit/src/Sender.tests.ts

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions channels/applicationinsights-channel-js/src/Interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
import { IStorageBuffer } from "@microsoft/applicationinsights-common";
import { IXHROverride } from "@microsoft/applicationinsights-core-js";

/**
* Internal interface for sendBuffer, do not export it
* @internal
* @since 3.1.3
*/
export interface IInternalStorageItem {
/**
* serialized telemetry to be stored.
*/
item: string;
/**
* total retry count
*/
cnt?: number;
}

export interface ISenderConfig {
/**
* The url to which payloads will be sent
Expand Down Expand Up @@ -141,6 +157,15 @@ export interface ISenderConfig {
* @since 3.1.1
*/
retryCodes?: number[];

/**
* (Optional) The specific max retry count for each telemetry item.
* Default: 10
* if it is set to 0, means no retry allowed
* if it is set to undefined, means no limit for retry times
* @since 3.2.0
*/
maxRetryCnt?: number;
}

export interface IBackendResponse {
Expand Down
Loading
Loading