Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
261f0f1c
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
261f0f1c
编写于
6月 07, 2016
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
wip: telemetry service in shared process
上级
1f74e3c5
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
130 addition
and
44 deletion
+130
-44
src/bootstrap.js
src/bootstrap.js
+3
-3
src/vs/base/parts/ai/node/ai.app.ts
src/vs/base/parts/ai/node/ai.app.ts
+3
-3
src/vs/code/node/sharedProcessMain.ts
src/vs/code/node/sharedProcessMain.ts
+47
-7
src/vs/platform/environment/common/environment.ts
src/vs/platform/environment/common/environment.ts
+1
-0
src/vs/platform/environment/node/environmentService.ts
src/vs/platform/environment/node/environmentService.ts
+5
-0
src/vs/platform/telemetry/common/telemetryIpc.ts
src/vs/platform/telemetry/common/telemetryIpc.ts
+42
-0
src/vs/platform/telemetry/node/aiAdapter.ts
src/vs/platform/telemetry/node/aiAdapter.ts
+25
-27
src/vs/platform/telemetry/test/node/aiAdapter.test.ts
src/vs/platform/telemetry/test/node/aiAdapter.test.ts
+4
-4
未找到文件。
src/bootstrap.js
浏览文件 @
261f0f1c
...
@@ -97,9 +97,9 @@ var writable = new stream.Writable({
...
@@ -97,9 +97,9 @@ var writable = new stream.Writable({
write
:
function
()
{
/* No OP */
}
write
:
function
()
{
/* No OP */
}
});
});
process
.
__defineGetter__
(
'
stdout
'
,
function
()
{
return
writable
;
});
//
process.__defineGetter__('stdout', function() { return writable; });
process
.
__defineGetter__
(
'
stderr
'
,
function
()
{
return
writable
;
});
//
process.__defineGetter__('stderr', function() { return writable; });
process
.
__defineGetter__
(
'
stdin
'
,
function
()
{
return
writable
;
});
//
process.__defineGetter__('stdin', function() { return writable; });
// Handle uncaught exceptions
// Handle uncaught exceptions
process
.
on
(
'
uncaughtException
'
,
function
(
err
)
{
process
.
on
(
'
uncaughtException
'
,
function
(
err
)
{
...
...
src/vs/base/parts/ai/node/ai.app.ts
浏览文件 @
261f0f1c
...
@@ -7,10 +7,10 @@
...
@@ -7,10 +7,10 @@
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IServer
}
from
'
vs/base/parts/ipc/common/ipc
'
;
import
{
IServer
}
from
'
vs/base/parts/ipc/common/ipc
'
;
import
{
A
IAdapter
}
from
'
.
/aiAdapter
'
;
import
{
A
ppInsightsAppender
}
from
'
vs/platform/telemetry/node
/aiAdapter
'
;
import
{
IAIChannel
}
from
'
./ai.ipc
'
;
import
{
IAIChannel
}
from
'
./ai.ipc
'
;
const
adapter
:
{
[
handle
:
number
]:
A
IAdapt
er
}
=
Object
.
create
(
null
);
const
adapter
:
{
[
handle
:
number
]:
A
ppInsightsAppend
er
}
=
Object
.
create
(
null
);
let
idPool
=
0
;
let
idPool
=
0
;
export
function
registerAIChannel
(
server
:
IServer
)
{
export
function
registerAIChannel
(
server
:
IServer
)
{
...
@@ -20,7 +20,7 @@ export function registerAIChannel(server: IServer) {
...
@@ -20,7 +20,7 @@ export function registerAIChannel(server: IServer) {
case
'
create
'
:
{
case
'
create
'
:
{
let
handle
=
idPool
++
;
let
handle
=
idPool
++
;
let
{
key
,
eventPrefix
,
data
}
=
arg
;
let
{
key
,
eventPrefix
,
data
}
=
arg
;
adapter
[
handle
]
=
new
A
IAdapt
er
(
eventPrefix
,
data
,
key
);
adapter
[
handle
]
=
new
A
ppInsightsAppend
er
(
eventPrefix
,
data
,
key
);
return
TPromise
.
as
(
handle
);
return
TPromise
.
as
(
handle
);
}
}
case
'
log
'
:
{
case
'
log
'
:
{
...
...
src/vs/code/node/sharedProcessMain.ts
浏览文件 @
261f0f1c
...
@@ -19,6 +19,11 @@ import { ExtensionManagementChannel } from 'vs/platform/extensionManagement/comm
...
@@ -19,6 +19,11 @@ import { ExtensionManagementChannel } from 'vs/platform/extensionManagement/comm
import
{
IExtensionManagementService
}
from
'
vs/platform/extensionManagement/common/extensionManagement
'
;
import
{
IExtensionManagementService
}
from
'
vs/platform/extensionManagement/common/extensionManagement
'
;
import
{
ExtensionManagementService
}
from
'
vs/platform/extensionManagement/node/extensionManagementService
'
;
import
{
ExtensionManagementService
}
from
'
vs/platform/extensionManagement/node/extensionManagementService
'
;
import
product
from
'
vs/platform/product
'
;
import
{
ITelemetryAppender
,
combinedAppender
,
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
TelemetryService
,
ITelemetryServiceConfig
}
from
'
vs/platform/telemetry/common/telemetryService
'
;
import
{
AppInsightsAppender
}
from
'
vs/platform/telemetry/node/aiAdapter
'
;
function
quit
(
err
?:
Error
)
{
function
quit
(
err
?:
Error
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
err
);
console
.
error
(
err
);
...
@@ -40,6 +45,23 @@ function setupPlanB(parentPid: number): void {
...
@@ -40,6 +45,23 @@ function setupPlanB(parentPid: number): void {
},
5000
);
},
5000
);
}
}
const
eventPrefix
=
'
monacoworkbench
'
;
function
createAppender
():
ITelemetryAppender
{
const
result
:
ITelemetryAppender
[]
=
[];
const
{
key
,
asimovKey
}
=
product
.
aiConfig
;
if
(
key
)
{
result
.
push
(
new
AppInsightsAppender
(
eventPrefix
,
null
,
key
));
}
if
(
asimovKey
)
{
result
.
push
(
new
AppInsightsAppender
(
eventPrefix
,
null
,
asimovKey
));
}
return
combinedAppender
(...
result
);
}
function
main
(
server
:
Server
):
void
{
function
main
(
server
:
Server
):
void
{
const
services
=
new
ServiceCollection
();
const
services
=
new
ServiceCollection
();
...
@@ -50,13 +72,31 @@ function main(server: Server): void {
...
@@ -50,13 +72,31 @@ function main(server: Server): void {
const
instantiationService
=
new
InstantiationService
(
services
);
const
instantiationService
=
new
InstantiationService
(
services
);
instantiationService
.
invokeFunction
(
accessor
=>
{
instantiationService
.
invokeFunction
(
accessor
=>
{
const
extensionManagementService
=
accessor
.
get
(
IExtensionManagementService
);
const
{
appRoot
,
extensionsPath
}
=
accessor
.
get
(
IEnvironmentService
);
const
channel
=
new
ExtensionManagementChannel
(
extensionManagementService
);
server
.
registerChannel
(
'
extensions
'
,
channel
);
const
appender
=
createAppender
();
registerAIChannel
(
server
);
const
config
:
ITelemetryServiceConfig
=
{
appender
,
// eventually clean up old extensions
commonProperties
:
TPromise
.
as
({}),
//resolveCommonProperties(storageService, contextService),
setTimeout
(()
=>
(
extensionManagementService
as
ExtensionManagementService
).
removeDeprecatedExtensions
(),
5000
);
piiPaths
:
[
appRoot
,
extensionsPath
]
};
const
services
=
new
ServiceCollection
();
services
.
set
(
ITelemetryService
,
new
SyncDescriptor
(
TelemetryService
,
config
));
const
instantiationService2
=
instantiationService
.
createChild
(
services
);
instantiationService2
.
invokeFunction
(
accessor
=>
{
const
telemetryService
=
accessor
.
get
(
ITelemetryService
);
console
.
log
(
telemetryService
);
const
extensionManagementService
=
accessor
.
get
(
IExtensionManagementService
);
const
channel
=
new
ExtensionManagementChannel
(
extensionManagementService
);
server
.
registerChannel
(
'
extensions
'
,
channel
);
registerAIChannel
(
server
);
// eventually clean up old extensions
setTimeout
(()
=>
(
extensionManagementService
as
ExtensionManagementService
).
removeDeprecatedExtensions
(),
5000
);
});
});
});
}
}
...
...
src/vs/platform/environment/common/environment.ts
浏览文件 @
261f0f1c
...
@@ -10,6 +10,7 @@ export const IEnvironmentService = createDecorator<IEnvironmentService>('environ
...
@@ -10,6 +10,7 @@ export const IEnvironmentService = createDecorator<IEnvironmentService>('environ
export
interface
IEnvironmentService
{
export
interface
IEnvironmentService
{
serviceId
:
ServiceIdentifier
<
any
>
;
serviceId
:
ServiceIdentifier
<
any
>
;
appRoot
:
string
;
userDataPath
:
string
;
userDataPath
:
string
;
extensionsPath
:
string
;
extensionsPath
:
string
;
}
}
src/vs/platform/environment/node/environmentService.ts
浏览文件 @
261f0f1c
...
@@ -10,11 +10,15 @@ import pkg from 'vs/platform/package';
...
@@ -10,11 +10,15 @@ import pkg from 'vs/platform/package';
import
*
as
os
from
'
os
'
;
import
*
as
os
from
'
os
'
;
import
*
as
path
from
'
path
'
;
import
*
as
path
from
'
path
'
;
import
{
parseArgs
}
from
'
vs/code/node/argv
'
;
import
{
parseArgs
}
from
'
vs/code/node/argv
'
;
import
URI
from
'
vs/base/common/uri
'
;
export
class
EnvironmentService
implements
IEnvironmentService
{
export
class
EnvironmentService
implements
IEnvironmentService
{
serviceId
=
IEnvironmentService
;
serviceId
=
IEnvironmentService
;
private
_appRoot
:
string
;
get
appRoot
():
string
{
return
this
.
_appRoot
;
}
private
_userDataPath
:
string
;
private
_userDataPath
:
string
;
get
userDataPath
():
string
{
return
this
.
_userDataPath
;
}
get
userDataPath
():
string
{
return
this
.
_userDataPath
;
}
...
@@ -24,6 +28,7 @@ export class EnvironmentService implements IEnvironmentService {
...
@@ -24,6 +28,7 @@ export class EnvironmentService implements IEnvironmentService {
constructor
()
{
constructor
()
{
const
argv
=
parseArgs
(
process
.
argv
);
const
argv
=
parseArgs
(
process
.
argv
);
this
.
_appRoot
=
path
.
dirname
(
URI
.
parse
(
require
.
toUrl
(
''
)).
fsPath
);
this
.
_userDataPath
=
paths
.
getUserDataPath
(
process
.
platform
,
pkg
.
name
,
process
.
argv
);
this
.
_userDataPath
=
paths
.
getUserDataPath
(
process
.
platform
,
pkg
.
name
,
process
.
argv
);
const
userHome
=
path
.
join
(
os
.
homedir
(),
product
.
dataFolderName
);
const
userHome
=
path
.
join
(
os
.
homedir
(),
product
.
dataFolderName
);
...
...
src/vs/platform/telemetry/common/telemetryIpc.ts
0 → 100644
浏览文件 @
261f0f1c
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IChannel
}
from
'
vs/base/parts/ipc/common/ipc
'
;
import
{
ITelemetryAppender
}
from
'
./telemetry
'
;
export
interface
ITelemetryLog
{
eventName
:
string
;
data
?:
any
;
}
export
interface
ITelemetryAppenderChannel
extends
IChannel
{
call
(
command
:
'
log
'
,
data
:
ITelemetryLog
):
TPromise
<
void
>
;
call
(
command
:
string
,
arg
:
any
):
TPromise
<
any
>
;
}
export
class
TelemetryAppenderChannel
implements
ITelemetryAppenderChannel
{
constructor
(
private
appender
:
ITelemetryAppender
)
{
}
call
(
command
:
string
,
{
eventName
,
data
}:
ITelemetryLog
):
TPromise
<
any
>
{
return
this
.
appender
.
log
(
eventName
,
data
);
}
}
export
class
TelemetryAppenderClient
implements
ITelemetryAppender
{
constructor
(
private
channel
:
ITelemetryAppenderChannel
)
{
}
log
(
eventName
:
string
,
data
?:
any
):
any
{
return
this
.
channel
.
call
(
'
log
'
,
{
eventName
,
data
});
}
dispose
():
any
{
// TODO
}
}
\ No newline at end of file
src/vs/
base/parts/ai
/node/aiAdapter.ts
→
src/vs/
platform/telemetry
/node/aiAdapter.ts
浏览文件 @
261f0f1c
...
@@ -8,36 +8,34 @@ import * as appInsights from 'applicationinsights';
...
@@ -8,36 +8,34 @@ import * as appInsights from 'applicationinsights';
import
{
isObject
}
from
'
vs/base/common/types
'
;
import
{
isObject
}
from
'
vs/base/common/types
'
;
import
{
safeStringify
,
mixin
}
from
'
vs/base/common/objects
'
;
import
{
safeStringify
,
mixin
}
from
'
vs/base/common/objects
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
ITelemetryAppender
}
from
'
../common/telemetry
'
;
namespace
AI
{
let
_initialized
=
false
;
let
_initialized
=
false
;
function
ensureAIEngineIsInitialized
():
void
{
if
(
_initialized
===
false
)
{
// we need to pass some fake key, otherwise AI throws an exception
appInsights
.
setup
(
'
2588e01f-f6c9-4cd6-a348-143741f8d702
'
)
.
setAutoCollectConsole
(
false
)
.
setAutoCollectExceptions
(
false
)
.
setAutoCollectPerformance
(
false
)
.
setAutoCollectRequests
(
false
);
function
ensureAIEngineIsInitialized
():
void
{
_initialized
=
true
;
if
(
_initialized
===
false
)
{
// we need to pass some fake key, otherwise AI throws an exception
appInsights
.
setup
(
'
2588e01f-f6c9-4cd6-a348-143741f8d702
'
)
.
setAutoCollectConsole
(
false
)
.
setAutoCollectExceptions
(
false
)
.
setAutoCollectPerformance
(
false
)
.
setAutoCollectRequests
(
false
);
_initialized
=
true
;
}
}
}
}
export
function
getClient
(
aiKey
:
string
):
typeof
appInsights
.
client
{
function
getClient
(
aiKey
:
string
):
typeof
appInsights
.
client
{
ensureAIEngineIsInitialized
();
ensureAIEngineIsInitialized
();
const
client
=
appInsights
.
getClient
(
aiKey
);
const
client
=
appInsights
.
getClient
(
aiKey
);
client
.
channel
.
setOfflineMode
(
true
);
client
.
channel
.
setOfflineMode
(
true
);
client
.
context
.
tags
[
client
.
context
.
keys
.
deviceMachineName
]
=
''
;
//prevent App Insights from reporting machine name
client
.
context
.
tags
[
client
.
context
.
keys
.
deviceMachineName
]
=
''
;
//prevent App Insights from reporting machine name
if
(
aiKey
.
indexOf
(
'
AIF-
'
)
===
0
)
{
if
(
aiKey
.
indexOf
(
'
AIF-
'
)
===
0
)
{
client
.
config
.
endpointUrl
=
'
https://vortex.data.microsoft.com/collect/v1
'
;
client
.
config
.
endpointUrl
=
'
https://vortex.data.microsoft.com/collect/v1
'
;
}
return
client
;
}
}
return
client
;
}
}
interface
Properties
{
interface
Properties
{
...
@@ -48,7 +46,7 @@ interface Measurements {
...
@@ -48,7 +46,7 @@ interface Measurements {
[
key
:
string
]:
number
;
[
key
:
string
]:
number
;
}
}
export
class
A
IAdapt
er
{
export
class
A
ppInsightsAppender
implements
ITelemetryAppend
er
{
private
_aiClient
:
typeof
appInsights
.
client
;
private
_aiClient
:
typeof
appInsights
.
client
;
...
@@ -62,7 +60,7 @@ export class AIAdapter {
...
@@ -62,7 +60,7 @@ export class AIAdapter {
}
}
if
(
typeof
aiKeyOrClientFactory
===
'
string
'
)
{
if
(
typeof
aiKeyOrClientFactory
===
'
string
'
)
{
this
.
_aiClient
=
AI
.
getClient
(
aiKeyOrClientFactory
);
this
.
_aiClient
=
getClient
(
aiKeyOrClientFactory
);
}
else
if
(
typeof
aiKeyOrClientFactory
===
'
function
'
)
{
}
else
if
(
typeof
aiKeyOrClientFactory
===
'
function
'
)
{
this
.
_aiClient
=
aiKeyOrClientFactory
();
this
.
_aiClient
=
aiKeyOrClientFactory
();
}
}
...
@@ -74,7 +72,7 @@ export class AIAdapter {
...
@@ -74,7 +72,7 @@ export class AIAdapter {
const
measurements
:
Measurements
=
Object
.
create
(
null
);
const
measurements
:
Measurements
=
Object
.
create
(
null
);
const
flat
=
Object
.
create
(
null
);
const
flat
=
Object
.
create
(
null
);
A
IAdapt
er
.
_flaten
(
data
,
flat
);
A
ppInsightsAppend
er
.
_flaten
(
data
,
flat
);
for
(
let
prop
in
flat
)
{
for
(
let
prop
in
flat
)
{
// enforce property names less than 150 char, take the last 150 char
// enforce property names less than 150 char, take the last 150 char
...
@@ -120,7 +118,7 @@ export class AIAdapter {
...
@@ -120,7 +118,7 @@ export class AIAdapter {
}
else
if
(
isObject
(
value
))
{
}
else
if
(
isObject
(
value
))
{
if
(
order
<
2
)
{
if
(
order
<
2
)
{
A
IAdapt
er
.
_flaten
(
value
,
result
,
order
+
1
,
index
+
'
.
'
);
A
ppInsightsAppend
er
.
_flaten
(
value
,
result
,
order
+
1
,
index
+
'
.
'
);
}
else
{
}
else
{
result
[
index
]
=
safeStringify
(
value
);
result
[
index
]
=
safeStringify
(
value
);
}
}
...
@@ -135,7 +133,7 @@ export class AIAdapter {
...
@@ -135,7 +133,7 @@ export class AIAdapter {
return
;
return
;
}
}
data
=
mixin
(
data
,
this
.
_defaultData
);
data
=
mixin
(
data
,
this
.
_defaultData
);
let
{
properties
,
measurements
}
=
A
IAdapt
er
.
_getData
(
data
);
let
{
properties
,
measurements
}
=
A
ppInsightsAppend
er
.
_getData
(
data
);
this
.
_aiClient
.
trackEvent
(
this
.
_eventPrefix
+
'
/
'
+
eventName
,
properties
,
measurements
);
this
.
_aiClient
.
trackEvent
(
this
.
_eventPrefix
+
'
/
'
+
eventName
,
properties
,
measurements
);
}
}
...
...
src/vs/
base/test/node/aiAdapter
/aiAdapter.test.ts
→
src/vs/
platform/telemetry/test/node
/aiAdapter.test.ts
浏览文件 @
261f0f1c
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
'
use strict
'
;
'
use strict
'
;
import
*
as
assert
from
'
assert
'
;
import
*
as
assert
from
'
assert
'
;
import
{
A
IAdapter
}
from
'
vs/base/parts/ai
/node/aiAdapter
'
;
import
{
A
ppInsightsAppender
}
from
'
vs/platform/telemetry
/node/aiAdapter
'
;
interface
IAppInsightsEvent
{
interface
IAppInsightsEvent
{
eventName
:
string
;
eventName
:
string
;
...
@@ -41,12 +41,12 @@ class AppInsightsMock {
...
@@ -41,12 +41,12 @@ class AppInsightsMock {
suite
(
'
AIAdapter
'
,
()
=>
{
suite
(
'
AIAdapter
'
,
()
=>
{
var
appInsightsMock
:
AppInsightsMock
;
var
appInsightsMock
:
AppInsightsMock
;
var
adapter
:
A
IAdapt
er
;
var
adapter
:
A
ppInsightsAppend
er
;
var
prefix
=
'
prefix
'
;
var
prefix
=
'
prefix
'
;
setup
(()
=>
{
setup
(()
=>
{
appInsightsMock
=
new
AppInsightsMock
();
appInsightsMock
=
new
AppInsightsMock
();
adapter
=
new
A
IAdapt
er
(
prefix
,
undefined
,
()
=>
appInsightsMock
);
adapter
=
new
A
ppInsightsAppend
er
(
prefix
,
undefined
,
()
=>
appInsightsMock
);
});
});
teardown
(()
=>
{
teardown
(()
=>
{
...
@@ -61,7 +61,7 @@ suite('AIAdapter', () => {
...
@@ -61,7 +61,7 @@ suite('AIAdapter', () => {
});
});
test
(
'
addional data
'
,
()
=>
{
test
(
'
addional data
'
,
()
=>
{
adapter
=
new
A
IAdapt
er
(
prefix
,
{
first
:
'
1st
'
,
second
:
2
,
third
:
true
},
()
=>
appInsightsMock
);
adapter
=
new
A
ppInsightsAppend
er
(
prefix
,
{
first
:
'
1st
'
,
second
:
2
,
third
:
true
},
()
=>
appInsightsMock
);
adapter
.
log
(
'
testEvent
'
);
adapter
.
log
(
'
testEvent
'
);
assert
.
equal
(
appInsightsMock
.
events
.
length
,
1
);
assert
.
equal
(
appInsightsMock
.
events
.
length
,
1
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录