Signal attributes are custom key-value pairs that are automatically included with every telemetry signal (spans, logs, events) transmitted by the SDK. They provide a way to add contextual information to all telemetry data.
Critical Signal Attribute Behavior:
init() may be queued or lost if SDK initialization failsAdds a signal attribute to be transmitted with every signal.
/**
* Adds a signal attribute to be transmitted with every signal
* @param name - The attribute name
* @param value - The attribute value
* @throws No errors thrown; invalid values may be ignored
*/
function addSignalAttribute(name: string, value: AttributeValueType | AnyValue): void;Usage Examples:
import { addSignalAttribute } from "@dash0/sdk-web";
// Add string attribute
addSignalAttribute("environment", "production");
// Add numeric attribute
addSignalAttribute("version.number", 1.2);
// Add boolean attribute
addSignalAttribute("feature.enabled", true);
// Add array attribute
addSignalAttribute("supported.locales", ["en", "es", "fr"]);
// Add object attribute
addSignalAttribute("config", {
theme: "dark",
notifications: true,
});For IIFE (script tag) usage:
dash0("addSignalAttribute", "environment", "production");
dash0("addSignalAttribute", "version.number", 1.2);Note: If you need to ensure attributes are included with signals transmitted on initial page load, use the additionalSignalAttributes property in the init() call instead:
import { init } from "@dash0/sdk-web";
init({
serviceName: "my-website",
endpoint: { url: "...", authToken: "..." },
additionalSignalAttributes: {
"environment": "production",
"version.number": 1.2,
},
});Critical Behavior:
additionalSignalAttributes in init() are available immediatelyRemoves a previously added signal attribute.
/**
* Removes a previously added signal attribute
* @param name - The attribute name to remove
* @throws No errors thrown; removing non-existent attribute is a no-op
*/
function removeSignalAttribute(name: string): void;Usage Examples:
import { removeSignalAttribute } from "@dash0/sdk-web";
// Remove an attribute
removeSignalAttribute("environment");For IIFE (script tag) usage:
dash0("removeSignalAttribute", "environment");Critical Behavior:
additionalSignalAttributes in init() removes it from all signalstype AttributeValueType =
| string
| number
| boolean
| Array<string | number | boolean>
| Record<string, string | number | boolean>;The SDK also supports the OpenTelemetry AnyValue type for more complex data structures:
interface AnyValue {
stringValue?: string;
boolValue?: boolean;
intValue?: string;
doubleValue?: number;
arrayValue?: { values: AnyValue[] };
kvlistValue?: { values: Array<{ key: string; value: AnyValue }> };
bytesValue?: string;
}Critical Behavior:
AttributeValueType is the simplified type for most use casesAnyValue is the OpenTelemetry-compatible type for complex structuresAttributeValueType must contain only primitive valuesAnyValue supports nested structures and byte arraysTrack which features are enabled for debugging and analytics:
addSignalAttribute("feature.new_checkout", true);
addSignalAttribute("feature.ab_test_variant", "B");Add user-level context (use identify() for standard user attributes):
addSignalAttribute("user.subscription_tier", "premium");
addSignalAttribute("user.account_age_days", 365);Track application-wide state:
addSignalAttribute("app.mode", "demo");
addSignalAttribute("app.locale", "en-US");
addSignalAttribute("app.theme", "dark");Add business-level information:
addSignalAttribute("tenant.id", "acme-corp");
addSignalAttribute("region", "us-west-2");Update attributes as application state changes:
// On user login
addSignalAttribute("auth.status", "authenticated");
// On user logout
removeSignalAttribute("auth.status");
addSignalAttribute("auth.status", "anonymous");session.id, user.id)addSignalAttribute() is called before init(), attributes may be queued or lostinit() is called multiple times, additionalSignalAttributes from the last call are usedWhile not strictly enforced, the following attribute name patterns are used by the SDK:
session.* - Session-related attributesuser.* - User identification attributesevent.* - Event-related attributesurl.* - URL-related attributeshttp.* - HTTP request attributesUsing these patterns may cause conflicts or unexpected behavior.