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

# OpenTelemetry instrumentation attributes

AppSignal supports multiple OpenTelemetry language integrations. However, the data model may not always align perfectly, which can affect how OpenTelemetry data is displayed in the AppSignal interface. By using the attributes listed on this page, you can customize the appearance of trace and span data.

<Warning>
  🔐 Do not send <strong>Personal Identifiable Information (PII)</strong> to AppSignal. Filter PII (e.g., names, emails) and use an ID, hash, or pseudonymized identifier instead. <br /> <br /> For <strong>HIPAA-covered entities</strong>, more info on signing a Business Associate Agreement (BAA) is available in our <a href="/support/business-add-ons">Business Add-Ons documentation</a>.
</Warning>

## Accessing a span

<Tabs>
  <Tab title="Python">
    When customizing the trace or span, first import the OpenTelemetry trace module in the file you want to customize the reported trace data.

    <CodeGroup>
      ```python Python theme={null}
      from opentelemetry import trace
      ```
    </CodeGroup>

    Using that trace module, create a new span:

    <CodeGroup>
      ```python Python theme={null}
      tracer = trace.get_tracer(__name__)
      with tracer.start_as_current_span("Span name") as span:
          # Set attribute values
          span.set_attribute("attribute name", "attribute value")
      ```
    </CodeGroup>

    Or fetch the current active one:

    <CodeGroup>
      ```python Python theme={null}
      span = trace.get_current_span()
      # Set attribute values
      span.set_attribute("attribute name", "attribute value")
      ```
    </CodeGroup>
  </Tab>

  <Tab title="Go (golang)">
    When customizing the trace or span, first import the OpenTelemetry trace module in the file you want to customize the reported trace data.

    <CodeGroup>
      ```go Go theme={null}
      import (
      	"go.opentelemetry.io/otel"
      	"go.opentelemetry.io/otel/attribute"
      	"go.opentelemetry.io/otel/trace"
      )
      ```
    </CodeGroup>

    Using that trace module, create a new span:

    <CodeGroup>
      ```go Go theme={null}
      var tracer = otel.Tracer("my-tracer-name")

      func httpHandler(w http.ResponseWriter, r *http.Request) {
      	ctx, span := tracer.Start(r.Context(), "hello-span")
      	defer span.End()

      	// Set attributes
      }
      ```
    </CodeGroup>

    *Note: In these examples we're relying on the context from the HTTP request, given by `r.Context()`.*
    *Receiving the context may be different in your application.*

    Or fetch the current active one:

    <CodeGroup>
      ```go Go theme={null}
      func httpHandler(w http.ResponseWriter, r *http.Request) {
      	ctx := r.Context()
          span := trace.SpanFromContext(ctx)

      	// Set attributes
      }
      ```
    </CodeGroup>
  </Tab>
</Tabs>

## AppSignal attributes

### Namespace

<Tip>
  This attribute applies to the entire trace. It can be set on a child span, and does not need to be set on the uppermost parent span. This attribute can only be set once per trace. If it is set multiple times, only the attribute from one span in the trace is applied.
</Tip>

* Attribute name: `appsignal.namespace`
* Value type: `String`

[Group traces by namespace](/application/namespaces) for better organization in the AppSignal interface.

Namespaces are grouped per OpenTelemetry service name with the format `<Service name>/<Namespace>`, e.g. "Web server/admin" or "Background worker/billing". This attribute allows you to configure the namespace part only. The default namespace for all traces is `<Service name>/default`.

<CodeGroup>
  ```python Python theme={null}
  span.set_attribute("appsignal.namespace", "admin")
  ```

  ```go Go theme={null}
  span.SetAttributes(attribute.String("appsignal.namespace", "admin"))
  ```
</CodeGroup>

### Root action name

<Tip>
  This attribute applies to the entire trace. It can be set on a child span, and does not need to be set on the uppermost parent span. This attribute can only be set once per trace. If it is set multiple times, only the attribute from one span in the trace is applied.
</Tip>

* Attribute name: `appsignal.action_name`
* Value type: `String`

