> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sedata-ai.tech/llms.txt
> Use this file to discover all available pages before exploring further.

# TelemetryConfig

> The single configuration object for the entire telemetry pipeline.

```ts theme={null}
interface TelemetryConfig {
  serverName: string
  serverVersion: string
  exporterEndpoint?: string
  exporterType?: 'otlp-http' | 'otlp-grpc' | 'console'
  exporterAuth?: AuthConfig
  samplingRate?: number
  metricExportIntervalMs?: number
  batchTimeoutMs?: number
  enableMetrics?: boolean
  enableTracing?: boolean
  enablePIISanitization?: boolean
  enableArgumentCollection?: boolean
  dataProcessors?: ((data: any) => any)[]
}
```

## Required fields

<ParamField path="serverName" type="string" required>
  Maps to the OpenTelemetry `service.name` resource attribute. Use a stable,
  human-readable identifier for your service (`weather-mcp`, not `dev-1`).
</ParamField>

<ParamField path="serverVersion" type="string" required>
  Maps to `service.version`. Recommended: a release tag or git SHA.
</ParamField>

## Exporter

<ParamField path="exporterEndpoint" type="string">
  Base OTLP endpoint, e.g. `https://otel.sedata-ai.tech/v1`. Required unless
  `exporterType: 'console'`. The package appends `/traces` and `/metrics` to
  derive the per-signal URLs.
</ParamField>

<ParamField path="exporterType" type="'otlp-http' | 'otlp-grpc' | 'console'" default="otlp-http">
  Which exporter to use.

  * `otlp-http` — OTLP/HTTP for traces and metrics (default).
  * `otlp-grpc` — OTLP/gRPC trace exporter (metrics still HTTP).
  * `console` — Print spans to stdout. No metric reader is attached.
</ParamField>

<ParamField path="exporterAuth" type="AuthConfig">
  Auth for the exporter. See [`AuthConfig`](/api-reference/types/auth-config).
  Also used to authenticate the safety-check API.
</ParamField>

## Sampling & batching

<ParamField path="samplingRate" type="number" default="1.0">
  Trace sampling ratio in `[0, 1]`. Uses
  `TraceIdRatioBasedSampler` — deterministic by trace id.
</ParamField>

<ParamField path="metricExportIntervalMs" type="number" default="5000">
  Metric flush interval in milliseconds.
</ParamField>

<ParamField path="batchTimeoutMs" type="number" default="2000">
  Per-batch metric export timeout in milliseconds.
</ParamField>

## Toggles

<ParamField path="enableTracing" type="boolean" default="true">
  Set `false` to skip the trace exporter and sampler.
</ParamField>

<ParamField path="enableMetrics" type="boolean" default="true">
  Set `false` to skip the metric reader.
</ParamField>

<ParamField path="enablePIISanitization" type="boolean" default="true">
  Reserved for built-in sanitization patterns. Pair with `dataProcessors` for
  active redaction today.
</ParamField>

<ParamField path="enableArgumentCollection" type="boolean" default="false">
  When `true`, every tool argument is flattened into
  `mcp.request.argument.<key>` span attributes. Off by default to avoid
  inadvertent PII leakage.
</ParamField>

## Custom processing

<ParamField path="dataProcessors" type="((data: any) => any)[]">
  Array of pure functions run on every attribute set before export. Run in
  order. See [Data processors](/guides/data-processors) for patterns.
</ParamField>

## Defaults

```ts theme={null}
const DEFAULT_CONFIG: Partial<TelemetryConfig> = {
  samplingRate: 1.0,
  metricExportIntervalMs: 5000,
  enablePIISanitization: true,
  enableArgumentCollection: false,
  exporterType: 'otlp-http',
  enableMetrics: true,
  enableTracing: true,
  batchTimeoutMs: 2000,
  dataProcessors: [],
}
```

## Example

```ts theme={null}
import type { TelemetryConfig } from '@sedata-ai/mcp'

const config: TelemetryConfig = {
  serverName: 'weather-mcp',
  serverVersion: process.env.GIT_SHA ?? '0.0.0-dev',
  exporterEndpoint: 'https://otel.sedata-ai.tech/v1',
  exporterAuth: {
    type: 'bearer',
    token: process.env.SEDATA_TOKEN!,
  },
  samplingRate: 0.25,
  metricExportIntervalMs: 10_000,
  enableArgumentCollection: false,
  dataProcessors: [
    (data) => ({ ...data, 'deployment.env': process.env.DEPLOY_ENV ?? 'dev' }),
  ],
}
```

## Validation

`ConfigValidator.validate(config)` enforces the rules above. See the
[validator reference](/api-reference/config-validator) for the exact error
messages.
