Skip to content

Commit fa49f91

Browse files
committed
chore(instrumnetation-gprc): require manual invocation of buf when updating protos
1 parent b94bc86 commit fa49f91

File tree

9 files changed

+238
-46
lines changed

9 files changed

+238
-46
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: v1
22
plugins:
33
- plugin: buf.build/community/timostamm-protobuf-ts:v2.9.0
4-
out: ../../test/proto/ts/fixtures
4+
out: test/generated
55
opt:
66
- long_type_string
77
- generate_dependencies

experimental/packages/opentelemetry-instrumentation-grpc/package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,17 @@
77
"repository": "open-telemetry/opentelemetry-js",
88
"scripts": {
99
"prepublishOnly": "npm run compile",
10-
"precompile": "npm run protos:generate",
1110
"compile": "tsc --build",
1211
"clean": "tsc --build --clean",
13-
"test": "npm run protos:generate && nyc mocha test/**/*.test.ts",
12+
"test": "nyc mocha test/**/*.test.ts",
1413
"tdd": "npm run test -- --watch-extensions ts --watch",
1514
"lint": "eslint . --ext .ts",
1615
"lint:fix": "eslint . --ext .ts --fix",
1716
"version": "node ../../../scripts/version-update.js",
1817
"watch": "tsc --build --watch",
1918
"prewatch": "node ../../../scripts/version-update.js",
2019
"peer-api-check": "node ../../../scripts/peer-api-check.js",
21-
"protos:generate": "cd test/fixtures && buf generate",
20+
"re-generate-protos": "npx -y @bufbuild/buf@1.53.0 generate",
2221
"align-api-deps": "node ../../../scripts/align-api-deps.js"
2322
},
2423
"keywords": [
@@ -46,7 +45,6 @@
4645
"access": "public"
4746
},
4847
"devDependencies": {
49-
"@bufbuild/buf": "1.53.0",
5048
"@grpc/grpc-js": "^1.7.1",
5149
"@grpc/proto-loader": "^0.7.10",
5250
"@opentelemetry/api": "1.9.0",
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
/proto
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
// @generated by protobuf-ts 2.9.0 with parameter long_type_string,generate_dependencies,ts_nocheck
2+
// @generated from protobuf file "test/fixtures/grpc-test.proto" (package "pkg_test", syntax proto3)
3+
// tslint:disable
4+
// @ts-nocheck
5+
import type { RpcTransport } from "@protobuf-ts/runtime-rpc";
6+
import type { ServiceInfo } from "@protobuf-ts/runtime-rpc";
7+
import { GrpcTester } from "./grpc-test";
8+
import type { DuplexStreamingCall } from "@protobuf-ts/runtime-rpc";
9+
import type { ServerStreamingCall } from "@protobuf-ts/runtime-rpc";
10+
import type { ClientStreamingCall } from "@protobuf-ts/runtime-rpc";
11+
import { stackIntercept } from "@protobuf-ts/runtime-rpc";
12+
import type { TestReply } from "./grpc-test";
13+
import type { TestRequest } from "./grpc-test";
14+
import type { UnaryCall } from "@protobuf-ts/runtime-rpc";
15+
import type { RpcOptions } from "@protobuf-ts/runtime-rpc";
16+
/**
17+
* @generated from protobuf service pkg_test.GrpcTester
18+
*/
19+
export interface IGrpcTesterClient {
20+
/**
21+
* @generated from protobuf rpc: unaryMethodWithMetadata(pkg_test.TestRequest) returns (pkg_test.TestReply);
22+
*/
23+
unaryMethodWithMetadata(input: TestRequest, options?: RpcOptions): UnaryCall<TestRequest, TestReply>;
24+
/**
25+
* @generated from protobuf rpc: UnaryMethod(pkg_test.TestRequest) returns (pkg_test.TestReply);
26+
*/
27+
unaryMethod(input: TestRequest, options?: RpcOptions): UnaryCall<TestRequest, TestReply>;
28+
/**
29+
* @generated from protobuf rpc: camelCaseMethod(pkg_test.TestRequest) returns (pkg_test.TestReply);
30+
*/
31+
camelCaseMethod(input: TestRequest, options?: RpcOptions): UnaryCall<TestRequest, TestReply>;
32+
/**
33+
* @generated from protobuf rpc: ClientStreamMethod(stream pkg_test.TestRequest) returns (pkg_test.TestReply);
34+
*/
35+
clientStreamMethod(options?: RpcOptions): ClientStreamingCall<TestRequest, TestReply>;
36+
/**
37+
* @generated from protobuf rpc: ServerStreamMethod(pkg_test.TestRequest) returns (stream pkg_test.TestReply);
38+
*/
39+
serverStreamMethod(input: TestRequest, options?: RpcOptions): ServerStreamingCall<TestRequest, TestReply>;
40+
/**
41+
* @generated from protobuf rpc: BidiStreamMethod(stream pkg_test.TestRequest) returns (stream pkg_test.TestReply);
42+
*/
43+
bidiStreamMethod(options?: RpcOptions): DuplexStreamingCall<TestRequest, TestReply>;
44+
}
45+
/**
46+
* @generated from protobuf service pkg_test.GrpcTester
47+
*/
48+
export class GrpcTesterClient implements IGrpcTesterClient, ServiceInfo {
49+
typeName = GrpcTester.typeName;
50+
methods = GrpcTester.methods;
51+
options = GrpcTester.options;
52+
constructor(private readonly _transport: RpcTransport) {
53+
}
54+
/**
55+
* @generated from protobuf rpc: unaryMethodWithMetadata(pkg_test.TestRequest) returns (pkg_test.TestReply);
56+
*/
57+
unaryMethodWithMetadata(input: TestRequest, options?: RpcOptions): UnaryCall<TestRequest, TestReply> {
58+
const method = this.methods[0], opt = this._transport.mergeOptions(options);
59+
return stackIntercept<TestRequest, TestReply>("unary", this._transport, method, opt, input);
60+
}
61+
/**
62+
* @generated from protobuf rpc: UnaryMethod(pkg_test.TestRequest) returns (pkg_test.TestReply);
63+
*/
64+
unaryMethod(input: TestRequest, options?: RpcOptions): UnaryCall<TestRequest, TestReply> {
65+
const method = this.methods[1], opt = this._transport.mergeOptions(options);
66+
return stackIntercept<TestRequest, TestReply>("unary", this._transport, method, opt, input);
67+
}
68+
/**
69+
* @generated from protobuf rpc: camelCaseMethod(pkg_test.TestRequest) returns (pkg_test.TestReply);
70+
*/
71+
camelCaseMethod(input: TestRequest, options?: RpcOptions): UnaryCall<TestRequest, TestReply> {
72+
const method = this.methods[2], opt = this._transport.mergeOptions(options);
73+
return stackIntercept<TestRequest, TestReply>("unary", this._transport, method, opt, input);
74+
}
75+
/**
76+
* @generated from protobuf rpc: ClientStreamMethod(stream pkg_test.TestRequest) returns (pkg_test.TestReply);
77+
*/
78+
clientStreamMethod(options?: RpcOptions): ClientStreamingCall<TestRequest, TestReply> {
79+
const method = this.methods[3], opt = this._transport.mergeOptions(options);
80+
return stackIntercept<TestRequest, TestReply>("clientStreaming", this._transport, method, opt);
81+
}
82+
/**
83+
* @generated from protobuf rpc: ServerStreamMethod(pkg_test.TestRequest) returns (stream pkg_test.TestReply);
84+
*/
85+
serverStreamMethod(input: TestRequest, options?: RpcOptions): ServerStreamingCall<TestRequest, TestReply> {
86+
const method = this.methods[4], opt = this._transport.mergeOptions(options);
87+
return stackIntercept<TestRequest, TestReply>("serverStreaming", this._transport, method, opt, input);
88+
}
89+
/**
90+
* @generated from protobuf rpc: BidiStreamMethod(stream pkg_test.TestRequest) returns (stream pkg_test.TestReply);
91+
*/
92+
bidiStreamMethod(options?: RpcOptions): DuplexStreamingCall<TestRequest, TestReply> {
93+
const method = this.methods[5], opt = this._transport.mergeOptions(options);
94+
return stackIntercept<TestRequest, TestReply>("duplex", this._transport, method, opt);
95+
}
96+
}
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
// @generated by protobuf-ts 2.9.0 with parameter long_type_string,generate_dependencies,ts_nocheck
2+
// @generated from protobuf file "test/fixtures/grpc-test.proto" (package "pkg_test", syntax proto3)
3+
// tslint:disable
4+
// @ts-nocheck
5+
import { ServiceType } from "@protobuf-ts/runtime-rpc";
6+
import type { BinaryWriteOptions } from "@protobuf-ts/runtime";
7+
import type { IBinaryWriter } from "@protobuf-ts/runtime";
8+
import { WireType } from "@protobuf-ts/runtime";
9+
import type { BinaryReadOptions } from "@protobuf-ts/runtime";
10+
import type { IBinaryReader } from "@protobuf-ts/runtime";
11+
import { UnknownFieldHandler } from "@protobuf-ts/runtime";
12+
import type { PartialMessage } from "@protobuf-ts/runtime";
13+
import { reflectionMergePartial } from "@protobuf-ts/runtime";
14+
import { MESSAGE_TYPE } from "@protobuf-ts/runtime";
15+
import { MessageType } from "@protobuf-ts/runtime";
16+
/**
17+
* @generated from protobuf message pkg_test.TestRequest
18+
*/
19+
export interface TestRequest {
20+
/**
21+
* @generated from protobuf field: int32 num = 1;
22+
*/
23+
num: number;
24+
}
25+
/**
26+
* @generated from protobuf message pkg_test.TestReply
27+
*/
28+
export interface TestReply {
29+
/**
30+
* @generated from protobuf field: int32 num = 1;
31+
*/
32+
num: number;
33+
}
34+
// @generated message type with reflection information, may provide speed optimized methods
35+
class TestRequest$Type extends MessageType<TestRequest> {
36+
constructor() {
37+
super("pkg_test.TestRequest", [
38+
{ no: 1, name: "num", kind: "scalar", T: 5 /*ScalarType.INT32*/ }
39+
]);
40+
}
41+
create(value?: PartialMessage<TestRequest>): TestRequest {
42+
const message = { num: 0 };
43+
globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this });
44+
if (value !== undefined)
45+
reflectionMergePartial<TestRequest>(this, message, value);
46+
return message;
47+
}
48+
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: TestRequest): TestRequest {
49+
let message = target ?? this.create(), end = reader.pos + length;
50+
while (reader.pos < end) {
51+
let [fieldNo, wireType] = reader.tag();
52+
switch (fieldNo) {
53+
case /* int32 num */ 1:
54+
message.num = reader.int32();
55+
break;
56+
default:
57+
let u = options.readUnknownField;
58+
if (u === "throw")
59+
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
60+
let d = reader.skip(wireType);
61+
if (u !== false)
62+
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
63+
}
64+
}
65+
return message;
66+
}
67+
internalBinaryWrite(message: TestRequest, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
68+
/* int32 num = 1; */
69+
if (message.num !== 0)
70+
writer.tag(1, WireType.Varint).int32(message.num);
71+
let u = options.writeUnknownFields;
72+
if (u !== false)
73+
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
74+
return writer;
75+
}
76+
}
77+
/**
78+
* @generated MessageType for protobuf message pkg_test.TestRequest
79+
*/
80+
export const TestRequest = new TestRequest$Type();
81+
// @generated message type with reflection information, may provide speed optimized methods
82+
class TestReply$Type extends MessageType<TestReply> {
83+
constructor() {
84+
super("pkg_test.TestReply", [
85+
{ no: 1, name: "num", kind: "scalar", T: 5 /*ScalarType.INT32*/ }
86+
]);
87+
}
88+
create(value?: PartialMessage<TestReply>): TestReply {
89+
const message = { num: 0 };
90+
globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this });
91+
if (value !== undefined)
92+
reflectionMergePartial<TestReply>(this, message, value);
93+
return message;
94+
}
95+
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: TestReply): TestReply {
96+
let message = target ?? this.create(), end = reader.pos + length;
97+
while (reader.pos < end) {
98+
let [fieldNo, wireType] = reader.tag();
99+
switch (fieldNo) {
100+
case /* int32 num */ 1:
101+
message.num = reader.int32();
102+
break;
103+
default:
104+
let u = options.readUnknownField;
105+
if (u === "throw")
106+
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
107+
let d = reader.skip(wireType);
108+
if (u !== false)
109+
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
110+
}
111+
}
112+
return message;
113+
}
114+
internalBinaryWrite(message: TestReply, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
115+
/* int32 num = 1; */
116+
if (message.num !== 0)
117+
writer.tag(1, WireType.Varint).int32(message.num);
118+
let u = options.writeUnknownFields;
119+
if (u !== false)
120+
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
121+
return writer;
122+
}
123+
}
124+
/**
125+
* @generated MessageType for protobuf message pkg_test.TestReply
126+
*/
127+
export const TestReply = new TestReply$Type();
128+
/**
129+
* @generated ServiceType for protobuf service pkg_test.GrpcTester
130+
*/
131+
export const GrpcTester = new ServiceType("pkg_test.GrpcTester", [
132+
{ name: "unaryMethodWithMetadata", options: {}, I: TestRequest, O: TestReply },
133+
{ name: "UnaryMethod", options: {}, I: TestRequest, O: TestReply },
134+
{ name: "camelCaseMethod", options: {}, I: TestRequest, O: TestReply },
135+
{ name: "ClientStreamMethod", clientStreaming: true, options: {}, I: TestRequest, O: TestReply },
136+
{ name: "ServerStreamMethod", serverStreaming: true, options: {}, I: TestRequest, O: TestReply },
137+
{ name: "BidiStreamMethod", serverStreaming: true, clientStreaming: true, options: {}, I: TestRequest, O: TestReply }
138+
]);

experimental/packages/opentelemetry-instrumentation-grpc/test/grpc-protobuf-ts.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ instrumentation.disable();
2121

2222
import { GrpcTransport } from '@protobuf-ts/grpc-transport';
2323
import * as grpc from '@grpc/grpc-js';
24-
import { GrpcTesterClient } from './proto/ts/fixtures/grpc-test.client';
24+
import { GrpcTesterClient } from './generated/test/fixtures/grpc-test.client';
2525
import {
2626
InMemorySpanExporter,
2727
NodeTracerProvider,

package-lock.json

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

0 commit comments

Comments
 (0)