Set the action name of the trace that will be used to create incidents and group tracing on AppSignal.com. This will overwrite any automated mapping done by the AppSignal support for specific instrumentation. It is useful for traces that are not created by supported libraries. If your trace is grouped with other not named or poorly grouped traces, it may be missing this attribute.

We aim to improve our automatic grouping over time, so [please let us know](mailto:support@appsignal.com?subject=OpenTelemetry%20feedback) when you find that this attribute is needed.

<CodeGroup>
  ```python Python theme={null}
  span.set_attribute("appsignal.action_name", "ControllerName#action")
  ```

  ```go Go theme={null}
  span.SetAttributes(attribute.String("appsignal.action_name", "ControllerName#action"))
  ```
</CodeGroup>

### Tags

* Attribute name: `appsignal.tag.<tag_name>`
* Value type: `String`

[Tag traces](/application/tagging) to bring them to the front on the trace detail pages and filter traces in the AppSignal interface. Multiple tags can be set on spans in a trace. Tags can be added to any span in a trace on any level on the trace.

You can use [link templates](https://docs.appsignal.com/application/link-templates.html) to link tags to a specific URL, such as a user profile or admin page.

The tag attribute key is built up out of two parts, the `appsignal.tag` prefix, and the tag key. For the tag `user_id`, this becomes `appsignal.tag.user_id` as an attribute key.

<CodeGroup>
  ```python Python theme={null}
  span.set_attribute("appsignal.tag.<tag_name>", "string") # Example format
  span.set_attribute("appsignal.tag.user_id", user.id)
  ```

  ```go Go theme={null}
  span.SetAttributes(attribute.String("appsignal.tag.<tag_name>", "string")) // Example format
  span.SetAttributes(attribute.String("appsignal.tag.user_id", user.id))
  ```
</CodeGroup>

### Function parameters

<Tip>
  This attribute's value needs to be serialized to a JSON string. It does not support a Hash or object from the integration language directly and will be silently ignored.
</Tip>

* Attribute name: `appsignal.function.parameters`
* Value type: JSON serialized object

Report the parameters for a function call using this attribute.
Use this to set parameters given to a background job, a task or function call you'd like to track.

The values set in this span attribute can be filtered using the [`appsignal.config.filter_function_parameters` config option](/opentelemetry/configuration/options#filter-function-parameters).

<CodeGroup>
  ```python Python theme={null}
  span.set_attribute("appsignal.function.parameters", json.dumps({
      "param1": "value1",
      "param2": "value2"
  }))
  ```

  ```go Go theme={null}
  import (
  	"encoding/json"
  )

  params := map[string]interface{}{
  	"param1": "value1",
  	"param2": "value2",
  	"nested": map[string]interface{}{
  		"param3": "value3",
  		"param4": "value4",
  	},
  }
  json, _ := json.Marshal(params)
  span.SetAttributes(attribute.String("appsignal.function.parameters", string(json)))
  ```
</CodeGroup>

### Response headers

<Tip>
  This attribute's value needs to be serialized to a JSON string. It does not support a Hash or object from the integration language directly and will be silently ignored.
</Tip>

* Attribute name: `http.response.header.<key>`
* Value type: Array of Strings

Report the response's headers using an OpenTelemetry span attribute.
This span attribute is also documented on the [OpenTelemetry HTTP span specification](https://opentelemetry.io/docs/specs/semconv/http/http-spans/).

<CodeGroup>
  ```python Python theme={null}
  span.set_attribute("http.response.header.content-type", ["application/json"])
  span.set_attribute("http.response.header.custom-header", ["abc", "def"])
  ```

  ```go Go theme={null}
  span.SetAttributes(attribute.StringSlice("http.response.header.content-type", []string{"application/json"}))
  span.SetAttributes(attribute.StringSlice("http.response.header.custom-header", []string{"abc", "def"}))
  ```
</CodeGroup>

### Request headers

<Tip>
  This attribute's value needs to be serialized to a JSON string. It does not support a Hash or object from the integration language directly and will be silently ignored.
</Tip>

* Attribute name: `http.request.header.<key>`
* Value type: Array of Strings

Report the request's headers using an OpenTelemetry span attribute.
This span attribute is also documented on the [OpenTelemetry HTTP span specification](https://opentelemetry.io/docs/specs/semconv/http/http-spans/).

<CodeGroup>
  ```python Python theme={null}
  span.set_attribute("http.request.header.content-type", ["application/json"])
  span.set_attribute("http.request.header.custom-header", ["abc", "def"])
  ```

  ```go Go theme={null}
  span.SetAttributes(attribute.StringSlice("http.request.header.content-type", []string{"application/json"}))
  span.SetAttributes(attribute.StringSlice("http.request.header.custom-header"), []string{"abc", "def"})
  ```
</CodeGroup>

### Request query parameters

<Tip>
  This attribute's value needs to be serialized to a JSON string. It does not support a Hash or object from the integration language directly and will be silently ignored.
</Tip>

* Attribute name: `appsignal.request.query_parameters`
* Value type: JSON serialized object

Report an incoming HTTP request's query parameters using this attribute.

The values set in this span attribute can be filtered using the [`appsignal.config.filter_request_query_parameters` config option](/opentelemetry/configuration/options#filter-request-query-parameters).

<CodeGroup>
  ```python Python theme={null}
  span.set_attribute("appsignal.request.query_parameters", json.dumps({
      "category": "shoes",
      "filter": "color:blue"
  }))
  ```

  ```go Go theme={null}
  import (
  	"encoding/json"

  	"go.opentelemetry.io/otel/attribute"
  	"go.opentelemetry.io/otel/trace"
  )

  params := map[string]interface{}{
  	"param1": "value1",
  	"param2": "value2",
  	"nested": map[string]interface{}{
  		"param3": "value3",
  		"param4": "value4",
  	},
  }
  json, _ := json.Marshal(params)
  span.SetAttributes(attribute.String("appsignal.request.query_parameters", string(json)))
  ```
</CodeGroup>

### Request payload

<Tip>
  This attribute's value needs to be serialized to a JSON string. It does not support a Hash or object from the integration language directly and will be silently ignored.
</Tip>

* Attribute name: `appsignal.request.payload`
* Value type: JSON serialized object

Report an incoming HTTP request's payload using this attribute.

The values set in this span attribute can be filtered using the [`appsignal.config.filter_request_payload` config option](/opentelemetry/configuration/options#filter-request-payload).

<CodeGroup>
  ```python Python theme={null}
  span.set_attribute("appsignal.request.payload", json.dumps({
      "title": "My new blog post"
      "body": "Lorem ipsum"
  }))
  ```

  ```go Go theme={null}
  import (
  	"encoding/json"

  	"go.opentelemetry.io/otel/attribute"
  	"go.opentelemetry.io/otel/trace"
  )

  payload := map[string]interface{}{
  	"param1": "value1",
  	"param2": "value2",
  	"nested": map[string]interface{}{
  		"param3": "value3",
  		"param4": "value4",
  	},
  }
  json, _ := json.Marshal(payload)
  span.SetAttributes(attribute.String("appsignal.request.payload", string(json)))
  ```
</CodeGroup>

### Request session data

<Tip>
  This attribute's value needs to be serialized to a JSON string. It does not support a Hash or object from the integration language directly and will be silently ignored.
</Tip>

* Attribute name: `appsignal.request.session_data`
* Value type: JSON serialized object

Report an incoming HTTP request's session data using this attribute.

The values set in this span attribute can be filtered using the [`appsignal.config.filter_request_session_data` config option](/opentelemetry/configuration/options#filter-request-session-data).

<CodeGroup>
  ```python Python theme={null}
  span.set_attribute("appsignal.request.session_data", json.dumps({
      "user_id": 123
      "theme": "dark"
  }))
  ```

  ```go Go theme={null}
  import (
  	"encoding/json"

  	"go.opentelemetry.io/otel/attribute"
  	"go.opentelemetry.io/otel/trace"
  )

  session_data := map[string]interface{}{
  	"param1": "value1",
  	"param2": "value2",
  	"nested": map[string]interface{}{
  		"param3": "value3",
  		"param4": "value4",
  	},
  }
  json, _ := json.Marshal(session_data)
  span.SetAttributes(attribute.String("appsignal.request.session_data", string(json)))
  ```
</CodeGroup>
