cap-js / telemetry

CDS plugin providing observability features, incl. automatic OpenTelemetry instrumentation.
https://cap.cloud.sap/docs
Apache License 2.0
8 stars 7 forks source link

Trace background processes #192

Closed sebastien-savalle closed 1 month ago

sebastien-savalle commented 4 months ago

Hi,

We have an application using this package to trace incoming requests and to capture some metrics. This works pretty well on BTP with the one agent sdk. We would like to add monitoring for internal scheduled processes. We have added open telemetry span but we are not able to retrieve them in Dynatrace.

Could you help ? Thanks, Sebastien

    const span = tracer.startSpan(taskConfiguration.name, {
      root: true,
      kind: SpanKind.INTERNAL
    });
    try {
      await task.run(taskConfiguration.name, taskConfiguration.config);
      span.setStatus({ code: SpanStatusCode.OK });
    } catch (error) {
      span.recordException(error);
      span.setStatus({ code: SpanStatusCode.ERROR, message: error.message });
    } finally {
      span.end();
    }
sebastien-savalle commented 4 months ago

184

sjvans commented 3 months ago

hi @sebastien-savalle

i'd need a bit more context. what are tracer and task in your code snippet?

for tasks, we offer cds.spawn, which is trace enabled.

best, sebastian

sjvans commented 1 month ago

closing as stale