Skip to content

Commit 8d0d617

Browse files
committed
πŸ“ˆ add pubsub instrumentation library
1 parent 62fe7fd commit 8d0d617

File tree

4 files changed

+158
-1
lines changed

4 files changed

+158
-1
lines changed

β€Žpackage-lock.jsonβ€Ž

Lines changed: 154 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Žpackage.jsonβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
"lodash": "^4.17.21",
9090
"lru-cache": "^7.13.1",
9191
"moment": "^2.29.4",
92+
"opentelemetry-instrumentation-pubsub": "^2.1.0",
9293
"rate-limiter-flexible": "^2.3.11",
9394
"redis": "^4.2.0",
9495
"zod": "^3.23.8"

β€Žsrc/models/pubsub/pubsub-client.model.tsβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export class PubSubClient<T> {
2929
});
3030

3131
await Promise.race([
32-
topic.publishMessage({ data: dataBuffer, orderingKey }),
32+
topic.publishMessage({ data: dataBuffer, orderingKey, attributes: {} }),
3333
timeout(
3434
PUBLISH_TIMEOUT,
3535
'Could not publish message in time. Did you forget to authenticate with GCP? (gcloud auth application-default login)',

β€Žsrc/tracing/tracing-initializer.tsβ€Ž

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { SimpleSpanProcessor } from '@opentelemetry/sdk-trace-base';
44
import { HttpInstrumentation } from '@opentelemetry/instrumentation-http';
55
import { ExpressInstrumentation } from '@opentelemetry/instrumentation-express';
66
import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';
7+
import { PubSubInstrumentation } from 'opentelemetry-instrumentation-pubsub';
78
const apikey = process.env.BACKEND_TRACING_API_KEY;
89
const tracingEnabledEnv = process.env.BACKEND_TRACING_ENABLED;
910

@@ -19,6 +20,7 @@ export const otelSDK = new NodeSDK({
1920
instrumentations: [
2021
new HttpInstrumentation(),
2122
new ExpressInstrumentation(),
23+
new PubSubInstrumentation(),
2224
getNodeAutoInstrumentations({
2325
'@opentelemetry/instrumentation-fs': { enabled: false },
2426
}),

0 commit comments

Comments
Β (0)