@google-cloud/pubsub 4.5.0 → 4.7.0
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/CHANGELOG.md +20 -0
- package/README.md +3 -1
- package/build/protos/google/pubsub/v1/pubsub.proto +12 -0
- package/build/protos/protos.d.ts +14 -1
- package/build/protos/protos.js +69 -1
- package/build/protos/protos.json +19 -1
- package/build/src/ack-metadata.js +2 -3
- package/build/src/ack-metadata.js.map +1 -1
- package/build/src/iam.d.ts +11 -3
- package/build/src/iam.js +12 -2
- package/build/src/iam.js.map +1 -1
- package/build/src/index.d.ts +2 -0
- package/build/src/index.js +5 -1
- package/build/src/index.js.map +1 -1
- package/build/src/lease-manager.d.ts +2 -3
- package/build/src/lease-manager.js +19 -3
- package/build/src/lease-manager.js.map +1 -1
- package/build/src/message-queues.d.ts +8 -4
- package/build/src/message-queues.js +17 -8
- package/build/src/message-queues.js.map +1 -1
- package/build/src/message-stream.d.ts +0 -1
- package/build/src/publisher/flow-publisher.js +5 -0
- package/build/src/publisher/flow-publisher.js.map +1 -1
- package/build/src/publisher/index.d.ts +3 -3
- package/build/src/publisher/index.js +24 -46
- package/build/src/publisher/index.js.map +1 -1
- package/build/src/publisher/message-batch.d.ts +13 -1
- package/build/src/publisher/message-batch.js +11 -1
- package/build/src/publisher/message-batch.js.map +1 -1
- package/build/src/publisher/message-queues.d.ts +0 -2
- package/build/src/publisher/message-queues.js +32 -6
- package/build/src/publisher/message-queues.js.map +1 -1
- package/build/src/publisher/pubsub-message.d.ts +43 -1
- package/build/src/publisher/pubsub-message.js +30 -2
- package/build/src/publisher/pubsub-message.js.map +1 -1
- package/build/src/pubsub.d.ts +5 -1
- package/build/src/pubsub.js +4 -14
- package/build/src/pubsub.js.map +1 -1
- package/build/src/subscriber.d.ts +72 -8
- package/build/src/subscriber.js +179 -51
- package/build/src/subscriber.js.map +1 -1
- package/build/src/subscription.d.ts +3 -3
- package/build/src/subscription.js +7 -4
- package/build/src/subscription.js.map +1 -1
- package/build/src/telemetry-tracing.d.ts +257 -0
- package/build/src/telemetry-tracing.js +648 -0
- package/build/src/telemetry-tracing.js.map +1 -0
- package/build/src/topic.d.ts +2 -2
- package/build/src/topic.js +8 -4
- package/build/src/topic.js.map +1 -1
- package/build/src/util.js +4 -4
- package/build/src/util.js.map +1 -1
- package/build/src/v1/publisher_client.d.ts +0 -1
- package/build/src/v1/schema_service_client.d.ts +0 -1
- package/build/src/v1/subscriber_client.d.ts +0 -1
- package/package.json +5 -4
- package/build/src/opentelemetry-tracing.d.ts +0 -23
- package/build/src/opentelemetry-tracing.js +0 -42
- package/build/src/opentelemetry-tracing.js.map +0 -1
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright 2020-2024 Google LLC
|
|
3
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License.
|
|
5
|
+
* You may obtain a copy of the License at
|
|
6
|
+
*
|
|
7
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
* See the License for the specific language governing permissions and
|
|
13
|
+
* limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
import { SpanContext, Span, SpanKind, TextMapGetter, TextMapSetter, Context } from '@opentelemetry/api';
|
|
16
|
+
import { Attributes, PubsubMessage } from './publisher/pubsub-message';
|
|
17
|
+
import { PublishOptions } from './publisher/index';
|
|
18
|
+
import { Duration } from './temporal';
|
|
19
|
+
export { Span };
|
|
20
|
+
/**
|
|
21
|
+
* Determination of the level of OTel support we're providing.
|
|
22
|
+
*
|
|
23
|
+
* @private
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
export declare enum OpenTelemetryLevel {
|
|
27
|
+
/**
|
|
28
|
+
* None: OTel support is not enabled because we found no trace provider, or
|
|
29
|
+
* the user has not enabled it.
|
|
30
|
+
*/
|
|
31
|
+
None = 0,
|
|
32
|
+
/**
|
|
33
|
+
* Legacy: We found a trace provider, but the user also specified the old
|
|
34
|
+
* manual enable flag; this will trigger the legacy attribute being included.
|
|
35
|
+
* The modern propagation attribute will _also_ be included.
|
|
36
|
+
*/
|
|
37
|
+
Legacy = 1,
|
|
38
|
+
/**
|
|
39
|
+
* Modern: We will only inject/extract the modern propagation attribute.
|
|
40
|
+
*/
|
|
41
|
+
Modern = 2
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Manually set the OpenTelemetry enabledness.
|
|
45
|
+
*
|
|
46
|
+
* @param enabled The enabled flag to use, to override any automated methods.
|
|
47
|
+
* @private
|
|
48
|
+
* @internal
|
|
49
|
+
*/
|
|
50
|
+
export declare function setGloballyEnabled(enabled: boolean): void;
|
|
51
|
+
/**
|
|
52
|
+
* Tries to divine what sort of OpenTelemetry we're supporting. See the enum
|
|
53
|
+
* for the meaning of the values, and other notes.
|
|
54
|
+
*
|
|
55
|
+
* Legacy OTel is no longer officially supported, but we don't want to
|
|
56
|
+
* break anyone at a non-major.
|
|
57
|
+
*
|
|
58
|
+
* @private
|
|
59
|
+
* @internal
|
|
60
|
+
*/
|
|
61
|
+
export declare function isEnabled(publishSettings?: PublishOptions): OpenTelemetryLevel;
|
|
62
|
+
/**
|
|
63
|
+
* Our Carrier object for propagation is anything with an 'attributes'
|
|
64
|
+
* object, which is one of several possible Message classes. (They're
|
|
65
|
+
* different for publish and subscribe.)
|
|
66
|
+
*
|
|
67
|
+
* Also we add a parentSpan optional member for passing around the
|
|
68
|
+
* actual Span object within the client library. This can be a publish
|
|
69
|
+
* or subscriber span, depending on the context.
|
|
70
|
+
*
|
|
71
|
+
* @private
|
|
72
|
+
* @internal
|
|
73
|
+
*/
|
|
74
|
+
export interface MessageWithAttributes {
|
|
75
|
+
attributes?: Attributes | null | undefined;
|
|
76
|
+
parentSpan?: Span;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Implements common members for the TextMap getter and setter interfaces for Pub/Sub messages.
|
|
80
|
+
*
|
|
81
|
+
* @private
|
|
82
|
+
* @internal
|
|
83
|
+
*/
|
|
84
|
+
export declare class PubsubMessageGetSet {
|
|
85
|
+
static keyPrefix: string;
|
|
86
|
+
keys(carrier: MessageWithAttributes): string[];
|
|
87
|
+
protected attributeName(key: string): string;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Implements the TextMap getter interface for Pub/Sub messages.
|
|
91
|
+
*
|
|
92
|
+
* @private
|
|
93
|
+
* @internal
|
|
94
|
+
*/
|
|
95
|
+
export declare class PubsubMessageGet extends PubsubMessageGetSet implements TextMapGetter<MessageWithAttributes> {
|
|
96
|
+
get(carrier: MessageWithAttributes, key: string): string | string[] | undefined;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Implements the TextMap setter interface for Pub/Sub messages.
|
|
100
|
+
*
|
|
101
|
+
* @private
|
|
102
|
+
* @internal
|
|
103
|
+
*/
|
|
104
|
+
export declare class PubsubMessageSet extends PubsubMessageGetSet implements TextMapSetter<MessageWithAttributes> {
|
|
105
|
+
set(carrier: MessageWithAttributes, key: string, value: string): void;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* The getter to use when calling extract() on a Pub/Sub message.
|
|
109
|
+
*
|
|
110
|
+
* @private
|
|
111
|
+
* @internal
|
|
112
|
+
*/
|
|
113
|
+
export declare const pubsubGetter: PubsubMessageGet;
|
|
114
|
+
/**
|
|
115
|
+
* The setter to use when calling inject() on a Pub/Sub message.
|
|
116
|
+
*
|
|
117
|
+
* @private
|
|
118
|
+
* @internal
|
|
119
|
+
*/
|
|
120
|
+
export declare const pubsubSetter: PubsubMessageSet;
|
|
121
|
+
/**
|
|
122
|
+
* Description of the data structure passed for span attributes.
|
|
123
|
+
*
|
|
124
|
+
* @private
|
|
125
|
+
* @internal
|
|
126
|
+
*/
|
|
127
|
+
export interface SpanAttributes {
|
|
128
|
+
[x: string]: string | number | boolean;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Converts a SpanContext to a full Context, as needed.
|
|
132
|
+
*
|
|
133
|
+
* @private
|
|
134
|
+
* @internal
|
|
135
|
+
*/
|
|
136
|
+
export declare function spanContextToContext(parent?: SpanContext): Context | undefined;
|
|
137
|
+
/**
|
|
138
|
+
* The modern propagation attribute name.
|
|
139
|
+
*
|
|
140
|
+
* Technically this is determined by the OpenTelemetry library, but
|
|
141
|
+
* in practice, it follows the W3C spec, so this should be the right
|
|
142
|
+
* one. The only thing we're using it for, anyway, is emptying user
|
|
143
|
+
* supplied attributes.
|
|
144
|
+
*
|
|
145
|
+
* @private
|
|
146
|
+
* @internal
|
|
147
|
+
*/
|
|
148
|
+
export declare const modernAttributeName = "googclient_traceparent";
|
|
149
|
+
/**
|
|
150
|
+
* The old legacy attribute name.
|
|
151
|
+
*
|
|
152
|
+
* @private
|
|
153
|
+
* @internal
|
|
154
|
+
*/
|
|
155
|
+
export declare const legacyAttributeName = "googclient_OpenTelemetrySpanContext";
|
|
156
|
+
export interface AttributeParams {
|
|
157
|
+
topicName?: string;
|
|
158
|
+
subName?: string;
|
|
159
|
+
projectId?: string;
|
|
160
|
+
topicId?: string;
|
|
161
|
+
subId?: string;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Break down the subscription's full name into its project and ID.
|
|
165
|
+
*
|
|
166
|
+
* @private
|
|
167
|
+
* @internal
|
|
168
|
+
*/
|
|
169
|
+
export declare function getSubscriptionInfo(fullName: string): AttributeParams;
|
|
170
|
+
/**
|
|
171
|
+
* Break down the subscription's full name into its project and ID.
|
|
172
|
+
*
|
|
173
|
+
* @private
|
|
174
|
+
* @internal
|
|
175
|
+
*/
|
|
176
|
+
export declare function getTopicInfo(fullName: string): AttributeParams;
|
|
177
|
+
/**
|
|
178
|
+
* Contains utility methods for creating spans.
|
|
179
|
+
*
|
|
180
|
+
* @private
|
|
181
|
+
* @internal
|
|
182
|
+
*/
|
|
183
|
+
export declare class PubsubSpans {
|
|
184
|
+
static createAttributes(params: AttributeParams, message?: PubsubMessage, caller?: string): SpanAttributes;
|
|
185
|
+
static createPublisherSpan(message: PubsubMessage, topicName: string, caller: string): Span | undefined;
|
|
186
|
+
static updatePublisherTopicName(span: Span, topicName: string): void;
|
|
187
|
+
static createReceiveSpan(message: PubsubMessage, subName: string, parent: Context | undefined, caller: string): Span | undefined;
|
|
188
|
+
static createChildSpan(name: string, message?: PubsubMessage, parentSpan?: Span, attributes?: SpanAttributes): Span | undefined;
|
|
189
|
+
static createPublishFlowSpan(message: PubsubMessage): Span | undefined;
|
|
190
|
+
static createPublishSchedulerSpan(message: PubsubMessage): Span | undefined;
|
|
191
|
+
static createPublishRpcSpan(messages: MessageWithAttributes[], topicName: string, caller: string): Span | undefined;
|
|
192
|
+
static createAckRpcSpan(messageSpans: (Span | undefined)[], subName: string, caller: string): Span | undefined;
|
|
193
|
+
static createModackRpcSpan(messageSpans: (Span | undefined)[], subName: string, type: 'modack' | 'nack', caller: string, deadline?: Duration, isInitial?: boolean): Span | undefined;
|
|
194
|
+
static createReceiveFlowSpan(message: MessageWithAttributes): Span | undefined;
|
|
195
|
+
static createReceiveSchedulerSpan(message: MessageWithAttributes): Span | undefined;
|
|
196
|
+
static createReceiveProcessSpan(message: MessageWithAttributes, subName: string): Span | undefined;
|
|
197
|
+
static setReceiveProcessResult(span: Span, isAck: boolean): void;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Creates and manipulates Pub/Sub-related events on spans.
|
|
201
|
+
*
|
|
202
|
+
* @private
|
|
203
|
+
* @internal
|
|
204
|
+
*/
|
|
205
|
+
export declare class PubsubEvents {
|
|
206
|
+
static addEvent(text: string, message: MessageWithAttributes, attributes?: Attributes): void;
|
|
207
|
+
static publishStart(message: MessageWithAttributes): void;
|
|
208
|
+
static publishEnd(message: MessageWithAttributes): void;
|
|
209
|
+
static ackStart(message: MessageWithAttributes): void;
|
|
210
|
+
static ackEnd(message: MessageWithAttributes): void;
|
|
211
|
+
static modackStart(message: MessageWithAttributes): void;
|
|
212
|
+
static modackEnd(message: MessageWithAttributes): void;
|
|
213
|
+
static nackStart(message: MessageWithAttributes): void;
|
|
214
|
+
static nackEnd(message: MessageWithAttributes): void;
|
|
215
|
+
static ackCalled(span: Span): void;
|
|
216
|
+
static nackCalled(span: Span): void;
|
|
217
|
+
static modAckCalled(span: Span, deadline: Duration): void;
|
|
218
|
+
static modAckStart(message: MessageWithAttributes, deadline: Duration, isInitial: boolean): void;
|
|
219
|
+
static modAckEnd(message: MessageWithAttributes): void;
|
|
220
|
+
static shutdown(message: MessageWithAttributes): void;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Injects the trace context into a Pub/Sub message (or other object with
|
|
224
|
+
* an 'attributes' object) for propagation.
|
|
225
|
+
*
|
|
226
|
+
* This is for the publish side.
|
|
227
|
+
*
|
|
228
|
+
* @private
|
|
229
|
+
* @internal
|
|
230
|
+
*/
|
|
231
|
+
export declare function injectSpan(span: Span, message: MessageWithAttributes, enabled: OpenTelemetryLevel): void;
|
|
232
|
+
/**
|
|
233
|
+
* Returns true if this message potentially contains a span context.
|
|
234
|
+
*
|
|
235
|
+
* @private
|
|
236
|
+
* @internal
|
|
237
|
+
*/
|
|
238
|
+
export declare function containsSpanContext(message: MessageWithAttributes): boolean;
|
|
239
|
+
/**
|
|
240
|
+
* Extracts the trace context from a Pub/Sub message (or other object with
|
|
241
|
+
* an 'attributes' object) from a propagation, for receive processing. If no
|
|
242
|
+
* context was present, create a new parent span.
|
|
243
|
+
*
|
|
244
|
+
* This is for the receive side.
|
|
245
|
+
*
|
|
246
|
+
* @private
|
|
247
|
+
* @internal
|
|
248
|
+
*/
|
|
249
|
+
export declare function extractSpan(message: MessageWithAttributes, subName: string, enabled: OpenTelemetryLevel): Span | undefined;
|
|
250
|
+
export declare const legacyExports: {
|
|
251
|
+
/**
|
|
252
|
+
* @deprecated
|
|
253
|
+
* Use the new telemetry functionality instead; see the updated OpenTelemetry
|
|
254
|
+
* sample for an example.
|
|
255
|
+
*/
|
|
256
|
+
createSpan: (spanName: string, kind: SpanKind, attributes?: SpanAttributes, parent?: SpanContext) => Span;
|
|
257
|
+
};
|