Builder class
Builder for configuring Agent 365 with OpenTelemetry tracing
Methods
| build() | Builds and initializes the Agent 365 configuration |
| shutdown() | Shuts down the OpenTelemetry SDK |
| start() | Starts the OpenTelemetry SDK |
| with |
Configures the cluster category for Agent 365 exporter |
| with |
Configures the configuration provider for ObservabilityConfiguration. When set, this provider is used by the builder and its internal components instead of the default provider that reads from environment variables. |
| with |
Sets a custom logger implementation for the observability SDK |
| with |
Provide a partial set of Agent365ExporterOptions. These will be merged with defaults and any explicitly configured clusterCategory/tokenResolver. |
| with |
Configures the service name and version for telemetry |
| with |
Configures the service namespace for telemetry (service.namespace resource attribute) |
| with |
Configures the token resolver for Agent 365 exporter |
Method Details
build()
Builds and initializes the Agent 365 configuration
function build(): boolean
Returns
boolean
The configured NodeSDK instance
shutdown()
Shuts down the OpenTelemetry SDK
function shutdown(): Promise<void>
Returns
Promise<void>
start()
Starts the OpenTelemetry SDK
function start()
withClusterCategory(ClusterCategory)
Configures the cluster category for Agent 365 exporter
function withClusterCategory(clusterCategory: ClusterCategory): ObservabilityBuilder
Parameters
- clusterCategory
- ClusterCategory
The cluster category (e.g., "preprod", "prod")
Returns
The builder instance for method chaining
withConfigurationProvider(IConfigurationProvider<ObservabilityConfiguration>)
Configures the configuration provider for ObservabilityConfiguration. When set, this provider is used by the builder and its internal components instead of the default provider that reads from environment variables.
function withConfigurationProvider(configProvider: IConfigurationProvider<ObservabilityConfiguration>): ObservabilityBuilder
Parameters
- configProvider
The configuration provider
Returns
The builder instance for method chaining
withCustomLogger(ILogger)
Sets a custom logger implementation for the observability SDK
function withCustomLogger(customLogger: ILogger): ObservabilityBuilder
Parameters
- customLogger
- ILogger
The custom logger implementation (must implement ILogger interface)
Returns
The builder instance for method chaining
Example with Winston:
const winstonLogger = winston.createLogger({...});
builder.withCustomLogger({
info: (msg, ...args) => winstonLogger.info(msg, ...args),
warn: (msg, ...args) => winstonLogger.warn(msg, ...args),
error: (msg, ...args) => winstonLogger.error(msg, ...args)
});
withExporterOptions(Partial<Agent365ExporterOptions>)
Provide a partial set of Agent365ExporterOptions. These will be merged with defaults and any explicitly configured clusterCategory/tokenResolver.
function withExporterOptions(exporterOptions: Partial<Agent365ExporterOptions>): ObservabilityBuilder
Parameters
- exporterOptions
-
Partial<Agent365ExporterOptions>
Partial exporter options
Returns
The builder instance for chaining
withService(string, string)
Configures the service name and version for telemetry
function withService(serviceName: string, serviceVersion?: string): ObservabilityBuilder
Parameters
- serviceName
-
string
The service name
- serviceVersion
-
string
The service version
Returns
The builder instance for method chaining
withServiceNamespace(string)
Configures the service namespace for telemetry (service.namespace resource attribute)
function withServiceNamespace(serviceNamespace: string): ObservabilityBuilder
Parameters
- serviceNamespace
-
string
The service namespace
Returns
The builder instance for method chaining
withTokenResolver(TokenResolver)
Configures the token resolver for Agent 365 exporter
function withTokenResolver(tokenResolver: TokenResolver): ObservabilityBuilder
Parameters
- tokenResolver
-
TokenResolver
Function to resolve authentication tokens
Returns
The builder instance for method chaining