Creates a new attribute container that provides an efficient, observable key-value storage for OpenTelemetry attributes with support for inheritance, limits, and change notifications.

The container supports inherited attributes from parent containers or plain objects, enforces attribute count and value size limits, and provides efficient iteration and access patterns.

The OpenTelemetry configuration containing trace configuration and limits

Optional name for the container (used in the container ID)

Optional parent attributes or container to inherit from

Optional specific attribute limits to override configuration defaults

A new IAttributeContainer instance with the specified configuration

3.4.0

const config = { traceCfg: { generalLimits: { attributeCountLimit: 64 } } };
const container = createAttributeContainer(config, "my-container");
container.set("service.name", "my-service");

// With inheritance
const parent = { "environment": "production" };
const child = createAttributeContainer(config, "child-container", parent);
console.log(child.get("environment")); // "production"
  • Creates a new attribute container with only configuration.

    Type Parameters

    Parameters

    • otelCfg: IOTelConfig

      The OpenTelemetry configuration containing trace configuration and limits

    Returns IAttributeContainer<V>

    A new IAttributeContainer instance with auto-generated container ID

    3.4.0

    const config = { traceCfg: { generalLimits: { attributeCountLimit: 64 } } };
    const container = createAttributeContainer(config);
    console.log(container.id); // ".0" (auto-generated)
  • Creates a new attribute container with configuration and a name.

    Type Parameters

    Parameters

    • otelCfg: IOTelConfig

      The OpenTelemetry configuration containing trace configuration and limits

    • name: string

      The name for the container (used in the container ID)

    Returns IAttributeContainer<V>

    A new IAttributeContainer instance with the specified name

    3.4.0

    const config = { traceCfg: { generalLimits: { attributeCountLimit: 64 } } };
    const container = createAttributeContainer(config, "my-container");
    console.log(container.id); // "my-container.0"
    container.set("service.name", "my-service");
  • Creates a new attribute container with configuration, name, and inheritance.

    Type Parameters

    Parameters

    Returns IAttributeContainer<V>

    A new IAttributeContainer instance that inherits from the specified parent

    3.4.0

    const config = { traceCfg: { generalLimits: { attributeCountLimit: 64 } } };
    const parent = { "environment": "production", "region": "us-east-1" };
    const child = createAttributeContainer(config, "child-container", parent);
    console.log(child.get("environment")); // "production" (inherited)
    child.set("service.name", "my-service"); // local attribute
  • Creates a new attribute container with full configuration options.

    Type Parameters

    Parameters

    Returns IAttributeContainer<V>

    A new IAttributeContainer instance with custom limits and inheritance

    3.4.0

    const config = { traceCfg: { generalLimits: { attributeCountLimit: 64 } } };
    const parent = { "environment": "production" };
    const customLimits = { attributeCountLimit: 32, attributeValueLengthLimit: 256 };
    const container = createAttributeContainer(config, "limited-container", parent, customLimits);
    // This container has stricter limits than the default configuration