Skip to content

Commit

Permalink
Remove SemanticAttributes deprecation warning
Browse files Browse the repository at this point in the history
Re-export the specific semantic attributes that are used by our
instrumentation from the `SEMATTRS_` exported constants, which are
not deprecated, mimicking the structure of the deprecated object.
  • Loading branch information
unflxw committed Jun 6, 2024
1 parent 976dee5 commit 09731e4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
16 changes: 16 additions & 0 deletions src/attributes.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
import {
SEMATTRS_MESSAGING_CONSUMER_ID,
SEMATTRS_MESSAGING_DESTINATION,
SEMATTRS_MESSAGING_MESSAGE_ID,
SEMATTRS_MESSAGING_OPERATION,
SEMATTRS_MESSAGING_SYSTEM,
} from "@opentelemetry/semantic-conventions";

const ns = "messaging.bullmq";
const job = `${ns}.job`;
const queue = `${ns}.queue`;
Expand Down Expand Up @@ -26,3 +34,11 @@ export const BullMQAttributes = {
WORKER_RATE_LIMIT_DURATION: `${worker}.rateLimiter.duration`,
WORKER_RATE_LIMIT_GROUP: `${worker}.rateLimiter.groupKey`,
};

export const SemanticAttributes = {
MESSAGING_SYSTEM: SEMATTRS_MESSAGING_SYSTEM,
MESSAGING_DESTINATION: SEMATTRS_MESSAGING_DESTINATION,
MESSAGING_OPERATION: SEMATTRS_MESSAGING_OPERATION,
MESSAGING_MESSAGE_ID: SEMATTRS_MESSAGING_MESSAGE_ID,
MESSAGING_CONSUMER_ID: SEMATTRS_MESSAGING_CONSUMER_ID,
};
3 changes: 1 addition & 2 deletions src/instrumentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
InstrumentationConfig,
InstrumentationNodeModuleDefinition,
} from "@opentelemetry/instrumentation";
import { SemanticAttributes } from "@opentelemetry/semantic-conventions";
import type { Attributes, Link, Span } from "@opentelemetry/api";
import {
context,
Expand All @@ -27,7 +26,7 @@ import type {
import { flatten } from "flat";

import { VERSION } from "./version";
import { BullMQAttributes } from "./attributes";
import { SemanticAttributes, BullMQAttributes } from "./attributes";

declare type Fn = (...args: any[]) => any;
const BULK_CONTEXT = Symbol("BULLMQ_BULK_CONTEXT");
Expand Down

0 comments on commit 09731e4

Please sign in to comment.