Skip to content

Commit d1a0ef2

Browse files
committed
Merge remote-tracking branch 'original/master'
2 parents 0b78cfe + 2bc7d35 commit d1a0ef2

File tree

500 files changed

+3330
-2218
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

500 files changed

+3330
-2218
lines changed

README.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,19 @@ pip install opentelemetry-sdk
6363
```
6464

6565
The
66-
[`ext/`](https://github.com/open-telemetry/opentelemetry-python/tree/master/ext)
67-
directory includes OpenTelemetry integration packages, which can be installed
68-
separately as:
66+
[`instrumentation/`](https://github.com/open-telemetry/opentelemetry-python/tree/master/instrumentation)
67+
directory includes OpenTelemetry instrumentation packages, which can be installed separately as:
6968

7069
```sh
71-
pip install opentelemetry-ext-{integration}
70+
pip install opentelemetry-instrumentation-{instrumentation}
71+
```
72+
73+
The
74+
[`exporter/`](https://github.com/open-telemetry/opentelemetry-python/tree/master/exporter)
75+
directory includes OpenTelemetry exporter packages, which can be installed separately as:
76+
77+
```sh
78+
pip install opentelemetry-exporter-{exporter}
7279
```
7380

7481
To install the development versions of these packages instead, clone or fork
@@ -78,7 +85,7 @@ install](https://pip.pypa.io/en/stable/reference/pip_install/#editable-installs)
7885
```sh
7986
pip install -e ./opentelemetry-api
8087
pip install -e ./opentelemetry-sdk
81-
pip install -e ./ext/opentelemetry-ext-{integration}
88+
pip install -e ./ext/opentelemetry-instrumentation-{instrumentation}
8289
```
8390

8491
## Documentation

docs-requirements.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ asyncpg>=0.12.0
88
ddtrace>=0.34.0
99
aiohttp~= 3.0
1010
aiopg>=0.13.0
11+
grpcio~=1.27
1112
Deprecated>=1.2.6
1213
django>=2.2
1314
PyMySQL~=0.9.3
@@ -29,5 +30,3 @@ boto~=2.0
2930
botocore~=1.0
3031
starlette~=0.13
3132
fastapi~=0.58.1
32-
opentelemetry-exporter-cloud-trace==0.10b0
33-
opentelemetry-exporter-cloud-monitoring==0.10b0

docs/conf.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,14 @@
3737
if isdir(join(exp, f))
3838
]
3939

40-
ext = "../ext"
41-
ext_dirs = [
42-
os.path.abspath("/".join(["../ext", f, "src"]))
43-
for f in listdir(ext)
44-
if isdir(join(ext, f))
40+
instr = "../instrumentation"
41+
instr_dirs = [
42+
os.path.abspath("/".join(["../instrumentation", f, "src"]))
43+
for f in listdir(instr)
44+
if isdir(join(instr, f))
4545
]
46-
sys.path[:0] = source_dirs + exp_dirs + ext_dirs
46+
47+
sys.path[:0] = source_dirs + exp_dirs + instr_dirs
4748

4849
# -- Project information -----------------------------------------------------
4950

docs/examples/auto-instrumentation/README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Installation
7373
7474
$ pip install opentelemetry-sdk
7575
$ pip install opentelemetry-instrumentation
76-
$ pip install opentelemetry-ext-flask
76+
$ pip install opentelemetry-instrumentation-flask
7777
$ pip install requests
7878
7979
Execution

docs/examples/auto-instrumentation/server_instrumented.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from flask import Flask, request
1616

1717
from opentelemetry import propagators, trace
18-
from opentelemetry.ext.wsgi import collect_request_attributes
18+
from opentelemetry.instrumentation.wsgi import collect_request_attributes
1919
from opentelemetry.sdk.trace import TracerProvider
2020
from opentelemetry.sdk.trace.export import (
2121
ConsoleSpanExporter,

docs/examples/basic_meter/basic_metrics.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
- How to configure a meter passing a sateful or stateless.
2020
- How to configure an exporter and how to create a controller.
2121
- How to create some metrics intruments and how to capture data with them.
22+
- How to use views to specify aggregation types for each metric instrument.
2223
"""
2324
import sys
2425
import time
@@ -57,7 +58,6 @@
5758
unit="1",
5859
value_type=int,
5960
metric_type=Counter,
60-
label_keys=("environment",),
6161
)
6262

6363
requests_size = meter.create_metric(
@@ -66,7 +66,6 @@
6666
unit="1",
6767
value_type=int,
6868
metric_type=ValueRecorder,
69-
label_keys=("environment",),
7069
)
7170

7271
# Labels are used to identify key-values that are associated with a specific
@@ -86,4 +85,5 @@
8685

8786
requests_counter.add(35, testing_labels)
8887
requests_size.record(2, testing_labels)
89-
time.sleep(5)
88+
89+
input("...\n")

docs/examples/basic_meter/calling_conventions.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
unit="1",
3434
value_type=int,
3535
metric_type=Counter,
36-
label_keys=("environment",),
3736
)
3837

3938
requests_size = meter.create_metric(
@@ -42,7 +41,6 @@
4241
unit="1",
4342
value_type=int,
4443
metric_type=ValueRecorder,
45-
label_keys=("environment",),
4644
)
4745

4846
clicks_counter = meter.create_metric(
@@ -51,7 +49,6 @@
5149
unit="1",
5250
value_type=int,
5351
metric_type=Counter,
54-
label_keys=("environment",),
5552
)
5653

5754
labels = {"environment": "staging"}
@@ -78,3 +75,5 @@
7875
# specified labels for each.
7976
meter.record_batch(labels, ((requests_counter, 50), (clicks_counter, 70)))
8077
time.sleep(5)
78+
79+
input("...\n")

docs/examples/basic_meter/observer.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ def get_cpu_usage_callback(observer):
4141
unit="1",
4242
value_type=float,
4343
observer_type=ValueObserver,
44-
label_keys=("cpu_number",),
4544
)
4645

4746

@@ -58,7 +57,6 @@ def get_ram_usage_callback(observer):
5857
unit="1",
5958
value_type=float,
6059
observer_type=ValueObserver,
61-
label_keys=(),
6260
)
6361

6462
input("Metrics will be printed soon. Press a key to finish...\n")

docs/examples/basic_meter/view.py

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
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+
#
15+
"""
16+
This example shows how to use the different modes to capture metrics.
17+
It shows the usage of the direct, bound and batch calling conventions.
18+
"""
19+
from opentelemetry import metrics
20+
from opentelemetry.sdk.metrics import (
21+
MeterProvider,
22+
UpDownCounter,
23+
ValueRecorder,
24+
)
25+
from opentelemetry.sdk.metrics.export import ConsoleMetricsExporter
26+
from opentelemetry.sdk.metrics.export.aggregate import (
27+
HistogramAggregator,
28+
LastValueAggregator,
29+
MinMaxSumCountAggregator,
30+
SumAggregator,
31+
)
32+
from opentelemetry.sdk.metrics.view import View, ViewConfig
33+
34+
# Use the meter type provided by the SDK package
35+
metrics.set_meter_provider(MeterProvider())
36+
meter = metrics.get_meter(__name__)
37+
metrics.get_meter_provider().start_pipeline(meter, ConsoleMetricsExporter(), 5)
38+
39+
requests_counter = meter.create_metric(
40+
name="requests",
41+
description="number of requests",
42+
unit="1",
43+
value_type=int,
44+
metric_type=UpDownCounter,
45+
)
46+
47+
requests_size = meter.create_metric(
48+
name="requests_size",
49+
description="size of requests",
50+
unit="1",
51+
value_type=int,
52+
metric_type=ValueRecorder,
53+
)
54+
55+
# Views are used to define an aggregation type and label keys to aggregate by
56+
# for a given metric
57+
58+
# Two views with the same metric and aggregation type but different label keys
59+
# With ViewConfig.LABEL_KEYS, all labels but the ones defined in label_keys are
60+
# dropped from the aggregation
61+
counter_view1 = View(
62+
requests_counter,
63+
SumAggregator,
64+
label_keys=["environment"],
65+
view_config=ViewConfig.LABEL_KEYS,
66+
)
67+
counter_view2 = View(
68+
requests_counter,
69+
MinMaxSumCountAggregator,
70+
label_keys=["os_type"],
71+
view_config=ViewConfig.LABEL_KEYS,
72+
)
73+
# This view has ViewConfig set to UNGROUPED, meaning all recorded metrics take
74+
# the labels directly without and consideration for label_keys
75+
counter_view3 = View(
76+
requests_counter,
77+
LastValueAggregator,
78+
label_keys=["environment"], # is not used due to ViewConfig.UNGROUPED
79+
view_config=ViewConfig.UNGROUPED,
80+
)
81+
# This view uses the HistogramAggregator which accepts an option config
82+
# parameter to specify the bucket ranges
83+
size_view = View(
84+
requests_size,
85+
HistogramAggregator,
86+
label_keys=["environment"], # is not used due to ViewConfig.UNGROUPED
87+
aggregator_config={"bounds": [20, 40, 60, 80, 100]},
88+
view_config=ViewConfig.UNGROUPED,
89+
)
90+
91+
# Register the views to the view manager to use the views. Views MUST be
92+
# registered before recording metrics. Metrics that are recorded without
93+
# views defined for them will use a default for that type of metric
94+
meter.register_view(counter_view1)
95+
meter.register_view(counter_view2)
96+
meter.register_view(counter_view3)
97+
meter.register_view(size_view)
98+
99+
# The views will evaluate the labels passed into the record and aggregate upon
100+
# the unique labels that are generated
101+
# view1 labels will evaluate to {"environment": "staging"}
102+
# view2 labels will evaluate to {"os_type": linux}
103+
# view3 labels will evaluate to {"environment": "staging", "os_type": "linux"}
104+
requests_counter.add(100, {"environment": "staging", "os_type": "linux"})
105+
106+
# Since this is using the HistogramAggregator, the bucket counts will be reflected
107+
# with each record
108+
requests_size.record(25, {"test": "value"})
109+
requests_size.record(-3, {"test": "value"})
110+
requests_size.record(200, {"test": "value"})
111+
112+
input("...\n")

docs/examples/datadog_exporter/README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Distributed Example
5050
pip install opentelemetry-sdk
5151
pip install opentelemetry-exporter-datadog
5252
pip install opentelemetry-instrumentation
53-
pip install opentelemetry-ext-flask
53+
pip install opentelemetry-instrumentation-flask
5454
pip install flask
5555
pip install requests
5656

0 commit comments

Comments
 (0)