solarwinds-apm
Version:
OpenTelemetry-based SolarWinds APM library
148 lines (145 loc) • 5.99 kB
JavaScript
/*
Copyright 2023-2025 SolarWinds Worldwide, LLC.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
var _a;
import { inspect } from "node:util";
import { SpanKind, SpanStatusCode, } from "@opentelemetry/api";
import { ExportResultCode, hrTimeToMicroseconds, } from "@opentelemetry/core";
import { ATTR_EXCEPTION_MESSAGE, ATTR_EXCEPTION_STACKTRACE, ATTR_EXCEPTION_TYPE, } from "@opentelemetry/semantic-conventions";
import { oboe } from "@solarwinds-apm/bindings";
import { TRANSACTION_NAME_ATTRIBUTE } from "../../processing/transaction-name.js";
import { traceParent } from "../../propagation/headers.js";
import { componentLogger } from "../../shared/logger.js";
export class AppopticsTraceExporter {
constructor(reporter) {
this.
}
export(spans, resultCallback) {
for (const span of spans) {
const context = span.spanContext();
const md = this.
let evt;
if (span.parentSpanContext) {
evt = oboe.Context.createEntry(md, hrTimeToMicroseconds(span.startTime), this.
traceFlags: context.traceFlags,
traceId: context.traceId,
spanId: span.parentSpanContext.spanId,
}));
}
else {
evt = oboe.Context.createEntry(md, hrTimeToMicroseconds(span.startTime));
}
const kind = SpanKind[span.kind];
const layer = `${kind}:${span.name}`;
evt.addInfo("Layer", layer);
evt.addInfo("sw.span_name", span.name);
evt.addInfo("sw.span_kind", kind);
evt.addInfo("Language", "Node.js");
evt.addInfo("otel.scope.name", span.instrumentationScope.name);
evt.addInfo("otel.scope.version", span.instrumentationScope.version ?? null);
if (span.status.code !== SpanStatusCode.UNSET) {
evt.addInfo("otel.status_code", SpanStatusCode[span.status.code]);
}
if (span.status.message) {
evt.addInfo("otel.status_description", span.status.message);
}
if (span.droppedAttributesCount > 0) {
evt.addInfo("otel.dropped_attributes_count", span.droppedAttributesCount);
}
if (span.droppedEventsCount > 0) {
evt.addInfo("otel.dropped_events_count", span.droppedEventsCount);
}
if (span.droppedLinksCount > 0) {
evt.addInfo("otel.dropped_links_count", span.droppedLinksCount);
}
const rename = {
[]: "TransactionName",
};
for (const [key, value] of Object.entries(span.attributes)) {
const name = rename[key] ?? key;
evt.addInfo(name, this.
}
this.
for (const event of span.events) {
if (event.name === "exception") {
this.
}
else {
this.
}
}
evt = oboe.Context.createExit(hrTimeToMicroseconds(span.endTime));
evt.addInfo("Layer", layer);
this.
}
const result = this.
? { code: ExportResultCode.FAILED, error: this.
: { code: ExportResultCode.SUCCESS };
this.
resultCallback(result);
}
forceFlush() {
this.
return Promise.resolve();
}
shutdown() {
oboe.Context.shutdown();
return Promise.resolve();
}
return oboe.Metadata.fromString(traceParent(spanContext));
}
if (Array.isArray(v)) {
return inspect(v, { breakLength: Infinity, compact: true });
}
else {
return v ?? null;
}
}
const evt = oboe.Context.createEvent(hrTimeToMicroseconds(event.time));
evt.addInfo("Label", "error");
evt.addInfo("Spec", "error");
const rename = {
[]: "ErrorClass",
[]: "ErrorMsg",
[]: "Backtrace",
};
for (const [key, value] of Object.entries(event.attributes ?? {})) {
const name = rename[key] ?? key;
evt.addInfo(name, this.
}
this.
}
const evt = oboe.Context.createEvent(hrTimeToMicroseconds(event.time));
evt.addInfo("Label", "info");
for (const [key, value] of Object.entries(event.attributes ?? {})) {
evt.addInfo(key, this.
}
this.
}
const status = this.
if (status < 0) {
this.
this.
this.
}
}
}
_a = AppopticsTraceExporter;
//# sourceMappingURL=traces.js.map