Skip to content

Commit

Permalink
Check for clients in auto instrumentation subs (#858)
Browse files Browse the repository at this point in the history
  • Loading branch information
hectorhdzg authored Oct 25, 2021
1 parent 06e25bf commit a4a994f
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 0 deletions.
4 changes: 4 additions & 0 deletions AutoCollection/diagnostic-channel/azure-coretracing.sub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ export const subscriber = (event: IStandardEvent<Span>) => {
export function enable(enabled: boolean, client: TelemetryClient) {
let statsbeat = client.getStatsbeat();
if (enabled) {
let clientFound = clients.find(c => c == client);
if (clientFound) {
return;
}
if (clients.length === 0) {
channel.subscribe<any>("azure-coretracing", subscriber);
if (statsbeat) {
Expand Down
4 changes: 4 additions & 0 deletions AutoCollection/diagnostic-channel/bunyan.sub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ const subscriber = (event: IStandardEvent<bunyan.IBunyanData>) => {
export function enable(enabled: boolean, client: TelemetryClient) {
let statsbeat = client.getStatsbeat();
if (enabled) {
let clientFound = clients.find(c => c == client);
if (clientFound) {
return;
}
if (clients.length === 0) {
channel.subscribe<bunyan.IBunyanData>("bunyan", subscriber);
if (statsbeat) {
Expand Down
4 changes: 4 additions & 0 deletions AutoCollection/diagnostic-channel/console.sub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ const subscriber = (event: IStandardEvent<consolePub.IConsoleData>) => {
export function enable(enabled: boolean, client: TelemetryClient) {
let statsbeat = client.getStatsbeat();
if (enabled) {
let clientFound = clients.find(c => c == client);
if (clientFound) {
return;
}
if (clients.length === 0) {
channel.subscribe<consolePub.IConsoleData>("console", subscriber);
if (statsbeat) {
Expand Down
4 changes: 4 additions & 0 deletions AutoCollection/diagnostic-channel/mongodb.sub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ export const subscriber = (event: IStandardEvent<mongodb.IMongoData>) => {
export function enable(enabled: boolean, client: TelemetryClient) {
let statsbeat = client.getStatsbeat();
if (enabled) {
let clientFound = clients.find(c => c == client);
if (clientFound) {
return;
}
if (clients.length === 0) {
channel.subscribe<mongodb.IMongoData>("mongodb", subscriber);
if (statsbeat) {
Expand Down
4 changes: 4 additions & 0 deletions AutoCollection/diagnostic-channel/mysql.sub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ export const subscriber = (event: IStandardEvent<mysql.IMysqlData>) => {
export function enable(enabled: boolean, client: TelemetryClient) {
let statsbeat = client.getStatsbeat();
if (enabled) {
let clientFound = clients.find(c => c == client);
if (clientFound) {
return;
}
if (clients.length === 0) {
channel.subscribe<mysql.IMysqlData>("mysql", subscriber);
if (statsbeat) {
Expand Down
4 changes: 4 additions & 0 deletions AutoCollection/diagnostic-channel/postgres.sub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ export const subscriber = (event: IStandardEvent<pg.IPostgresData>) => {
export function enable(enabled: boolean, client: TelemetryClient) {
let statsbeat = client.getStatsbeat();
if (enabled) {
let clientFound = clients.find(c => c == client);
if (clientFound) {
return;
}
if (clients.length === 0) {
channel.subscribe<pg.IPostgresData>("postgres", subscriber);
if (statsbeat) {
Expand Down
4 changes: 4 additions & 0 deletions AutoCollection/diagnostic-channel/redis.sub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ export const subscriber = (event: IStandardEvent<redis.IRedisData>) => {
export function enable(enabled: boolean, client: TelemetryClient) {
let statsbeat = client.getStatsbeat();
if (enabled) {
let clientFound = clients.find(c => c == client);
if (clientFound) {
return;
}
if (clients.length === 0) {
channel.subscribe<redis.IRedisData>("redis", subscriber);
if (statsbeat) {
Expand Down
4 changes: 4 additions & 0 deletions AutoCollection/diagnostic-channel/winston.sub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ const subscriber = (event: IStandardEvent<winston.IWinstonData>) => {
export function enable(enabled: boolean, client: TelemetryClient) {
let statsbeat = client.getStatsbeat();
if (enabled) {
let clientFound = clients.find(c => c == client);
if (clientFound) {
return;
}
if (clients.length === 0) {
channel.subscribe<winston.IWinstonData>("winston", subscriber);
if (statsbeat) {
Expand Down

0 comments on commit a4a994f

Please sign in to comment.