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

♻️ [RUMF-1190] cleanup telemetry #1560

Merged
merged 8 commits into from
May 24, 2022
Merged
Show file tree
Hide file tree
Changes from 5 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
2 changes: 1 addition & 1 deletion packages/core/src/boot/init.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { setDebugMode } from '../domain/internalMonitoring'
import { setDebugMode } from '../domain/telemetry'
import { catchUserErrors } from '../tools/catchUserErrors'
import { assign } from '../tools/utils'

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/browser/fetchObservable.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { monitor, callMonitored } from '../domain/internalMonitoring'
import { monitor, callMonitored } from '../domain/telemetry'
import { instrumentMethod } from '../tools/instrumentMethod'
import { Observable } from '../tools/observable'
import type { Duration, ClocksState } from '../tools/timeUtils'
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/browser/xhrObservable.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { monitor } from '../domain/internalMonitoring'
import { monitor } from '../domain/telemetry'
import { instrumentMethodAndCallOriginal } from '../tools/instrumentMethod'
import { Observable } from '../tools/observable'
import type { Duration, RelativeTime, ClocksState } from '../tools/timeUtils'
Expand Down
5 changes: 2 additions & 3 deletions packages/core/src/domain/configuration/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export interface InitConfiguration {

// internal options
enableExperimentalFeatures?: string[] | undefined
internalMonitoringApiKey?: string | undefined
replica?: ReplicaUserConfiguration | undefined
datacenter?: string
}
Expand All @@ -63,7 +62,7 @@ export interface Configuration extends TransportConfiguration {

// Event limits
eventRateLimiterThreshold: number // Limit the maximum number of actions, errors and logs per minutes
maxInternalMonitoringMessagesPerPage: number
maxTelemetryEventsPerPage: number

// Batch configuration
batchBytesLimit: number
Expand Down Expand Up @@ -108,7 +107,7 @@ export function validateAndBuildConfiguration(initConfiguration: InitConfigurati
batchBytesLimit: isExperimentalFeatureEnabled('lower-batch-size') ? 10 * ONE_KILO_BYTE : 16 * ONE_KILO_BYTE,

eventRateLimiterThreshold: 3000,
maxInternalMonitoringMessagesPerPage: 15,
maxTelemetryEventsPerPage: 15,

/**
* flush automatically, aim to be lower than ALB connection timeout
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/domain/configuration/endpointBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { timeStampNow } from '../../tools/timeUtils'
import { normalizeUrl } from '../../tools/urlPolyfill'
import { generateUUID } from '../../tools/utils'
import type { InitConfiguration } from './configuration'
import { INTAKE_SITE_US } from './intakeSites'
import { INTAKE_SITE_US1 } from './intakeSites'

// replaced at build time
declare const __BUILD_ENV__SDK_VERSION__: string
Expand All @@ -29,7 +29,7 @@ export function createEndpointBuilder(
tags: string[],
source?: string
) {
const { site = INTAKE_SITE_US, clientToken } = initConfiguration
const { site = INTAKE_SITE_US1, clientToken } = initConfiguration

const domainParts = site.split('.')
const extension = domainParts.pop()
Expand Down
6 changes: 2 additions & 4 deletions packages/core/src/domain/configuration/intakeSites.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
export const INTAKE_SITE_STAGING = 'datad0g.com'
export const INTAKE_SITE_US = 'datadoghq.com'
export const INTAKE_SITE_US3 = 'us3.datadoghq.com'
export const INTAKE_SITE_US5 = 'us5.datadoghq.com'
export const INTAKE_SITE_EU = 'datadoghq.eu'
export const INTAKE_SITE_US1 = 'datadoghq.com'
export const INTAKE_SITE_US1_FED = 'ddog-gov.com'
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,11 @@ import { computeTransportConfiguration } from './transportConfiguration'

describe('transportConfiguration', () => {
const clientToken = 'some_client_token'
const otherClientToken = 'some_other_client_token'

beforeEach(() => {
;(window as unknown as BuildEnvWindow).__BUILD_ENV__SDK_VERSION__ = 'some_version'
})

describe('internal monitoring endpoint', () => {
it('should only be defined when api key is provided', () => {
let configuration = computeTransportConfiguration({ clientToken })
expect(configuration.internalMonitoringEndpointBuilder).toBeUndefined()

configuration = computeTransportConfiguration({ clientToken, internalMonitoringApiKey: otherClientToken })
expect(configuration.internalMonitoringEndpointBuilder?.build()).toContain(otherClientToken)
})
})

describe('site', () => {
it('should use US site by default', () => {
const configuration = computeTransportConfiguration({ clientToken })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ import type { InitConfiguration } from './configuration'
import type { EndpointBuilder } from './endpointBuilder'
import { createEndpointBuilder } from './endpointBuilder'
import { buildTags } from './tags'
import { INTAKE_SITE_US } from './intakeSites'
import { INTAKE_SITE_US1 } from './intakeSites'

export interface TransportConfiguration {
logsEndpointBuilder: EndpointBuilder
rumEndpointBuilder: EndpointBuilder
sessionReplayEndpointBuilder: EndpointBuilder
internalMonitoringEndpointBuilder?: EndpointBuilder
isIntakeUrl: (url: string) => boolean
replica?: ReplicaConfiguration
site: string
Expand All @@ -19,7 +18,6 @@ export interface ReplicaConfiguration {
applicationId?: string
logsEndpointBuilder: EndpointBuilder
rumEndpointBuilder: EndpointBuilder
internalMonitoringEndpointBuilder: EndpointBuilder
}

export function computeTransportConfiguration(initConfiguration: InitConfiguration): TransportConfiguration {
Expand All @@ -34,31 +32,18 @@ export function computeTransportConfiguration(initConfiguration: InitConfigurati
{
isIntakeUrl: (url: string) => intakeEndpoints.some((intakeEndpoint) => url.indexOf(intakeEndpoint) === 0),
replica: replicaConfiguration,
site: initConfiguration.site || INTAKE_SITE_US,
site: initConfiguration.site || INTAKE_SITE_US1,
},
endpointBuilders
)
}

function computeEndpointBuilders(initConfiguration: InitConfiguration, tags: string[]) {
const endpointBuilders = {
return {
logsEndpointBuilder: createEndpointBuilder(initConfiguration, 'logs', tags),
rumEndpointBuilder: createEndpointBuilder(initConfiguration, 'rum', tags),
sessionReplayEndpointBuilder: createEndpointBuilder(initConfiguration, 'sessionReplay', tags),
}

if (initConfiguration.internalMonitoringApiKey) {
return assign(endpointBuilders, {
internalMonitoringEndpointBuilder: createEndpointBuilder(
assign({}, initConfiguration, { clientToken: initConfiguration.internalMonitoringApiKey }),
'logs',
tags,
'browser-agent-internal-monitoring'
bcaudan marked this conversation as resolved.
Show resolved Hide resolved
),
})
}

return endpointBuilders
}

function computeReplicaConfiguration(
Expand All @@ -71,19 +56,13 @@ function computeReplicaConfiguration(
}

const replicaConfiguration: InitConfiguration = assign({}, initConfiguration, {
site: INTAKE_SITE_US,
site: INTAKE_SITE_US1,
clientToken: initConfiguration.replica.clientToken,
})

const replicaEndpointBuilders = {
logsEndpointBuilder: createEndpointBuilder(replicaConfiguration, 'logs', tags),
rumEndpointBuilder: createEndpointBuilder(replicaConfiguration, 'rum', tags),
internalMonitoringEndpointBuilder: createEndpointBuilder(
replicaConfiguration,
'logs',
tags,
'browser-agent-internal-monitoring'
),
}

intakeEndpoints.push(...objectValues(replicaEndpointBuilders).map((builder) => builder.buildIntakeUrl()))
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/domain/console/consoleObservable.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { callMonitored } from '../internalMonitoring'
import { callMonitored } from '../telemetry'
import { computeStackTrace } from '../tracekit'
import { createHandlingStack, formatErrorMessage, toStackTraceString } from '../../tools/error'
import { mergeObservables, Observable } from '../../tools/observable'
Expand Down
15 changes: 0 additions & 15 deletions packages/core/src/domain/internalMonitoring/index.ts

This file was deleted.

Loading