Respan Parameters

Understanding Respan-specific span parameters for filtering and metadata

Overview

Respan Parameters are special attributes you can attach to spans for enhanced filtering, grouping, and metadata in the Respan dashboard.

Parameters

customer_identifier

Identifies the customer or user associated with the trace. Useful for filtering traces by customer.

1await respanAi.withWorkflow(
2 { name: 'user_request' },
3 async () => {
4 const client = respanAi.getClient();
5
6 client.updateCurrentSpan({
7 respan_params: {
8 customer_identifier: 'user-123'
9 }
10 });
11
12 return await processUserRequest();
13 }
14);

trace_group_identifier

Groups related traces together. Useful for organizing traces by feature, team, or project.

1await respanAi.withWorkflow(
2 { name: 'order_processing' },
3 async () => {
4 const client = respanAi.getClient();
5
6 client.updateCurrentSpan({
7 respan_params: {
8 trace_group_identifier: 'ecommerce-orders'
9 }
10 });
11
12 return await processOrder();
13 }
14);

metadata

Arbitrary key-value pairs for additional context. Useful for business-specific information.

1await respanAi.withWorkflow(
2 { name: 'api_request' },
3 async () => {
4 const client = respanAi.getClient();
5
6 client.updateCurrentSpan({
7 respan_params: {
8 metadata: {
9 order_id: 'ORDER-789',
10 payment_method: 'credit_card',
11 shipping_country: 'US',
12 cart_total: 99.99,
13 is_premium_user: true
14 }
15 }
16 });
17
18 return await processApiRequest();
19 }
20);

Complete Example

1import { RespanTelemetry } from '@respan/tracing';
2
3const respanAi = new RespanTelemetry({
4 apiKey: process.env.RESPAN_API_KEY,
5 appName: 'ecommerce-api'
6});
7
8await respanAi.initialize();
9
10await respanAi.withWorkflow(
11 {
12 name: 'checkout_workflow',
13 associationProperties: {
14 'workflow_version': '2.0'
15 }
16 },
17 async () => {
18 const client = respanAi.getClient();
19
20 client.updateCurrentSpan({
21 respan_params: {
22 customer_identifier: 'customer-abc123',
23 trace_group_identifier: 'checkout',
24 metadata: {
25 cart_id: 'CART-456',
26 items_count: 3,
27 subtotal: 89.97,
28 tax: 7.20,
29 total: 97.17,
30 payment_method: 'visa',
31 shipping_method: 'express',
32 promo_code: 'SAVE10',
33 is_first_purchase: false
34 }
35 }
36 });
37
38 // Process checkout
39 await validateCart();
40 await processPayment();
41 await createOrder();
42
43 return 'checkout_complete';
44 }
45);
46
47await respanAi.shutdown();

Use Cases

Customer Support

Filter traces by customer ID when investigating support tickets:

1client.updateCurrentSpan({
2 respan_params: {
3 customer_identifier: supportTicket.customerId,
4 metadata: {
5 ticket_id: supportTicket.id,
6 issue_type: supportTicket.category,
7 priority: supportTicket.priority
8 }
9 }
10});

Feature Tracking

Group traces by feature for usage analytics:

1client.updateCurrentSpan({
2 respan_params: {
3 trace_group_identifier: 'new-search-feature',
4 metadata: {
5 feature_flag: 'search_v2',
6 ab_test_variant: 'B',
7 feature_enabled_at: new Date().toISOString()
8 }
9 }
10});

Business Metrics

Track business-relevant information:

1client.updateCurrentSpan({
2 respan_params: {
3 customer_identifier: order.customerId,
4 trace_group_identifier: 'orders',
5 metadata: {
6 order_value: order.total,
7 product_category: order.category,
8 revenue_type: 'subscription',
9 conversion_source: 'email_campaign'
10 }
11 }
12});

Multi-Tenant Applications

Identify traces by tenant:

1client.updateCurrentSpan({
2 respan_params: {
3 customer_identifier: tenant.id,
4 trace_group_identifier: `tenant-${tenant.plan}`,
5 metadata: {
6 tenant_name: tenant.name,
7 plan_tier: tenant.plan,
8 region: tenant.region,
9 custom_domain: tenant.domain
10 }
11 }
12});

Association Properties vs Respan Params

FeatureassociationPropertiesrespan_params
Set viaMethod optionsupdateCurrentSpan()
When to setAt span creationDuring span execution
Use caseStatic metadataDynamic runtime metadata
LocationwithWorkflow, withTask, etc.getClient().updateCurrentSpan()

Using Both Together

1await respanAi.withWorkflow(
2 {
3 name: 'user_workflow',
4 associationProperties: {
5 'app_version': '2.1.0',
6 'environment': 'production'
7 }
8 },
9 async () => {
10 const client = respanAi.getClient();
11
12 // Add dynamic runtime metadata
13 client.updateCurrentSpan({
14 respan_params: {
15 customer_identifier: userId,
16 metadata: {
17 action: 'purchase',
18 timestamp: Date.now()
19 }
20 }
21 });
22
23 return await processAction();
24 }
25);

Best Practices

  • Always include customer_identifier for user-specific traces
  • Use trace_group_identifier to organize traces by feature or team
  • Store business-relevant information in metadata
  • Keep metadata values simple (strings, numbers, booleans)
  • Avoid sensitive information (passwords, tokens) in metadata
  • Use consistent naming conventions for metadata keys
  • Update params early in the span lifecycle for complete context