@neat.is/core 0.4.4 → 0.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -337,12 +337,15 @@ function parseOtlpRequest(body) {
337
337
  const out = [];
338
338
  for (const rs of body.resourceSpans ?? []) {
339
339
  const resourceAttrs = attrsToRecord(rs.resource?.attributes);
340
- const service = typeof resourceAttrs["service.name"] === "string" ? resourceAttrs["service.name"] : "unknown";
340
+ const rawServiceName = resourceAttrs["service.name"];
341
+ const resourceServiceNamePresent = typeof rawServiceName === "string" && rawServiceName.length > 0;
342
+ const service = resourceServiceNamePresent ? rawServiceName : "unidentified";
341
343
  for (const ss of rs.scopeSpans ?? []) {
342
344
  for (const span of ss.spans ?? []) {
343
345
  const attrs = attrsToRecord(span.attributes);
344
346
  const parsed = {
345
347
  service,
348
+ resourceServiceNamePresent,
346
349
  traceId: span.traceId ?? "",
347
350
  spanId: span.spanId ?? "",
348
351
  parentSpanId: span.parentSpanId || void 0,
@@ -1644,6 +1647,14 @@ function thresholdForEdgeType(edgeType, overrides) {
1644
1647
  function nowIso(ctx) {
1645
1648
  return new Date(ctx.now ? ctx.now() : Date.now()).toISOString();
1646
1649
  }
1650
+ var unidentifiedWarnedProjects = /* @__PURE__ */ new Set();
1651
+ function warnUnidentifiedSpan(project) {
1652
+ if (unidentifiedWarnedProjects.has(project)) return;
1653
+ unidentifiedWarnedProjects.add(project);
1654
+ console.warn(
1655
+ `[neatd] span lacked service.name; routed to 'unidentified' in project ${project}; check your OTel SDK config.`
1656
+ );
1657
+ }
1647
1658
  function pickAttr(span, ...keys) {
1648
1659
  for (const k of keys) {
1649
1660
  const v = span.attributes[k];
@@ -1898,6 +1909,9 @@ async function handleSpan(ctx, span) {
1898
1909
  const ts = span.startTimeIso ?? nowIso(ctx);
1899
1910
  const nowMs = ctx.now ? ctx.now() : Date.now();
1900
1911
  const env = span.env ?? "unknown";
1912
+ if (span.resourceServiceNamePresent === false) {
1913
+ warnUnidentifiedSpan(ctx.project ?? DEFAULT_PROJECT);
1914
+ }
1901
1915
  const sourceId = ensureServiceNode(ctx.graph, span.service, env);
1902
1916
  const isError = span.statusCode === 2;
1903
1917
  cacheSpanService(span, nowMs);