File: README.rst

package info (click to toggle)
python-opentelemetry 1.39.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,952 kB
  • sloc: python: 53,083; sh: 398; makefile: 142; sql: 39
file content (81 lines) | stat: -rw-r--r-- 2,074 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
OpenTelemetry Metrics SDK
=========================

The source files of these examples are available :scm_web:`here <docs/examples/metrics/instruments/>`.

Start the Collector locally to see data being exported. Write the following file:

.. code-block:: yaml

    # otel-collector-config.yaml
    receivers:
        otlp:
            protocols:
                grpc:
                    endpoint: 0.0.0.0:4317

    exporters:
        debug:


    service:
        pipelines:
            metrics:
                receivers: [otlp]
                exporters: [debug]
  
Then start the Docker container:

.. code-block:: sh

    docker run \
        -p 4317:4317 \
        -v $(pwd)/otel-collector-config.yaml:/etc/otel/config.yaml \
        otel/opentelemetry-collector-contrib:latest

.. code-block:: sh

    $ python example.py

The resulting metrics will appear in the output from the collector and look similar to this:

.. code-block:: sh

    ScopeMetrics #0
    ScopeMetrics SchemaURL:
    InstrumentationScope getting-started 0.1.2
    Metric #0
    Descriptor:
         -> Name: counter
         -> Description:
         -> Unit:
         -> DataType: Sum
         -> IsMonotonic: true
         -> AggregationTemporality: Cumulative
    NumberDataPoints #0
    StartTimestamp: 2024-08-09 11:21:42.145179 +0000 UTC
    Timestamp: 2024-08-09 11:21:42.145325 +0000 UTC
    Value: 1
    Metric #1
    Descriptor:
         -> Name: updown_counter
         -> Description:
         -> Unit:
         -> DataType: Sum
         -> IsMonotonic: false
         -> AggregationTemporality: Cumulative
    NumberDataPoints #0
    StartTimestamp: 2024-08-09 11:21:42.145202 +0000 UTC
    Timestamp: 2024-08-09 11:21:42.145325 +0000 UTC
    Value: -4
    Metric #2
    Descriptor:
         -> Name: histogram
         -> Description:
         -> Unit:
         -> DataType: Histogram
         -> AggregationTemporality: Cumulative
    HistogramDataPoints #0
    StartTimestamp: 2024-08-09 11:21:42.145221 +0000 UTC
    Timestamp: 2024-08-09 11:21:42.145325 +0000 UTC
    Count: 1