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
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export class Generator {
restNumericEnums?: boolean;
mixinsOverride?: string[];
format?: string | string[];
enableTelemetryTracing?: boolean;

private root: protobuf.Root;

Expand Down Expand Up @@ -227,6 +228,12 @@ export class Generator {
}
}

private readEnableTelemetryTracing() {
if (this.paramMap['enable-telemetry-tracing'] === 'true') {
this.enableTelemetryTracing = true;
}
}
Comment thread
shivanee-p marked this conversation as resolved.

private readLegacyProtoLoad() {
if (this.paramMap['legacy-proto-load'] === 'true') {
this.legacyProtoLoad = true;
Expand Down Expand Up @@ -274,6 +281,7 @@ export class Generator {
this.readLegacyProtoLoad();
this.readRestNumericEnums();
this.readFormat();
this.readEnableTelemetryTracing();
}
}

Expand Down Expand Up @@ -334,6 +342,7 @@ export class Generator {
legacyProtoLoad: this.legacyProtoLoad,
restNumericEnums: this.restNumericEnums,
mixinsOverridden: this.mixinsOverride !== undefined,
enableTelemetryTracing: this.enableTelemetryTracing,
});
return api;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export class API {
restNumericEnums: boolean;
documentationUri: any;
newIssueUri: string;
enableTelemetryTracing?: boolean;
title?: string;

static isIgnoredService(
Expand Down Expand Up @@ -112,6 +113,7 @@ export class API {
this.documentationUri =
options.serviceYaml?.publishing?.documentation_uri ?? '';
this.newIssueUri = options.serviceYaml?.publishing?.new_issue_uri ?? '';
this.enableTelemetryTracing = options.enableTelemetryTracing ?? false;
this.title = options.serviceYaml?.title;

const [allResourceDatabase, resourceDatabase] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export interface Options {
legacyProtoLoad?: boolean;
restNumericEnums?: boolean;
mixinsOverridden?: boolean;
enableTelemetryTracing?: boolean;
}

export class Naming {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,4 +325,25 @@ describe('src/schema/api.ts', () => {
assert('.google.cloud.example.v1.MessageB' in secondCallMessages);
});
});

it('should set enableTelemetryTracing option', () => {
const fd = {} as protos.google.protobuf.FileDescriptorProto;
fd.name = 'google/cloud/test/v1/test.proto';
fd.package = 'google.cloud.test.v1';
fd.service = [{} as protos.google.protobuf.ServiceDescriptorProto];
fd.service[0].name = 'ZService';
fd.service[0].options = {
'.google.api.defaultHost': 'hostname.example.com:443',
};
const apiWithTracing = new API([fd], 'google.cloud.test.v1', {
grpcServiceConfig: {} as protos.grpc.service_config.ServiceConfig,
enableTelemetryTracing: true,
});
assert.strictEqual(apiWithTracing.enableTelemetryTracing, true);

const apiWithoutTracing = new API([fd], 'google.cloud.test.v1', {
grpcServiceConfig: {} as protos.grpc.service_config.ServiceConfig,
});
assert.strictEqual(apiWithoutTracing.enableTelemetryTracing, false);
});
});
Loading
Loading