Skip to content

Commit 5aafc56

Browse files
lramos15Copilot
andauthored
Add more telemtry for auto (#1714)
* Add more telemtry for auto * Update src/extension/byok/node/openAIEndpoint.ts Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]>
1 parent 7ce9f74 commit 5aafc56

File tree

8 files changed

+46
-14
lines changed

8 files changed

+46
-14
lines changed

src/extension/byok/node/openAIEndpoint.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,18 @@ function hydrateBYOKErrorMessages(response: ChatResponse): ChatResponse {
4343
return response;
4444
}
4545

46+
/**
47+
* Checks to see if a given endpoint is a BYOK model.
48+
* @param endpoint The endpoint to check if it's a BYOK model
49+
* @returns 1 if client side byok, 2 if server side byok, -1 if not a byok model
50+
*/
51+
export function isBYOKModel(endpoint: IChatEndpoint | undefined): number {
52+
if (!endpoint) {
53+
return -1;
54+
}
55+
return endpoint instanceof OpenAIEndpoint ? 1 : (endpoint.customModel ? 2 : -1);
56+
}
57+
4658
export class OpenAIEndpoint extends ChatEndpoint {
4759
// Reserved headers that cannot be overridden for security and functionality reasons
4860
// Including forbidden request headers: https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_request_header

src/extension/conversation/vscode-node/languageModelAccess.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import { EmbeddingType, getWellKnownEmbeddingTypeInfo, IEmbeddingsComputer } fro
1515
import { IEndpointProvider } from '../../../platform/endpoint/common/endpointProvider';
1616
import { CustomDataPartMimeTypes } from '../../../platform/endpoint/common/endpointTypes';
1717
import { encodeStatefulMarker } from '../../../platform/endpoint/common/statefulMarkerContainer';
18-
import { AutoChatEndpoint } from '../../../platform/endpoint/vscode-node/autoChatEndpoint';
19-
import { IAutomodeService } from '../../../platform/endpoint/vscode-node/automodeService';
18+
import { AutoChatEndpoint } from '../../../platform/endpoint/node/autoChatEndpoint';
19+
import { IAutomodeService } from '../../../platform/endpoint/node/automodeService';
2020
import { IEnvService, isScenarioAutomation } from '../../../platform/env/common/envService';
2121
import { IVSCodeExtensionContext } from '../../../platform/extContext/common/extensionContext';
2222
import { ILogService } from '../../../platform/log/common/logService';

src/extension/extension/vscode-node/services.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ import { DiffServiceImpl } from '../../../platform/diff/node/diffServiceImpl';
2121
import { ICAPIClientService } from '../../../platform/endpoint/common/capiClient';
2222
import { IDomainService } from '../../../platform/endpoint/common/domainService';
2323
import { IEndpointProvider } from '../../../platform/endpoint/common/endpointProvider';
24+
import { AutomodeService, IAutomodeService } from '../../../platform/endpoint/node/automodeService';
2425
import { CAPIClientImpl } from '../../../platform/endpoint/node/capiClientImpl';
2526
import { DomainService } from '../../../platform/endpoint/node/domainServiceImpl';
26-
import { AutomodeService, IAutomodeService } from '../../../platform/endpoint/vscode-node/automodeService';
2727
import { INativeEnvService, isScenarioAutomation } from '../../../platform/env/common/envService';
2828
import { NativeEnvServiceImpl } from '../../../platform/env/vscode-node/nativeEnvServiceImpl';
2929
import { IGitCommitMessageService } from '../../../platform/git/common/gitCommitMessageService';

src/extension/prompt/node/chatMLFetcher.ts

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { ChatFetchError, ChatFetchResponseType, ChatFetchRetriableError, ChatLoc
1010
import { IConversationOptions } from '../../../platform/chat/common/conversationOptions';
1111
import { getTextPart, toTextParts } from '../../../platform/chat/common/globalStringUtils';
1212
import { HARD_TOOL_LIMIT } from '../../../platform/configuration/common/configurationService';
13+
import { isAutoModel } from '../../../platform/endpoint/node/autoChatEndpoint';
1314
import { ILogService } from '../../../platform/log/common/logService';
1415
import { OptionalChatRequestParams } from '../../../platform/networking/common/fetch';
1516
import { IFetcherService } from '../../../platform/networking/common/fetcherService';
@@ -25,7 +26,7 @@ import { isCancellationError } from '../../../util/vs/base/common/errors';
2526
import { Emitter } from '../../../util/vs/base/common/event';
2627
import { generateUuid } from '../../../util/vs/base/common/uuid';
2728
import { IInstantiationService } from '../../../util/vs/platform/instantiation/common/instantiation';
28-
import { OpenAIEndpoint } from '../../byok/node/openAIEndpoint';
29+
import { isBYOKModel } from '../../byok/node/openAIEndpoint';
2930
import { EXTENSION_ID } from '../../common/constants';
3031

3132
export interface IMadeChatRequestEvent {
@@ -250,7 +251,8 @@ export class ChatMLFetcherImpl extends AbstractChatMLFetcher {
250251
timeToFirstTokenEmitted: (baseTelemetry && streamRecorder.firstTokenEmittedTime) ? streamRecorder.firstTokenEmittedTime - baseTelemetry.issuedTime : -1,
251252
timeToCancelled: baseTelemetry ? Date.now() - baseTelemetry.issuedTime : -1,
252253
isVisionRequest: this.filterImageMessages(messages) ? 1 : -1,
253-
isBYOK: chatEndpoint instanceof OpenAIEndpoint ? 1 : (chatEndpoint.customModel ? 2 : -1)
254+
isBYOK: isBYOKModel(chatEndpoint),
255+
isAuto: isAutoModel(chatEndpoint)
254256
});
255257
pendingLoggedChatRequest?.resolveWithCancelation();
256258
return this.processCanceledResponse(response, ourRequestId);
@@ -305,7 +307,8 @@ export class ChatMLFetcherImpl extends AbstractChatMLFetcher {
305307
timeToFirstToken: undefined,
306308
timeToCancelled: timeToError,
307309
isVisionRequest: this.filterImageMessages(messages) ? 1 : -1,
308-
isBYOK: chatEndpoint instanceof OpenAIEndpoint ? 1 : (chatEndpoint.customModel ? 2 : -1)
310+
isBYOK: isBYOKModel(chatEndpoint),
311+
isAuto: isAutoModel(chatEndpoint)
309312
});
310313
} else {
311314
this._sendResponseErrorTelemetry(processed, telemetryProperties, ourRequestId, chatEndpoint, requestBody, tokenCount, maxResponseTokens, timeToError, this.filterImageMessages(messages));
@@ -337,7 +340,8 @@ export class ChatMLFetcherImpl extends AbstractChatMLFetcher {
337340
timeToFirstTokenEmitted,
338341
timeToCancelled,
339342
isVisionRequest,
340-
isBYOK
343+
isBYOK,
344+
isAuto
341345
}: {
342346
totalTokenMax: number;
343347
promptTokenCount: number;
@@ -347,6 +351,7 @@ export class ChatMLFetcherImpl extends AbstractChatMLFetcher {
347351
timeToCancelled: number;
348352
isVisionRequest: number;
349353
isBYOK: number;
354+
isAuto: number;
350355
}
351356
) {
352357
/* __GDPR__
@@ -366,6 +371,7 @@ export class ChatMLFetcherImpl extends AbstractChatMLFetcher {
366371
"timeToCancelled": { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth", "comment": "Time to first token", "isMeasurement": true },
367372
"isVisionRequest": { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth", "comment": "Whether the request was for a vision model", "isMeasurement": true },
368373
"isBYOK": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "Whether the request was for a BYOK model", "isMeasurement": true },
374+
"isAuto": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "Whether the request was for an Auto model", "isMeasurement": true },
369375
"retryAfterErrorCategory": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "If the response failed and this is a retry attempt, this contains the error category." },
370376
"retryAfterFilterCategory": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "If the response was filtered and this is a retry attempt, this contains the original filtered content category." }
371377
}
@@ -384,7 +390,8 @@ export class ChatMLFetcherImpl extends AbstractChatMLFetcher {
384390
timeToFirstTokenEmitted,
385391
timeToCancelled,
386392
isVisionRequest,
387-
isBYOK
393+
isBYOK,
394+
isAuto
388395
});
389396
}
390397

@@ -419,6 +426,7 @@ export class ChatMLFetcherImpl extends AbstractChatMLFetcher {
419426
"timeToFirstTokenEmitted": { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth", "comment": "Time to first token emitted (visible text)", "isMeasurement": true },
420427
"isVisionRequest": { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth", "comment": "Whether the request was for a vision model", "isMeasurement": true },
421428
"isBYOK": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "Whether the request was for a BYOK model", "isMeasurement": true },
429+
"isAuto": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "Whether the request was for an Auto model", "isMeasurement": true },
422430
"retryAfterErrorCategory": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "If the response failed and this is a retry attempt, this contains the error category." },
423431
"retryAfterFilterCategory": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "If the response was filtered and this is a retry attempt, this contains the original filtered content category." }
424432
}
@@ -441,7 +449,8 @@ export class ChatMLFetcherImpl extends AbstractChatMLFetcher {
441449
tokenCountMax: maxResponseTokens,
442450
timeToFirstToken,
443451
isVisionRequest: isVisionRequest ? 1 : -1,
444-
isBYOK: chatEndpointInfo instanceof OpenAIEndpoint ? 1 : (chatEndpointInfo.customModel ? 2 : -1)
452+
isBYOK: isBYOKModel(chatEndpointInfo),
453+
isAuto: isAutoModel(chatEndpointInfo)
445454
});
446455
}
447456

@@ -471,6 +480,7 @@ export class ChatMLFetcherImpl extends AbstractChatMLFetcher {
471480
"source": { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth", "comment": "Source of the initial request" },
472481
"initiatorType": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "Whether the request was initiated by a user or an agent" },
473482
"model": { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth", "comment": "Model selection for the response" },
483+
"modelInvoked": { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth", "comment": "Actual model invoked for the response" },
474484
"apiType": { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth", "comment": "API type for the response- chat completions or responses" },
475485
"requestId": { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth", "comment": "Id of the current turn request" },
476486
"associatedRequestId": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "Another request ID that this request is associated with (eg, the originating request of a summarization request)." },
@@ -491,6 +501,7 @@ export class ChatMLFetcherImpl extends AbstractChatMLFetcher {
491501
"timeToComplete": { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth", "comment": "Time to complete the request", "isMeasurement": true },
492502
"isVisionRequest": { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth", "comment": "Whether the request was for a vision model", "isMeasurement": true },
493503
"isBYOK": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "Whether the request was for a BYOK model", "isMeasurement": true },
504+
"isAuto": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "Whether the request was for an Auto model", "isMeasurement": true },
494505
"retryAfterErrorCategory": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "If the response failed and this is a retry attempt, this contains the error category." },
495506
"retryAfterFilterCategory": { "classification": "SystemMetaData", "purpose": "FeatureInsight", "comment": "If the response was filtered and this is a retry attempt, this contains the original filtered content category." }
496507
}
@@ -501,6 +512,7 @@ export class ChatMLFetcherImpl extends AbstractChatMLFetcher {
501512
source: baseTelemetry?.properties.messageSource ?? 'unknown',
502513
initiatorType: userInitiatedRequest ? 'user' : 'agent',
503514
model: chatEndpointInfo?.model,
515+
modelInvoked: chatCompletion.model,
504516
apiType: chatEndpointInfo?.apiType,
505517
requestId,
506518
associatedRequestId: baseTelemetry?.properties.associatedRequestId,
@@ -523,7 +535,8 @@ export class ChatMLFetcherImpl extends AbstractChatMLFetcher {
523535
timeToFirstTokenEmitted: (baseTelemetry && streamRecorder.firstTokenEmittedTime) ? streamRecorder.firstTokenEmittedTime - baseTelemetry.issuedTime : -1,
524536
timeToComplete: baseTelemetry ? Date.now() - baseTelemetry.issuedTime : -1,
525537
isVisionRequest: this.filterImageMessages(messages) ? 1 : -1,
526-
isBYOK: chatEndpointInfo instanceof OpenAIEndpoint ? 1 : (chatEndpointInfo?.customModel ? 2 : -1)
538+
isBYOK: isBYOKModel(chatEndpointInfo),
539+
isAuto: isAutoModel(chatEndpointInfo)
527540
});
528541
if (!this.isRepetitive(chatCompletion, baseTelemetry?.properties)) {
529542
completions.push(chatCompletion);

src/extension/prompt/vscode-node/endpointProviderImpl.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ import { IAuthenticationService } from '../../../platform/authentication/common/
88
import { ConfigKey, IConfigurationService } from '../../../platform/configuration/common/configurationService';
99
import { ICAPIClientService } from '../../../platform/endpoint/common/capiClient';
1010
import { ChatEndpointFamily, EmbeddingsEndpointFamily, IChatModelInformation, ICompletionModelInformation, IEmbeddingModelInformation, IEndpointProvider } from '../../../platform/endpoint/common/endpointProvider';
11+
import { AutoChatEndpoint } from '../../../platform/endpoint/node/autoChatEndpoint';
12+
import { IAutomodeService } from '../../../platform/endpoint/node/automodeService';
1113
import { CopilotChatEndpoint } from '../../../platform/endpoint/node/copilotChatEndpoint';
1214
import { EmbeddingEndpoint } from '../../../platform/endpoint/node/embeddingsEndpoint';
1315
import { IModelMetadataFetcher, ModelMetadataFetcher } from '../../../platform/endpoint/node/modelMetadataFetcher';
1416
import { applyExperimentModifications, ExperimentConfig, getCustomDefaultModelExperimentConfig, ProxyExperimentEndpoint } from '../../../platform/endpoint/node/proxyExperimentEndpoint';
15-
import { AutoChatEndpoint } from '../../../platform/endpoint/vscode-node/autoChatEndpoint';
16-
import { IAutomodeService } from '../../../platform/endpoint/vscode-node/automodeService';
1717
import { ExtensionContributedChatEndpoint } from '../../../platform/endpoint/vscode-node/extChatEndpoint';
1818
import { IEnvService } from '../../../platform/env/common/envService';
1919
import { ILogService } from '../../../platform/log/common/logService';

src/extension/test/vscode-node/services.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ import { RemoteEmbeddingsComputer } from '../../../platform/embeddings/common/re
2323
import { ICAPIClientService } from '../../../platform/endpoint/common/capiClient';
2424
import { IDomainService } from '../../../platform/endpoint/common/domainService';
2525
import { IEndpointProvider } from '../../../platform/endpoint/common/endpointProvider';
26+
import { AutomodeService, IAutomodeService } from '../../../platform/endpoint/node/automodeService';
2627
import { CAPIClientImpl } from '../../../platform/endpoint/node/capiClientImpl';
2728
import { DomainService } from '../../../platform/endpoint/node/domainServiceImpl';
2829
import { TestEndpointProvider } from '../../../platform/endpoint/test/node/testEndpointProvider';
29-
import { AutomodeService, IAutomodeService } from '../../../platform/endpoint/vscode-node/automodeService';
3030
import { IEnvService } from '../../../platform/env/common/envService';
3131
import { EnvServiceImpl } from '../../../platform/env/vscode/envServiceImpl';
3232
import { IVSCodeExtensionContext } from '../../../platform/extContext/common/extensionContext';

src/platform/endpoint/vscode-node/autoChatEndpoint.ts renamed to src/platform/endpoint/node/autoChatEndpoint.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { ITokenizerProvider } from '../../tokenizer/node/tokenizer';
1616
import { ICAPIClientService } from '../common/capiClient';
1717
import { IDomainService } from '../common/domainService';
1818
import { IChatModelInformation } from '../common/endpointProvider';
19-
import { ChatEndpoint } from '../node/chatEndpoint';
19+
import { ChatEndpoint } from './chatEndpoint';
2020

2121
/**
2222
* This endpoint represents the "Auto" model in the model picker.
@@ -111,4 +111,11 @@ function calculateAutoModelInfo(endpoint: IChatEndpoint, sessionToken: string, d
111111
}
112112
};
113113
return newModelInfo;
114+
}
115+
116+
export function isAutoModel(endpoint: IChatEndpoint | undefined): number {
117+
if (!endpoint) {
118+
return -1;
119+
}
120+
return endpoint.model === AutoChatEndpoint.pseudoModelId || (endpoint instanceof AutoChatEndpoint) ? 1 : -1;
114121
}

0 commit comments

Comments
 (0)