Hey guys, is this the way to set custom attribute?...
# support
m
Hey guys, is this the way to set custom attribute? And if set, can i see it in the signoz dashboard?
Copy code
export function traceSpan<F extends (...args: any) => ReturnType<F>>(
  name: string,
  func: F,
  message: any,
): ReturnType<F> {
  var singleSpan: Span;
  if (bindingSpan) {
    const ctx = trace.setSpan(context.active(), bindingSpan);
    singleSpan = webTracerWithZone.startSpan(name, undefined, ctx);

    // Set custom attributes
    singleSpan.setAttribute('custom.name', name);
    singleSpan.setAttribute('custom.message', message);

    if (name === 'errorBoundary') {
      singleSpan.setAttribute('custom.errorBoundary', message);
    }

    bindingSpan = undefined;
  } else {
    singleSpan = webTracerWithZone.startSpan(name);

    // Set custom attributes for non-binding spans as well
    singleSpan.setAttribute('custom.name', name);
    singleSpan.setAttribute('custom.message', message);
  }

  return context.with(trace.setSpan(context.active(), singleSpan), () => {
    try {
      const result = func();

      singleSpan.setAttribute('custom.success', true);

      singleSpan.end();
      return result;
    } catch (error) {
      singleSpan.setStatus({ code: SpanStatusCode.ERROR });

      singleSpan.setAttribute('custom.error', error as AttributeValue);
      singleSpan.setAttribute('custom.success', false);

      singleSpan.end();
      throw error;
    }
  });
}
y