Skip to content

Commit ad894b1

Browse files
authored
Update some docs (open-telemetry#1553)
1 parent f433bc7 commit ad894b1

File tree

9 files changed

+56
-12
lines changed

9 files changed

+56
-12
lines changed

docs/examples/basic_tracer/basic_trace.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# Copyright The OpenTelemetry Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
115
from opentelemetry import trace
216
from opentelemetry.sdk.trace import TracerProvider
317
from opentelemetry.sdk.trace.export import (

docs/examples/basic_tracer/resources.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# Copyright The OpenTelemetry Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
115
from opentelemetry import trace
216
from opentelemetry.sdk.resources import Resource
317
from opentelemetry.sdk.trace import TracerProvider

opentelemetry-api/src/opentelemetry/baggage/propagation/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222

2323

2424
class BaggagePropagator(textmap.TextMapPropagator):
25+
"""Extracts and injects Baggage which is used to annotate telemetry.
26+
"""
27+
2528
MAX_HEADER_LENGTH = 8192
2629
MAX_PAIR_LENGTH = 4096
2730
MAX_PAIRS = 180

opentelemetry-api/src/opentelemetry/trace/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,8 @@ def start_as_current_span(
338338
be automatically set to ERROR when an uncaught exception is
339339
raised in the span with block. The span status won't be set by
340340
this mechanism if it was previously set manually.
341+
end_on_exit: Whether to end the span automatically when leaving the
342+
context manager.
341343
342344
Yields:
343345
The newly-created span.
@@ -423,7 +425,7 @@ def get_tracer(
423425
This function is a convenience wrapper for
424426
opentelemetry.trace.TracerProvider.get_tracer.
425427
426-
If tracer_provider is ommited the current configured one is used.
428+
If tracer_provider is omitted the current configured one is used.
427429
"""
428430
if tracer_provider is None:
429431
tracer_provider = get_tracer_provider()

opentelemetry-api/src/opentelemetry/trace/propagation/textmap.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,15 @@
2525

2626
class Getter(typing.Generic[TextMapPropagatorT]):
2727
"""This class implements a Getter that enables extracting propagated
28-
fields from a carrier
29-
28+
fields from a carrier.
3029
"""
3130

3231
def get(
3332
self, carrier: TextMapPropagatorT, key: str
3433
) -> typing.Optional[typing.List[str]]:
3534
"""Function that can retrieve zero
3635
or more values from the carrier. In the case that
37-
the value does not exist, returns an empty list.
36+
the value does not exist, returns None.
3837
3938
Args:
4039
carrier: An object which contains values that are used to
@@ -61,6 +60,14 @@ class DictGetter(Getter[typing.Dict[str, CarrierValT]]):
6160
def get(
6261
self, carrier: typing.Dict[str, CarrierValT], key: str
6362
) -> typing.Optional[typing.List[str]]:
63+
"""Getter implementation to retrieve a value from a dictionary.
64+
65+
Args:
66+
carrier: dictionary in which header
67+
key: the key used to get the value
68+
Returns:
69+
A list with a single string with the value if it exists, else None.
70+
"""
6471
val = carrier.get(key, None)
6572
if val is None:
6673
return None
@@ -69,6 +76,7 @@ def get(
6976
return [val]
7077

7178
def keys(self, carrier: typing.Dict[str, CarrierValT]) -> typing.List[str]:
79+
"""Keys implementation that returns all keys from a dictionary."""
7280
return list(carrier.keys())
7381

7482

opentelemetry-api/src/opentelemetry/trace/span.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,9 +360,9 @@ class SpanContext(
360360
Args:
361361
trace_id: The ID of the trace that this span belongs to.
362362
span_id: This span's ID.
363+
is_remote: True if propagated from a remote parent.
363364
trace_flags: Trace options to propagate.
364365
trace_state: Tracing-system-specific info to propagate.
365-
is_remote: True if propagated from a remote parent.
366366
"""
367367

368368
def __new__(

opentelemetry-sdk/src/opentelemetry/sdk/resources/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@
3232
3333
.. code-block:: python
3434
35-
metrics.set_meter_provider(
36-
MeterProvider(
35+
trace.set_tracer_provider(
36+
TracerProvider(
3737
resource=Resource.create({
3838
"service.name": "shoppingcart",
3939
"service.instance.id": "instance-12",
4040
}),
4141
),
4242
)
43-
print(metrics.get_meter_provider().resource.attributes)
43+
print(trace.get_tracer_provider().resource.attributes)
4444
4545
{'telemetry.sdk.language': 'python',
4646
'telemetry.sdk.name': 'opentelemetry',

opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,8 +427,8 @@ def __init__(
427427
sampler: Optional[sampling.Sampler] = None,
428428
trace_config: None = None, # TODO
429429
resource: Resource = Resource.create({}),
430-
attributes: types.Attributes = None, # TODO
431-
events: Sequence[Event] = None, # TODO
430+
attributes: types.Attributes = None,
431+
events: Sequence[Event] = None,
432432
links: Sequence[trace_api.Link] = (),
433433
kind: trace_api.SpanKind = trace_api.SpanKind.INTERNAL,
434434
span_processor: SpanProcessor = SpanProcessor(),
@@ -899,6 +899,9 @@ def use_span(
899899

900900

901901
class TracerProvider(trace_api.TracerProvider):
902+
"""See `opentelemetry.trace.TracerProvider`.
903+
"""
904+
902905
def __init__(
903906
self,
904907
sampler: sampling.Sampler = TRACE_SAMPLER,

opentelemetry-sdk/src/opentelemetry/sdk/trace/export/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ class SpanExportResult(Enum):
3838
class SpanExporter:
3939
"""Interface for exporting spans.
4040
41-
Interface to be implemented by services that want to export recorded in
42-
its own format.
41+
Interface to be implemented by services that want to export spans recorded
42+
in their own format.
4343
4444
To export data this MUST be registered to the :class`opentelemetry.sdk.trace.Tracer` using a
4545
`SimpleExportSpanProcessor` or a `BatchExportSpanProcessor`.

0 commit comments

Comments
 (0)