Anaconda OpenTelemetry for Typescript
    Preparing search index...

    Function traceBlock

    • Executes a block of code (async) within a tracing context, optionally attaching attributes and a carrier.

      Parameters

      • args: TraceArgs

        An argument list object where the name field is required.

        The args is an object defined by (in any order):

        {
        name: string = ""; Required; Not supplying a name will result in no value being recorded.
        attributes?: AttrMap = {}; Optional; Attributes for the counter metric.
        carrier?: CarrierMap = {}; Optional; Used to create a context for the trace block.
        }
      • block: (aspan: ASpan) => void

      Returns void

      • If tracing is not initialized, a warning is logged and the block is executed with a no-op span.
      • IMPORTANT: Calling reinitializeTelemetry from within a traceBlock will result in an exception (Error) being thrown!
      • This call should be awaited and the code block will be async.
      await traceBlock({name: "myTraceBlock", attributes: { key: "value" }}) { aspan =>
      aspan.addAttributes({ additional: "attributes" });
      // do some async code here with awaits...

      aspan.addEvent("eventName", { "attr": "value" });

      // do some more code with awaits...

      aspan.addException(new Error("An error occurred"));
      aspan.setErrorStatus("An error occurred");

      // finish the code block
      })