Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Introduce interfaces for metrics instrumentation #2403

Merged
merged 31 commits into from Jan 22, 2024
Merged

Conversation

blakeli0
Copy link
Collaborator

@blakeli0 blakeli0 commented Jan 19, 2024

This PR introduces new public interfaces and refactors existing interfaces for metrics instrumentation. All the interfaces are framework-agnostic. Subsequent PRs should implement interfaces with an observability framework. For example, introduce an OpenTelemetryMetricsRecorder that implements MetricsRecorder. All new methods are created with Javadocs, they are expected to be updated in the implementation PR if needed.

See go/java-gapic-otel-metrics-design for details.

@product-auto-label product-auto-label bot added the size: m Pull request size is medium. label Jan 19, 2024
@product-auto-label product-auto-label bot added size: l Pull request size is large. and removed size: m Pull request size is medium. labels Jan 20, 2024
@blakeli0 blakeli0 changed the title feat: Otel foundation feat: Introduce interfaces for metrics instrumentation Jan 22, 2024
@blakeli0 blakeli0 marked this pull request as ready for review January 22, 2024 17:58
@blakeli0 blakeli0 requested a review from a team as a code owner January 22, 2024 17:58
* Creates a new instance of the RPC method name.
*
* @param serviceName The name of the service. In general this will be GAPIC generated service
* name {@link StubSettings#getServiceName()}. However, in some cases, when the GAPIC
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@blakeli0 I am now having some second thoughts on the serviceName() getter's name. I think there might be some slight discrepancy between the intended result and the function name.

getServiceName() returns the name that was configured in the default_host. For example, asset's will return cloudasset: https://github.com/googleapis/google-cloud-java/blob/9785f8cfd43db0a8968f086a1461242da9d16cb5/java-asset/google-cloud-asset/src/main/java/com/google/cloud/asset/v1/stub/AssetServiceStubSettings.java#L866-L868

even though the intended result for this probably should be asset.

Not something blocking this PR, but just wondering your thoughts on this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lqiu96 why should the intended name be asset ?
@blakeli0 Is there any way we could test this? that for a particular service, this is the intented serviceName ?

Copy link
Contributor

@lqiu96 lqiu96 Jan 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lqiu96 why should the intended name be asset ? @blakeli0 Is there any way we could test this? that for a particular service, this is the intented serviceName ?

I don't want to say what the intended name should be. I think it might be a bit weird for customers since we probably aren't providing consistent service names.

java-asset's serviceName is cloudasset (link above)
java-biglake's serviceName is biglake (https://github.com/googleapis/google-cloud-java/blob/458516b462e0a4494f32815fe9d0e6f0b30353f1/java-biglake/google-cloud-biglake/src/main/java/com/google/cloud/bigquery/biglake/v1/stub/MetastoreServiceStubSettings.java#L409-L411)

I think most services would have the service name of java-{serviceName} except for asset and possibly a few others.

It might not be a big concern after all, but something just doesn't sit right with me knowing that serviceName is parsed from a URI (default_host value) and not the package name or some config value (name_pretty or api name).

Copy link
Contributor

@ddixit14 ddixit14 Jan 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I spent sometime while working on the dashboard on service names, and they are not of the type "java-{serviceName}". See column A in this sheet. In the dashboard too, we are deriving the service name from the default_host value.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, your link doesn't work for me. Seems like there is no defined serviceName and we've somehow settled on the same definition 😆

Not blocking this PR, but it would be great if there was an official definition for serviceName. Perhaps a question for the core team.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lqiu96 I think the term serviceName you introduced still makes sense, because we call the yaml and json config for each versioned protos service yaml and service config respectively. we may want to add more docs to explain that it is used for constructing service endpoints.
@ddixit14 I would call java-{serviceName} a library name or repo name, as it could includes multiple versioned services or admin services.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, to wrap up the conversation above: I'll add some additional docs clarifying the intended use case (constructing the endpoint) and how the this value is constructed (from the config files).

It is fine that serviceName in the library (pulled from getServiceName()) doesn't 100% match java-{serviceName}.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is fine that serviceName in the library (pulled from getServiceName()) doesn't 100% match java-{serviceName}.

Correct. The library/repo name may not always be in the format of java-{serviceName} and I would not refer java-{serviceName} as the format for library/repo name.

Copy link

sonarcloud bot commented Jan 22, 2024

Quality Gate Failed Quality Gate failed for 'gapic-generator-java-root'

Failed conditions

8.6% Coverage on New Code (required ≥ 80%)

See analysis details on SonarCloud

Copy link

sonarcloud bot commented Jan 22, 2024

Quality Gate Failed Quality Gate failed for 'java_showcase_integration_tests'

Failed conditions

2.6% Coverage on New Code (required ≥ 80%)

See analysis details on SonarCloud

@blakeli0 blakeli0 merged commit 3c61b14 into main Jan 22, 2024
37 of 39 checks passed
@blakeli0 blakeli0 deleted the otel-foundation branch January 22, 2024 23:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: l Pull request size is large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants