---
title: "Attributes"
description: "Attributes automatically enrich your telemetry with typed key-value data. Use them to add business context that you can filter and search in Sentry."
url: https://docs.sentry.io/platforms/javascript/guides/aws-lambda/enriching-events/attributes/
---

# Attributes | Sentry for AWS Lambda

Available since: `v10.61.0`

**Attributes** are key-value pairs you can attach to your telemetry (like [spans](https://docs.sentry.io/platforms/javascript/guides/aws-lambda/tracing/instrumentation.md), [logs](https://docs.sentry.io/platforms/javascript/guides/aws-lambda/logs.md), and [metrics](https://docs.sentry.io/platforms/javascript/guides/aws-lambda/metrics.md)). Unlike [tags](https://docs.sentry.io/platforms/javascript/guides/aws-lambda/enriching-events/tags.md), which only accept `string` values, attributes support `string`, `number` and `boolean` values.

Common uses include subscription tier, feature flags, or any business context that helps you filter and query your telemetry. Check out [Sending Span Metrics](https://docs.sentry.io/platforms/javascript/guides/aws-lambda/tracing/span-metrics.md) for an example of how to use attributes to enrich your spans.

Setting attributes will bind them to the [isolation scope](https://docs.sentry.io/platforms/javascript/guides/aws-lambda/enriching-events/scopes.md#isolation-scope). This ensures they'll automatically be included on future telemetry for the current request or page view:

```javascript
Sentry.setAttribute("is_admin", true);

Sentry.setAttributes({
  "user.num_orders": user.numOrders,
  "subscription.tier": "pro",
});
```

To attach attributes to a broader or narrower context, you can set them on a specific scope instead. Use the global scope for attributes that should appear on all telemetry across the entire application, and `withScope` for a single operation only:

```javascript
// Applied to everything across the entire application
Sentry.getGlobalScope().setAttributes({
  "app.version": "1.2.3",
});

// Applied to a single operation only
Sentry.withScope((scope) => {
  scope.setAttribute("checkout.step", "payment");
  Sentry.logger.info("Processing payment");
});
```

Learn more about how scope data is applied to events in [Scopes](https://docs.sentry.io/platforms/javascript/guides/aws-lambda/enriching-events/scopes.md).

## [Setting Attributes on Individual Telemetry](https://docs.sentry.io/platforms/javascript/guides/aws-lambda/enriching-events/attributes.md#setting-attributes-on-individual-telemetry)

The scope APIs above are the easiest way to enrich everything at once. But you can also attach attributes to a single span, log, or metric directly. Useful when the data only makes sense for that one item.

### [Spans](https://docs.sentry.io/platforms/javascript/guides/aws-lambda/enriching-events/attributes.md#spans)

Add attributes to the currently active span with `setAttribute` or `setAttributes`. See [Sending Span Metrics](https://docs.sentry.io/platforms/javascript/guides/aws-lambda/tracing/span-metrics.md) for more.

```javascript
const span = Sentry.getActiveSpan();
if (span) {
  span.setAttributes({
    "checkout.step": "payment",
    "cart.item_count": 3,
  });
}
```

### [Logs](https://docs.sentry.io/platforms/javascript/guides/aws-lambda/enriching-events/attributes.md#logs)

Pass attributes as the second argument to any `Sentry.logger` call. See [Logs](https://docs.sentry.io/platforms/javascript/guides/aws-lambda/logs.md) for more.

```javascript
Sentry.logger.info("Order created", {
  "order.id": order.id,
  "subscription.tier": "pro",
});
```

### [Metrics](https://docs.sentry.io/platforms/javascript/guides/aws-lambda/enriching-events/attributes.md#metrics)

Pass attributes in the `attributes` option of any metric. See [Metrics](https://docs.sentry.io/platforms/javascript/guides/aws-lambda/metrics.md) for more.

```javascript
Sentry.metrics.count("orders_created", 1, {
  attributes: {
    "subscription.tier": "pro",
    region: "us-west",
  },
});
```
