-
Notifications
You must be signed in to change notification settings - Fork 67
feat: Introducing OpentelemetryMetricsRecorder #2433
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
Closed
Closed
Changes from 35 commits
Commits
Show all changes
79 commits
Select commit
Hold shift + click to select a range
fab2ce0
feat: OpentelemetryMetricsRecorder Implementation
ddixit14 1fc2e9a
chore: showcase test setup
ddixit14 b08e849
chore: setup otel collector
ddixit14 bfcfb87
chore: fix
ddixit14 254fb38
chore: lint error
ddixit14 db4f772
chore: lint error
ddixit14 1772d42
chore: ignore linter for now
ddixit14 93b744f
chore: test setup
ddixit14 fb7fd5d
otel-collector-setup
ddixit14 166fc61
chore: fix lint
ddixit14 3fcdd5d
chore: fix
ddixit14 d908c28
chore: otel install
ddixit14 0382056
chore: otel install
ddixit14 4a8cdc9
chore: otel-setup
ddixit14 27f308b
chore: run-otel-background
ddixit14 e877bcf
cleanup
ddixit14 cfde7f6
chore: run test on gha
ddixit14 c4f3547
chore: lint
ddixit14 1b80dfa
chore: fix lint
ddixit14 0f7b6dd
lint
ddixit14 3217611
chore: test if logs exist
ddixit14 36f7cd3
chore: let's see if 2 tests run ok
ddixit14 beb91f1
chore: let's see if 2 tests run ok
ddixit14 5a33a4f
chore: will this work?
ddixit14 ae99154
chore: run 3 tests together
ddixit14 52f5abe
adding all tests
ddixit14 fb3757f
fix lint
ddixit14 de437c1
chore: fix time
ddixit14 6024d4d
refactoring tests + adding verify logic for metrics
ddixit14 a9c003a
chore: work on comments
ddixit14 759d0da
Merge branch 'main' into otel-MR-ddixit
ddixit14 a0d6856
comments
ddixit14 03d3159
Merge branch 'otel-MR-ddixit' of github.com:googleapis/sdk-platform-j…
ddixit14 1e8a82a
chore: parallel run
ddixit14 a281fc2
remove all yamls
ddixit14 b3ba6b9
using in-memory reader
ddixit14 61128ff
Merge branch 'main' into otel-MR-ddixit
ddixit14 494d53e
feat: autopopulate fields in the request (#2353)
alicejli 8f28fff
chore(main): release 2.34.0 (#2417)
release-please[bot] 09c1c72
chore(main): release 2.34.1-SNAPSHOT (#2434)
release-please[bot] bc8e285
test: increase timeout testCancelOuterFutureAfterStart to 60s (#2437)
suztomo b4c9659
chore: change header year (#2438)
JoeWang1127 58d2cc3
test: fix flakes in HttpJsonDirectServerStreamingCallableTest (#2432)
meltsufin 1a34a99
chore: Update showcase protos (#2445)
lqiu96 7716446
test: fix flaky HttpJsonDirectServerStreamingCallableTest.testOnRespo…
meltsufin aae5f09
feat: add `generate_repo.py` (#2431)
JoeWang1127 00be453
chore: add `setup.py` for `library_generation` (#2447)
diegomarquezp cac115e
chore: format python code (#2452)
JoeWang1127 cef5002
chore: update instructions on `generate_repo.py` (#2449)
JoeWang1127 edfa9ad
feat: move synthtool templates to `library_generation/owlbot` (#2443)
diegomarquezp 6c0aae0
chore: update dev guide to get version of gapic-showcase to install. …
zhumin8 903c1f6
chore: refactor golden tests for autopopulation feature (#2446)
alicejli fc84ee9
chore: use template excludes in generation config (#2453)
JoeWang1127 dc4039a
fix: Apiary Host returns user set host if set (#2455)
lqiu96 2e50f2a
chore: remove beta api annotation from client header customization su…
diegomarquezp 45a8e50
chore: parallel run
ddixit14 62d1670
remove all yamls
ddixit14 d5c99a1
using in-memory reader
ddixit14 8b0bd4e
deps: update grpc dependencies to v1.61.1 (#2463)
renovate-bot a3d3345
chore: [common-protos,common-protos] set packed = false on field_beha…
gcf-owl-bot[bot] 47b6ed7
deps: update google auth library dependencies to v1.23.0 (#2466)
renovate-bot 9ec415c
chore: [iam,iam] set packed = false on field_behavior extension (#2435)
gcf-owl-bot[bot] 68666e7
deps: update google http client dependencies to v1.44.1 (#2467)
renovate-bot 119fba8
chore: remove unused files from showcase. (#2464)
zhumin8 2ac2e4b
deps: update google api dependencies (#2469)
renovate-bot 4920536
chore: move owlbot requirements to library_generation/reqs.in (#2471)
diegomarquezp e6cb020
chore: add opentelemery to shared dependencies (#2456)
JoeWang1127 c66bc55
deps: update dependency commons-codec:commons-codec to v1.16.1 (#2473)
renovate-bot 93fefb0
deps: update google auth library dependencies to v1.23.0 (#2476)
renovate-bot 5a60665
fix: Cancel the Timeout Task for HttpJson (#2360)
lqiu96 54b798b
deps: update googleapis/java-cloud-bom digest to ac9893c (#2472)
renovate-bot a9b73c3
chore(main): release 2.35.0 (#2448)
release-please[bot] cd9e69b
chore(main): release 2.35.1-SNAPSHOT (#2482)
release-please[bot] 5dd96f1
chore: add library params (#2457)
JoeWang1127 402f32c
chore: fix workflow to create additional tags (#2487)
JoeWang1127 01c0dc2
chore: remove beta httpjson (#2358)
JoeWang1127 f206c89
Merge branch 'otel-MR-ddixit' of github.com:googleapis/sdk-platform-j…
ddixit14 643733a
chore: cleanup
ddixit14 f3df697
chore: cleanup
ddixit14 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
gax-java/gax/src/main/java/com/google/api/gax/tracing/OpentelemetryMetricsRecorder.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
/* | ||
* Copyright 2024 Google LLC | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are | ||
* met: | ||
* | ||
* * Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* * Redistributions in binary form must reproduce the above | ||
* copyright notice, this list of conditions and the following disclaimer | ||
* in the documentation and/or other materials provided with the | ||
* distribution. | ||
* * Neither the name of Google LLC nor the names of its | ||
* contributors may be used to endorse or promote products derived from | ||
* this software without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
package com.google.api.gax.tracing; | ||
|
||
import com.google.common.annotations.VisibleForTesting; | ||
import io.opentelemetry.api.common.Attributes; | ||
import io.opentelemetry.api.common.AttributesBuilder; | ||
import io.opentelemetry.api.metrics.DoubleHistogram; | ||
import io.opentelemetry.api.metrics.LongCounter; | ||
import io.opentelemetry.api.metrics.Meter; | ||
import java.util.Map; | ||
|
||
public class OpentelemetryMetricsRecorder implements MetricsRecorder { | ||
|
||
private Meter meter; | ||
|
||
private DoubleHistogram attemptLatencyRecorder; | ||
|
||
private DoubleHistogram operationLatencyRecorder; | ||
|
||
private LongCounter operationCountRecorder; | ||
|
||
private LongCounter attemptCountRecorder; | ||
|
||
public OpentelemetryMetricsRecorder(Meter meter) { | ||
this.meter = meter; | ||
this.attemptLatencyRecorder = | ||
meter | ||
.histogramBuilder("attempt_latency") | ||
ddixit14 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
.setDescription("Duration of an individual attempt") | ||
.setUnit("ms") | ||
.build(); | ||
this.operationLatencyRecorder = | ||
meter | ||
.histogramBuilder("operation_latency") | ||
.setDescription( | ||
"Total time until final operation success or failure, including retries and backoff.") | ||
.setUnit("ms") | ||
.build(); | ||
this.operationCountRecorder = | ||
meter | ||
.counterBuilder("operation_count") | ||
.setDescription("Count of Operations") | ||
.setUnit("1") | ||
.build(); | ||
this.attemptCountRecorder = | ||
meter | ||
.counterBuilder("attempt_count") | ||
.setDescription("Count of Attempts") | ||
.setUnit("1") | ||
.build(); | ||
} | ||
|
||
public void recordAttemptLatency(double attemptLatency, Map<String, String> attributes) { | ||
attemptLatencyRecorder.record(attemptLatency, toOtelAttributes(attributes)); | ||
} | ||
|
||
public void recordAttemptCount(long count, Map<String, String> attributes) { | ||
attemptCountRecorder.add(count, toOtelAttributes(attributes)); | ||
} | ||
|
||
public void recordOperationLatency(double operationLatency, Map<String, String> attributes) { | ||
operationLatencyRecorder.record(operationLatency, toOtelAttributes(attributes)); | ||
} | ||
|
||
public void recordOperationCount(long count, Map<String, String> attributes) { | ||
operationCountRecorder.add(count, toOtelAttributes(attributes)); | ||
} | ||
|
||
@VisibleForTesting | ||
Attributes toOtelAttributes(Map<String, String> attributes) { | ||
|
||
if (attributes == null) { | ||
blakeli0 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
throw new IllegalArgumentException("Input attributes map cannot be null"); | ||
} | ||
|
||
AttributesBuilder attributesBuilder = Attributes.builder(); | ||
attributes.forEach(attributesBuilder::put); | ||
return attributesBuilder.build(); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.