Skip to content

Commit

Permalink
Merge branch 'main' into fix/host-metrics-bundling
Browse files Browse the repository at this point in the history
  • Loading branch information
Netail committed Apr 24, 2024
2 parents a8196e4 + a5bee9f commit 304dc98
Show file tree
Hide file tree
Showing 5 changed files with 325 additions and 324 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,15 @@ jobs:
# get main again
- name: Checkout Repository
# only checkout if a release has been created
if: ${{ steps.release.outputs.release_created }}
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Rebuild Packages
# only rebuild if a release has been created
if: ${{ steps.release.outputs.release_created }}
run: |
npm ci
npm run compile
Expand All @@ -67,6 +71,8 @@ jobs:
# need to publish all unpublished versions to npm here
# See: https://github.com/lerna/lerna/tree/main/commands/publish#bump-from-package
- name: Publish to npm
# only publish if a release has been created
if: ${{ steps.release.outputs.release_created }}
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
run: npx lerna publish from-package --no-push --no-private --no-git-tag-version --no-verify-access --yes
196 changes: 94 additions & 102 deletions plugins/node/instrumentation-amqplib/test/amqplib-callbacks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,16 @@ registerInstrumentationTesting(new AmqplibInstrumentation());

import * as amqpCallback from 'amqplib/callback_api';
import {
MessagingDestinationKindValues,
SemanticAttributes,
MESSAGINGDESTINATIONKINDVALUES_TOPIC,
SEMATTRS_MESSAGING_DESTINATION,
SEMATTRS_MESSAGING_DESTINATION_KIND,
SEMATTRS_MESSAGING_PROTOCOL,
SEMATTRS_MESSAGING_PROTOCOL_VERSION,
SEMATTRS_MESSAGING_RABBITMQ_ROUTING_KEY,
SEMATTRS_MESSAGING_SYSTEM,
SEMATTRS_MESSAGING_URL,
SEMATTRS_NET_PEER_NAME,
SEMATTRS_NET_PEER_PORT,
} from '@opentelemetry/semantic-conventions';
import { Baggage, context, propagation, SpanKind } from '@opentelemetry/api';
import { asyncConfirmSend, asyncConsume, shouldTest } from './utils';
Expand Down Expand Up @@ -127,67 +135,63 @@ describe('amqplib instrumentation callback model', () => {

// assert publish span
expect(publishSpan.kind).toEqual(SpanKind.PRODUCER);
expect(publishSpan.attributes[SEMATTRS_MESSAGING_SYSTEM]).toEqual(
'rabbitmq'
);
expect(publishSpan.attributes[SEMATTRS_MESSAGING_DESTINATION]).toEqual(
''
); // according to spec: "This will be an empty string if the default exchange is used"
expect(
publishSpan.attributes[SemanticAttributes.MESSAGING_SYSTEM]
).toEqual('rabbitmq');
expect(
publishSpan.attributes[SemanticAttributes.MESSAGING_DESTINATION]
).toEqual(''); // according to spec: "This will be an empty string if the default exchange is used"
expect(
publishSpan.attributes[SemanticAttributes.MESSAGING_DESTINATION_KIND]
).toEqual(MessagingDestinationKindValues.TOPIC);
publishSpan.attributes[SEMATTRS_MESSAGING_DESTINATION_KIND]
).toEqual(MESSAGINGDESTINATIONKINDVALUES_TOPIC);
expect(
publishSpan.attributes[
SemanticAttributes.MESSAGING_RABBITMQ_ROUTING_KEY
]
publishSpan.attributes[SEMATTRS_MESSAGING_RABBITMQ_ROUTING_KEY]
).toEqual(queueName);
expect(publishSpan.attributes[SEMATTRS_MESSAGING_PROTOCOL]).toEqual(
'AMQP'
);
expect(
publishSpan.attributes[SemanticAttributes.MESSAGING_PROTOCOL]
).toEqual('AMQP');
expect(
publishSpan.attributes[SemanticAttributes.MESSAGING_PROTOCOL_VERSION]
publishSpan.attributes[SEMATTRS_MESSAGING_PROTOCOL_VERSION]
).toEqual('0.9.1');
expect(
publishSpan.attributes[SemanticAttributes.MESSAGING_URL]
).toEqual(censoredUrl);
expect(
publishSpan.attributes[SemanticAttributes.NET_PEER_NAME]
).toEqual(TEST_RABBITMQ_HOST);
expect(
publishSpan.attributes[SemanticAttributes.NET_PEER_PORT]
).toEqual(TEST_RABBITMQ_PORT);
expect(publishSpan.attributes[SEMATTRS_MESSAGING_URL]).toEqual(
censoredUrl
);
expect(publishSpan.attributes[SEMATTRS_NET_PEER_NAME]).toEqual(
TEST_RABBITMQ_HOST
);
expect(publishSpan.attributes[SEMATTRS_NET_PEER_PORT]).toEqual(
TEST_RABBITMQ_PORT
);

// assert consume span
expect(consumeSpan.kind).toEqual(SpanKind.CONSUMER);
expect(consumeSpan.attributes[SEMATTRS_MESSAGING_SYSTEM]).toEqual(
'rabbitmq'
);
expect(consumeSpan.attributes[SEMATTRS_MESSAGING_DESTINATION]).toEqual(
''
); // according to spec: "This will be an empty string if the default exchange is used"
expect(
consumeSpan.attributes[SemanticAttributes.MESSAGING_SYSTEM]
).toEqual('rabbitmq');
expect(
consumeSpan.attributes[SemanticAttributes.MESSAGING_DESTINATION]
).toEqual(''); // according to spec: "This will be an empty string if the default exchange is used"
expect(
consumeSpan.attributes[SemanticAttributes.MESSAGING_DESTINATION_KIND]
).toEqual(MessagingDestinationKindValues.TOPIC);
consumeSpan.attributes[SEMATTRS_MESSAGING_DESTINATION_KIND]
).toEqual(MESSAGINGDESTINATIONKINDVALUES_TOPIC);
expect(
consumeSpan.attributes[
SemanticAttributes.MESSAGING_RABBITMQ_ROUTING_KEY
]
consumeSpan.attributes[SEMATTRS_MESSAGING_RABBITMQ_ROUTING_KEY]
).toEqual(queueName);
expect(consumeSpan.attributes[SEMATTRS_MESSAGING_PROTOCOL]).toEqual(
'AMQP'
);
expect(
consumeSpan.attributes[SemanticAttributes.MESSAGING_PROTOCOL]
).toEqual('AMQP');
expect(
consumeSpan.attributes[SemanticAttributes.MESSAGING_PROTOCOL_VERSION]
consumeSpan.attributes[SEMATTRS_MESSAGING_PROTOCOL_VERSION]
).toEqual('0.9.1');
expect(
consumeSpan.attributes[SemanticAttributes.MESSAGING_URL]
).toEqual(censoredUrl);
expect(
consumeSpan.attributes[SemanticAttributes.NET_PEER_NAME]
).toEqual(TEST_RABBITMQ_HOST);
expect(
consumeSpan.attributes[SemanticAttributes.NET_PEER_PORT]
).toEqual(TEST_RABBITMQ_PORT);
expect(consumeSpan.attributes[SEMATTRS_MESSAGING_URL]).toEqual(
censoredUrl
);
expect(consumeSpan.attributes[SEMATTRS_NET_PEER_NAME]).toEqual(
TEST_RABBITMQ_HOST
);
expect(consumeSpan.attributes[SEMATTRS_NET_PEER_PORT]).toEqual(
TEST_RABBITMQ_PORT
);

// assert context propagation
expect(consumeSpan.spanContext().traceId).toEqual(
Expand Down Expand Up @@ -301,75 +305,63 @@ describe('amqplib instrumentation callback model', () => {

// assert publish span
expect(publishSpan.kind).toEqual(SpanKind.PRODUCER);
expect(publishSpan.attributes[SEMATTRS_MESSAGING_SYSTEM]).toEqual(
'rabbitmq'
);
expect(
publishSpan.attributes[SemanticAttributes.MESSAGING_SYSTEM]
).toEqual('rabbitmq');
expect(
publishSpan.attributes[SemanticAttributes.MESSAGING_DESTINATION]
publishSpan.attributes[SEMATTRS_MESSAGING_DESTINATION]
).toEqual(''); // according to spec: "This will be an empty string if the default exchange is used"
expect(
publishSpan.attributes[
SemanticAttributes.MESSAGING_DESTINATION_KIND
]
).toEqual(MessagingDestinationKindValues.TOPIC);
publishSpan.attributes[SEMATTRS_MESSAGING_DESTINATION_KIND]
).toEqual(MESSAGINGDESTINATIONKINDVALUES_TOPIC);
expect(
publishSpan.attributes[
SemanticAttributes.MESSAGING_RABBITMQ_ROUTING_KEY
]
publishSpan.attributes[SEMATTRS_MESSAGING_RABBITMQ_ROUTING_KEY]
).toEqual(queueName);
expect(publishSpan.attributes[SEMATTRS_MESSAGING_PROTOCOL]).toEqual(
'AMQP'
);
expect(
publishSpan.attributes[SemanticAttributes.MESSAGING_PROTOCOL]
).toEqual('AMQP');
expect(
publishSpan.attributes[
SemanticAttributes.MESSAGING_PROTOCOL_VERSION
]
publishSpan.attributes[SEMATTRS_MESSAGING_PROTOCOL_VERSION]
).toEqual('0.9.1');
expect(
publishSpan.attributes[SemanticAttributes.MESSAGING_URL]
).toEqual(censoredUrl);
expect(
publishSpan.attributes[SemanticAttributes.NET_PEER_NAME]
).toEqual(TEST_RABBITMQ_HOST);
expect(
publishSpan.attributes[SemanticAttributes.NET_PEER_PORT]
).toEqual(TEST_RABBITMQ_PORT);
expect(publishSpan.attributes[SEMATTRS_MESSAGING_URL]).toEqual(
censoredUrl
);
expect(publishSpan.attributes[SEMATTRS_NET_PEER_NAME]).toEqual(
TEST_RABBITMQ_HOST
);
expect(publishSpan.attributes[SEMATTRS_NET_PEER_PORT]).toEqual(
TEST_RABBITMQ_PORT
);

// assert consume span
expect(consumeSpan.kind).toEqual(SpanKind.CONSUMER);
expect(consumeSpan.attributes[SEMATTRS_MESSAGING_SYSTEM]).toEqual(
'rabbitmq'
);
expect(
consumeSpan.attributes[SemanticAttributes.MESSAGING_SYSTEM]
).toEqual('rabbitmq');
expect(
consumeSpan.attributes[SemanticAttributes.MESSAGING_DESTINATION]
consumeSpan.attributes[SEMATTRS_MESSAGING_DESTINATION]
).toEqual(''); // according to spec: "This will be an empty string if the default exchange is used"
expect(
consumeSpan.attributes[
SemanticAttributes.MESSAGING_DESTINATION_KIND
]
).toEqual(MessagingDestinationKindValues.TOPIC);
consumeSpan.attributes[SEMATTRS_MESSAGING_DESTINATION_KIND]
).toEqual(MESSAGINGDESTINATIONKINDVALUES_TOPIC);
expect(
consumeSpan.attributes[
SemanticAttributes.MESSAGING_RABBITMQ_ROUTING_KEY
]
consumeSpan.attributes[SEMATTRS_MESSAGING_RABBITMQ_ROUTING_KEY]
).toEqual(queueName);
expect(consumeSpan.attributes[SEMATTRS_MESSAGING_PROTOCOL]).toEqual(
'AMQP'
);
expect(
consumeSpan.attributes[SemanticAttributes.MESSAGING_PROTOCOL]
).toEqual('AMQP');
expect(
consumeSpan.attributes[
SemanticAttributes.MESSAGING_PROTOCOL_VERSION
]
consumeSpan.attributes[SEMATTRS_MESSAGING_PROTOCOL_VERSION]
).toEqual('0.9.1');
expect(
consumeSpan.attributes[SemanticAttributes.MESSAGING_URL]
).toEqual(censoredUrl);
expect(
consumeSpan.attributes[SemanticAttributes.NET_PEER_NAME]
).toEqual(TEST_RABBITMQ_HOST);
expect(
consumeSpan.attributes[SemanticAttributes.NET_PEER_PORT]
).toEqual(TEST_RABBITMQ_PORT);
expect(consumeSpan.attributes[SEMATTRS_MESSAGING_URL]).toEqual(
censoredUrl
);
expect(consumeSpan.attributes[SEMATTRS_NET_PEER_NAME]).toEqual(
TEST_RABBITMQ_HOST
);
expect(consumeSpan.attributes[SEMATTRS_NET_PEER_PORT]).toEqual(
TEST_RABBITMQ_PORT
);

// assert context propagation
expect(consumeSpan.spanContext().traceId).toEqual(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,14 @@ import {

registerInstrumentationTesting(new AmqplibInstrumentation());
import * as amqp from 'amqplib';
import { SemanticAttributes } from '@opentelemetry/semantic-conventions';
import {
SEMATTRS_MESSAGING_PROTOCOL,
SEMATTRS_MESSAGING_PROTOCOL_VERSION,
SEMATTRS_MESSAGING_SYSTEM,
SEMATTRS_MESSAGING_URL,
SEMATTRS_NET_PEER_NAME,
SEMATTRS_NET_PEER_PORT,
} from '@opentelemetry/semantic-conventions';

describe('amqplib instrumentation connection', () => {
before(function () {
Expand Down Expand Up @@ -60,24 +67,22 @@ describe('amqplib instrumentation connection', () => {
);
const [publishSpan] = getTestSpans();

expect(publishSpan.attributes[SEMATTRS_MESSAGING_SYSTEM]).toEqual(
'rabbitmq'
);
expect(publishSpan.attributes[SEMATTRS_MESSAGING_PROTOCOL]).toEqual(
'AMQP'
);
expect(
publishSpan.attributes[SemanticAttributes.MESSAGING_SYSTEM]
).toEqual('rabbitmq');
expect(
publishSpan.attributes[SemanticAttributes.MESSAGING_PROTOCOL]
).toEqual('AMQP');
expect(
publishSpan.attributes[SemanticAttributes.MESSAGING_PROTOCOL_VERSION]
publishSpan.attributes[SEMATTRS_MESSAGING_PROTOCOL_VERSION]
).toEqual('0.9.1');
expect(
publishSpan.attributes[SemanticAttributes.MESSAGING_URL]
).toBeUndefined(); // no url string if value supplied as object
expect(
publishSpan.attributes[SemanticAttributes.NET_PEER_NAME]
).toEqual(TEST_RABBITMQ_HOST);
expect(
publishSpan.attributes[SemanticAttributes.NET_PEER_PORT]
).toEqual(TEST_RABBITMQ_PORT);
expect(publishSpan.attributes[SEMATTRS_MESSAGING_URL]).toBeUndefined(); // no url string if value supplied as object
expect(publishSpan.attributes[SEMATTRS_NET_PEER_NAME]).toEqual(
TEST_RABBITMQ_HOST
);
expect(publishSpan.attributes[SEMATTRS_NET_PEER_PORT]).toEqual(
TEST_RABBITMQ_PORT
);
} finally {
await conn.close();
}
Expand All @@ -99,9 +104,9 @@ describe('amqplib instrumentation connection', () => {
Buffer.from('message created only to test connection attributes')
);
const [publishSpan] = getTestSpans();
expect(
publishSpan.attributes[SemanticAttributes.MESSAGING_PROTOCOL]
).toEqual('AMQP');
expect(publishSpan.attributes[SEMATTRS_MESSAGING_PROTOCOL]).toEqual(
'AMQP'
);
} finally {
await conn.close();
}
Expand All @@ -127,9 +132,9 @@ describe('amqplib instrumentation connection', () => {
Buffer.from('message created only to test connection attributes')
);
const [publishSpan] = getTestSpans();
expect(
publishSpan.attributes[SemanticAttributes.NET_PEER_NAME]
).toEqual(TEST_RABBITMQ_HOST);
expect(publishSpan.attributes[SEMATTRS_NET_PEER_NAME]).toEqual(
TEST_RABBITMQ_HOST
);
} finally {
await conn.close();
}
Expand All @@ -149,24 +154,24 @@ describe('amqplib instrumentation connection', () => {
);
const [publishSpan] = getTestSpans();

expect(publishSpan.attributes[SEMATTRS_MESSAGING_SYSTEM]).toEqual(
'rabbitmq'
);
expect(publishSpan.attributes[SEMATTRS_MESSAGING_PROTOCOL]).toEqual(
'AMQP'
);
expect(
publishSpan.attributes[SemanticAttributes.MESSAGING_SYSTEM]
).toEqual('rabbitmq');
expect(
publishSpan.attributes[SemanticAttributes.MESSAGING_PROTOCOL]
).toEqual('AMQP');
expect(
publishSpan.attributes[SemanticAttributes.MESSAGING_PROTOCOL_VERSION]
publishSpan.attributes[SEMATTRS_MESSAGING_PROTOCOL_VERSION]
).toEqual('0.9.1');
expect(
publishSpan.attributes[SemanticAttributes.MESSAGING_URL]
).toEqual(censoredUrl);
expect(
publishSpan.attributes[SemanticAttributes.NET_PEER_NAME]
).toEqual(TEST_RABBITMQ_HOST);
expect(
publishSpan.attributes[SemanticAttributes.NET_PEER_PORT]
).toEqual(TEST_RABBITMQ_PORT);
expect(publishSpan.attributes[SEMATTRS_MESSAGING_URL]).toEqual(
censoredUrl
);
expect(publishSpan.attributes[SEMATTRS_NET_PEER_NAME]).toEqual(
TEST_RABBITMQ_HOST
);
expect(publishSpan.attributes[SEMATTRS_NET_PEER_PORT]).toEqual(
TEST_RABBITMQ_PORT
);
} finally {
await conn.close();
}
Expand Down
Loading

0 comments on commit 304dc98

Please sign in to comment.