-
Notifications
You must be signed in to change notification settings - Fork 651
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add performance tests for b3 propagator
- Loading branch information
1 parent
6e5d7f1
commit 0afd9ba
Showing
2 changed files
with
44 additions
and
2 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
opentelemetry-sdk/benchmarks/trace/propagation/test_benchmark_b3_format.py
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,42 @@ | ||
# Copyright The OpenTelemetry Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from unittest import mock | ||
|
||
import opentelemetry.sdk.trace as trace | ||
import opentelemetry.sdk.trace.propagation.b3_format as b3_format | ||
from opentelemetry.trace.propagation.textmap import DictGetter | ||
|
||
FORMAT = b3_format.B3Format() | ||
|
||
|
||
@mock.patch( | ||
"opentelemetry.sdk.trace.propagation.b3_format.trace.get_tracer_provider", | ||
new=trace.TracerProvider, | ||
) | ||
def test_extract_single_header(benchmark): | ||
benchmark( | ||
FORMAT.extract, | ||
DictGetter(), | ||
{ | ||
FORMAT.SINGLE_HEADER_KEY: "bdb5b63237ed38aea578af665aa5aa60-00000000000000000c32d953d73ad225" | ||
}, | ||
) | ||
|
||
|
||
def test_inject_empty_context(benchmark): | ||
tracer = trace.TracerProvider().get_tracer("sdk_tracer_provider") | ||
with tracer.start_as_current_span("parent"): | ||
with tracer.start_as_current_span("child"): | ||
benchmark(FORMAT.inject, dict.__setitem__, {}) |
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