-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Internalize opentelemetry-exporter-otlp-proto-common adapter code (#43)
- Loading branch information
1 parent
1f5f4a8
commit 196413d
Showing
25 changed files
with
1,503 additions
and
29 deletions.
There are no files selected for viewing
This file contains 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,32 @@ | ||
# This workflow will delete and regenerate the opentelemetry-exporter-otlp-proto-common code using scripts/vendor_otlp_proto_common.sh. | ||
# If generating the code produces any changes from what is currently checked in, the workflow will fail and prompt the user to regenerate the code. | ||
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions | ||
|
||
name: Check OTLP Proto Common Vendored Code | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
paths: | ||
- "scripts/vendor_otlp_proto_common.sh" | ||
- "src/snowflake/telemetry/_internal/opentelemetry/exporter/**" | ||
- ".github/workflows/check-vendor.yml" | ||
pull_request: | ||
branches: [ "main" ] | ||
paths: | ||
- "scripts/vendor_otlp_proto_common.sh" | ||
- "src/snowflake/telemetry/_internal/opentelemetry/exporter/**" | ||
- ".github/workflows/check-vendor.yml" | ||
|
||
jobs: | ||
check-codegen: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Run vendor script | ||
run: | | ||
rm -rf src/snowflake/telemetry/_internal/opentelemetry/exporter/ | ||
./scripts/vendor_otlp_proto_common.sh | ||
- name: Check for changes | ||
run: | | ||
git diff --exit-code || { echo "Code generation produced changes! Regenerate the code using ./scripts/vendor_otlp_proto_common.sh"; exit 1; } |
This file contains 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 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 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,86 @@ | ||
import google_benchmark as benchmark | ||
|
||
from util import get_logs_data, get_metrics_data, get_traces_data, get_logs_data_4MB | ||
|
||
from snowflake.telemetry._internal.opentelemetry.exporter.otlp.proto.common._log_encoder import encode_logs | ||
from snowflake.telemetry._internal.opentelemetry.exporter.otlp.proto.common.metrics_encoder import encode_metrics | ||
from snowflake.telemetry._internal.opentelemetry.exporter.otlp.proto.common.trace_encoder import encode_spans | ||
|
||
from opentelemetry.exporter.otlp.proto.common._log_encoder import encode_logs as pb2_encode_logs | ||
from opentelemetry.exporter.otlp.proto.common.metrics_encoder import encode_metrics as pb2_encode_metrics | ||
from opentelemetry.exporter.otlp.proto.common.trace_encoder import encode_spans as pb2_encode_spans | ||
|
||
""" | ||
------------------------------------------------------------------------------ | ||
Benchmark Time CPU Iterations | ||
------------------------------------------------------------------------------ | ||
test_bm_serialize_logs_data_4MB 730591536 ns 730562298 ns 1 | ||
test_bm_pb2_serialize_logs_data_4MB 702522039 ns 702490893 ns 1 | ||
test_bm_serialize_logs_data 100882 ns 100878 ns 6930 | ||
test_bm_pb2_serialize_logs_data 97112 ns 97109 ns 7195 | ||
test_bm_serialize_metrics_data 114938 ns 114934 ns 6096 | ||
test_bm_pb2_serialize_metrics_data 161849 ns 161845 ns 4324 | ||
test_bm_serialize_traces_data 123977 ns 123973 ns 5633 | ||
test_bm_pb2_serialize_traces_data 131016 ns 131011 ns 5314 | ||
""" | ||
|
||
def sanity_check(): | ||
logs_data = get_logs_data() | ||
metrics_data = get_metrics_data() | ||
traces_data = get_traces_data() | ||
|
||
assert encode_logs(logs_data).SerializeToString() == pb2_encode_logs(logs_data).SerializeToString() | ||
assert encode_metrics(metrics_data).SerializeToString() == pb2_encode_metrics(metrics_data).SerializeToString() | ||
assert encode_spans(traces_data).SerializeToString() == pb2_encode_spans(traces_data).SerializeToString() | ||
|
||
@benchmark.register | ||
def test_bm_serialize_logs_data_4MB(state): | ||
logs_data = get_logs_data_4MB() | ||
while state: | ||
encode_logs(logs_data).SerializeToString() | ||
|
||
@benchmark.register | ||
def test_bm_pb2_serialize_logs_data_4MB(state): | ||
logs_data = get_logs_data_4MB() | ||
while state: | ||
pb2_encode_logs(logs_data).SerializeToString() | ||
|
||
@benchmark.register | ||
def test_bm_serialize_logs_data(state): | ||
logs_data = get_logs_data() | ||
while state: | ||
encode_logs(logs_data).SerializeToString() | ||
|
||
@benchmark.register | ||
def test_bm_pb2_serialize_logs_data(state): | ||
logs_data = get_logs_data() | ||
while state: | ||
pb2_encode_logs(logs_data).SerializeToString() | ||
|
||
@benchmark.register | ||
def test_bm_serialize_metrics_data(state): | ||
metrics_data = get_metrics_data() | ||
while state: | ||
encode_metrics(metrics_data).SerializeToString() | ||
|
||
@benchmark.register | ||
def test_bm_pb2_serialize_metrics_data(state): | ||
metrics_data = get_metrics_data() | ||
while state: | ||
pb2_encode_metrics(metrics_data).SerializeToString() | ||
|
||
@benchmark.register | ||
def test_bm_serialize_traces_data(state): | ||
traces_data = get_traces_data() | ||
while state: | ||
encode_spans(traces_data).SerializeToString() | ||
|
||
@benchmark.register | ||
def test_bm_pb2_serialize_traces_data(state): | ||
traces_data = get_traces_data() | ||
while state: | ||
pb2_encode_spans(traces_data).SerializeToString() | ||
|
||
if __name__ == "__main__": | ||
sanity_check() | ||
benchmark.main() |
Oops, something went wrong.