fix(syncing-server): add option to define otel ratio
This commit is contained in:
parent
783fd9e2c6
commit
c021bb3d7c
2 changed files with 9 additions and 2 deletions
|
@ -17,7 +17,10 @@ import { ExpressInstrumentation } from '@opentelemetry/instrumentation-express'
|
|||
export class OpenTelemetrySDK implements OpenTelemetrySDKInterface {
|
||||
private declare sdk: OpenTelemetrySDKNode.NodeSDK
|
||||
|
||||
constructor(private serviceName: string) {
|
||||
constructor(
|
||||
private serviceName: string,
|
||||
private spanRatio?: number,
|
||||
) {
|
||||
this.build()
|
||||
}
|
||||
|
||||
|
@ -41,8 +44,10 @@ export class OpenTelemetrySDK implements OpenTelemetrySDKInterface {
|
|||
},
|
||||
})
|
||||
|
||||
const ratio = this.spanRatio ?? 0.01
|
||||
|
||||
this.sdk = new OpenTelemetrySDKNode.NodeSDK({
|
||||
sampler: new OpenTelemetrySDKNode.tracing.TraceIdRatioBasedSampler(0.01),
|
||||
sampler: new OpenTelemetrySDKNode.tracing.TraceIdRatioBasedSampler(ratio),
|
||||
textMapPropagator: new AWSXRayPropagator(),
|
||||
instrumentations: [
|
||||
new HttpInstrumentation({
|
||||
|
|
|
@ -237,6 +237,7 @@ export class ContainerConfigLoader {
|
|||
const isConfiguredForHomeServerOrSelfHosting = isConfiguredForHomeServer || isConfiguredForSelfHosting
|
||||
const isSecondaryDatabaseEnabled = env.get('SECONDARY_DB_ENABLED', true) === 'true'
|
||||
const isConfiguredForInMemoryCache = env.get('CACHE_TYPE', true) === 'memory'
|
||||
const openTelemetryRatio = env.get('OTEL_SPAN_RATIO', true) ? +env.get('OTEL_SPAN_RATIO', true) : 0.01
|
||||
|
||||
container
|
||||
.bind<boolean>(TYPES.Sync_IS_CONFIGURED_FOR_HOME_SERVER_OR_SELF_HOSTING)
|
||||
|
@ -250,6 +251,7 @@ export class ContainerConfigLoader {
|
|||
this.mode === 'server'
|
||||
? ServiceIdentifier.NAMES.SyncingServer
|
||||
: ServiceIdentifier.NAMES.SyncingServerWorker,
|
||||
openTelemetryRatio,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue