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-465] collect client service, env and version #392

Merged
merged 7 commits into from
May 18, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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
21 changes: 17 additions & 4 deletions packages/core/src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ export interface UserConfiguration {
internalMonitoringEndpoint?: string
logsEndpoint?: string
rumEndpoint?: string

clientService?: string
clientEnv?: string
clientVersion?: string
mquentin marked this conversation as resolved.
Show resolved Hide resolved
mquentin marked this conversation as resolved.
Show resolved Hide resolved
}

export type Configuration = typeof DEFAULT_CONFIGURATION & {
Expand All @@ -63,19 +67,26 @@ export type Configuration = typeof DEFAULT_CONFIGURATION & {
interface TransportConfiguration {
clientToken: string
datacenter: Datacenter
env: Environment
sdkEnv: Environment
buildMode: BuildMode
sdkVersion: string
proxyHost?: string

clientService?: string
clientEnv?: string
clientVersion?: string
}

export function buildConfiguration(userConfiguration: UserConfiguration, buildEnv: BuildEnv): Configuration {
const transportConfiguration: TransportConfiguration = {
buildMode: buildEnv.buildMode,
clientEnv: userConfiguration.clientEnv,
clientService: userConfiguration.clientService,
clientToken: userConfiguration.clientToken,
clientVersion: userConfiguration.clientVersion,
datacenter: userConfiguration.datacenter || buildEnv.datacenter,
env: buildEnv.env,
proxyHost: userConfiguration.proxyHost,
sdkEnv: buildEnv.sdkEnv,
mquentin marked this conversation as resolved.
Show resolved Hide resolved
sdkVersion: buildEnv.sdkVersion,
}

Expand Down Expand Up @@ -129,8 +140,10 @@ export function buildConfiguration(userConfiguration: UserConfiguration, buildEn

function getEndpoint(type: string, conf: TransportConfiguration, source?: string) {
const tld = conf.datacenter === 'us' ? 'com' : 'eu'
const domain = conf.env === 'production' ? `datadoghq.${tld}` : `datad0g.${tld}`
const tags = `sdk_version:${conf.sdkVersion}`
const domain = conf.sdkEnv === 'production' ? `datadoghq.${tld}` : `datad0g.${tld}`
const tags = `sdk_version:${conf.sdkVersion}${conf.clientEnv ? `,env:${conf.clientEnv}` : ''}${
conf.clientService ? `,service:${conf.clientService}` : ''
}${conf.clientVersion ? `,version:${conf.clientVersion}` : ''}`
mquentin marked this conversation as resolved.
Show resolved Hide resolved
const datadogHost = `${type}-http-intake.logs.${domain}`
const host = conf.proxyHost ? conf.proxyHost : datadogHost
const proxyParameter = conf.proxyHost ? `ddhost=${datadogHost}&` : ''
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export type BuildMode = 'release' | 'staging' | 'e2e-test'

export interface BuildEnv {
datacenter: Datacenter
env: Environment
sdkEnv: Environment
buildMode: BuildMode
sdkVersion: string
}
Expand Down
2 changes: 1 addition & 1 deletion packages/logs/src/buildEnv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import { BuildEnv, Datacenter, Environment } from '@datadog/browser-core'
export const buildEnv: BuildEnv = {
buildMode: '<<< BUILD_MODE >>>' as BuildEnv['buildMode'],
datacenter: '<<< TARGET_DATACENTER >>>' as Datacenter,
env: '<<< TARGET_ENV >>>' as Environment,
sdkEnv: '<<< TARGET_ENV >>>' as Environment,
sdkVersion: '<<< SDK_VERSION >>>',
}
2 changes: 1 addition & 1 deletion packages/rum/src/buildEnv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import { BuildEnv } from '@datadog/browser-core'
export const buildEnv: BuildEnv = {
buildMode: '<<< BUILD_MODE >>>' as BuildEnv['buildMode'],
datacenter: '<<< TARGET_DATACENTER >>>' as BuildEnv['datacenter'],
env: '<<< TARGET_ENV >>>' as BuildEnv['env'],
sdkEnv: '<<< TARGET_ENV >>>' as BuildEnv['sdkEnv'],
sdkVersion: '<<< SDK_VERSION >>>',
}