Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions handwritten/pubsub/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"@google-cloud/projectify": "^5.0.0",
"@google-cloud/promisify": "^5.0.0",
"@opentelemetry/api": "~1.9.0",
"@opentelemetry/core": "^1.30.1",
"@opentelemetry/core": "^2.0.0",
Comment thread
omgovich marked this conversation as resolved.
"@opentelemetry/semantic-conventions": "~1.39.0",
"arrify": "^2.0.0",
"extend": "^3.0.2",
Expand All @@ -70,7 +70,7 @@
},
"devDependencies": {
"@grpc/proto-loader": "^0.8.0",
"@opentelemetry/sdk-trace-base": "^1.17.0",
"@opentelemetry/sdk-trace-base": "^2.0.0",
"@types/duplexify": "^3.6.4",
"@types/extend": "^3.0.4",
"@types/lodash.snakecase": "^4.1.9",
Expand Down
5 changes: 4 additions & 1 deletion handwritten/pubsub/test/subscriber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1200,7 +1200,10 @@ describe('Subscriber', () => {
assert.strictEqual(spans[0].events.length, 2);
const firstSpan = spans.pop();
assert.ok(firstSpan);
assert.strictEqual(firstSpan.parentSpanId, parentSpanContext.spanId);
assert.strictEqual(
firstSpan.parentSpanContext?.spanId,
parentSpanContext.spanId,
);
assert.strictEqual(
firstSpan.name,
`${subId} subscribe`,
Expand Down
9 changes: 7 additions & 2 deletions handwritten/pubsub/test/telemetry-tracing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ describe('OpenTelemetryTracer', () => {
'receive',
);
assert.strictEqual(childReadSpan.kind, SpanKind.CONSUMER);
assert.ok(childReadSpan.parentSpanId);
assert.ok(childReadSpan.parentSpanContext?.spanId);
});

it('creates publish RPC spans', () => {
Expand All @@ -373,14 +373,19 @@ describe('OpenTelemetryTracer', () => {
'test',
) as trace.Span;
message.parentSpan = span;
span.end();

// The publish RPC span adds a back-link onto the parent span, so it must
// be created while the parent is still open. This mirrors the real
// publish flow (Queue._publish), where parent spans are ended only after
// the RPC span is created. In @opentelemetry/sdk-trace-base v2,
// `addLink()` on an already-ended span is a no-op.
const publishSpan = otel.PubsubSpans.createPublishRpcSpan(
[message],
topicName,
'test',
);

span.end();
publishSpan?.end();
const spans = exporter.getFinishedSpans();
const publishReadSpan = spans.pop();
Expand Down
10 changes: 7 additions & 3 deletions handwritten/pubsub/test/tracing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/

import {trace} from '@opentelemetry/api';
import {
BasicTracerProvider,
InMemorySpanExporter,
Expand All @@ -36,6 +37,9 @@ import {
* its defined beforehand.
*/
export const exporter: InMemorySpanExporter = new InMemorySpanExporter();
export const provider: BasicTracerProvider = new BasicTracerProvider();
provider.addSpanProcessor(new SimpleSpanProcessor(exporter));
provider.register();
export const provider: BasicTracerProvider = new BasicTracerProvider({
spanProcessors: [new SimpleSpanProcessor(exporter)],
});
// `BasicTracerProvider.register()` was removed in @opentelemetry/sdk-trace-base
// v2; register the provider as the global one via the API instead.
trace.setGlobalTracerProvider(provider);
Loading