otlp-test-data 0.9.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,53 @@
1
+ Metadata-Version: 2.2
2
+ Name: otlp-test-data
3
+ Version: 0.9.0
4
+ Summary: Produces OTLP data using OTEL instrumentation
5
+ Classifier: Development Status :: 3 - Alpha
6
+ Classifier: Intended Audience :: Developers
7
+ Classifier: License :: OSI Approved :: MIT License
8
+ Classifier: Natural Language :: English
9
+ Classifier: Operating System :: OS Independent
10
+ Classifier: Programming Language :: Python
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.8
13
+ Classifier: Programming Language :: Python :: 3.9
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Programming Language :: Python :: 3.14
19
+ Classifier: Programming Language :: Python :: 3 :: Only
20
+ Classifier: Programming Language :: Python :: Implementation :: CPython
21
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
22
+ Classifier: Topic :: Software Development :: Testing
23
+ Classifier: Topic :: Software Development :: Testing :: Traffic Generation
24
+ Classifier: Framework :: OpenTelemetry
25
+ Classifier: Framework :: OpenTelemetry :: Exporters
26
+ Requires-Python: >=3.8
27
+ Description-Content-Type: text/markdown
28
+ Requires-Dist: freezegun~=1.5
29
+ Requires-Dist: opentelemetry-api~=1.30
30
+ Requires-Dist: opentelemetry-exporter-otlp~=1.30
31
+ Requires-Dist: opentelemetry-exporter-otlp-proto-http~=1.30
32
+
33
+ # otlp-test-data
34
+
35
+ Produces OTLP data using OTEL instrumentation.
36
+
37
+ ### Features
38
+
39
+ - fixed, configurable timestamps
40
+ - aims to cover as much of OTEL API as possible
41
+ - aims to cover all valid data types
42
+
43
+ ### Limitations
44
+
45
+ - currently only tracing data is generated, PRs are welcome to add metrics and logs data
46
+ - data is generated in process, remote (forwarded) spans are not supported
47
+
48
+ ### TODO
49
+
50
+ - Events
51
+ - Links
52
+ - Baggage
53
+ - Schemata, when https://github.com/open-telemetry/opentelemetry-python/pull/4359 lands
@@ -0,0 +1,53 @@
1
+ Metadata-Version: 2.2
2
+ Name: otlp-test-data
3
+ Version: 0.9.0
4
+ Summary: Produces OTLP data using OTEL instrumentation
5
+ Classifier: Development Status :: 3 - Alpha
6
+ Classifier: Intended Audience :: Developers
7
+ Classifier: License :: OSI Approved :: MIT License
8
+ Classifier: Natural Language :: English
9
+ Classifier: Operating System :: OS Independent
10
+ Classifier: Programming Language :: Python
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.8
13
+ Classifier: Programming Language :: Python :: 3.9
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Programming Language :: Python :: 3.14
19
+ Classifier: Programming Language :: Python :: 3 :: Only
20
+ Classifier: Programming Language :: Python :: Implementation :: CPython
21
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
22
+ Classifier: Topic :: Software Development :: Testing
23
+ Classifier: Topic :: Software Development :: Testing :: Traffic Generation
24
+ Classifier: Framework :: OpenTelemetry
25
+ Classifier: Framework :: OpenTelemetry :: Exporters
26
+ Requires-Python: >=3.8
27
+ Description-Content-Type: text/markdown
28
+ Requires-Dist: freezegun~=1.5
29
+ Requires-Dist: opentelemetry-api~=1.30
30
+ Requires-Dist: opentelemetry-exporter-otlp~=1.30
31
+ Requires-Dist: opentelemetry-exporter-otlp-proto-http~=1.30
32
+
33
+ # otlp-test-data
34
+
35
+ Produces OTLP data using OTEL instrumentation.
36
+
37
+ ### Features
38
+
39
+ - fixed, configurable timestamps
40
+ - aims to cover as much of OTEL API as possible
41
+ - aims to cover all valid data types
42
+
43
+ ### Limitations
44
+
45
+ - currently only tracing data is generated, PRs are welcome to add metrics and logs data
46
+ - data is generated in process, remote (forwarded) spans are not supported
47
+
48
+ ### TODO
49
+
50
+ - Events
51
+ - Links
52
+ - Baggage
53
+ - Schemata, when https://github.com/open-telemetry/opentelemetry-python/pull/4359 lands
@@ -0,0 +1,9 @@
1
+ otlp_test_data.py
2
+ pyproject.toml
3
+ readme.md
4
+ otlp_test_data.egg-info/PKG-INFO
5
+ otlp_test_data.egg-info/SOURCES.txt
6
+ otlp_test_data.egg-info/dependency_links.txt
7
+ otlp_test_data.egg-info/requires.txt
8
+ otlp_test_data.egg-info/top_level.txt
9
+ test/test_repeatable.py
@@ -0,0 +1,4 @@
1
+ freezegun~=1.5
2
+ opentelemetry-api~=1.30
3
+ opentelemetry-exporter-otlp~=1.30
4
+ opentelemetry-exporter-otlp-proto-http~=1.30
@@ -0,0 +1 @@
1
+ otlp_test_data
@@ -0,0 +1,89 @@
1
+ from __future__ import annotations
2
+
3
+ import base64
4
+ import dataclasses
5
+ import json
6
+ import random
7
+ from typing import Sequence, TYPE_CHECKING
8
+ from typing_extensions import reveal_type as reveal_type # temp
9
+
10
+ import freezegun
11
+ from google.protobuf.json_format import MessageToDict
12
+ from opentelemetry.exporter.otlp.proto.common._internal import trace_encoder
13
+ from opentelemetry.sdk.trace import TracerProvider
14
+ from opentelemetry.sdk.trace.export import SimpleSpanProcessor
15
+ from opentelemetry.sdk.trace.export.in_memory_span_exporter import InMemorySpanExporter
16
+
17
+ if TYPE_CHECKING:
18
+ from google.protobuf.message import Message
19
+ from opentelemetry.sdk.trace import ReadableSpan
20
+ from opentelemetry.proto.collector.trace.v1.trace_service_pb2 import (
21
+ ExportTraceServiceRequest,
22
+ )
23
+
24
+
25
+ @dataclasses.dataclass
26
+ class Config:
27
+ start_time: str = "2020-01-01 00:00:00Z"
28
+ random_seed: int = 42
29
+
30
+
31
+ time = None
32
+
33
+
34
+ def sample_proto(config: Config) -> bytes:
35
+ return _proto_to_bytes(_spans_to_proto_object(sample_spans(config)))
36
+
37
+
38
+ def sample_json(config: Config) -> bytes:
39
+ return _proto_to_json(_spans_to_proto_object(sample_spans(config)))
40
+
41
+
42
+ def sample_spans(config: Config) -> Sequence[ReadableSpan]:
43
+ """Creates and finishes two spans, then returns them as a list."""
44
+ global time
45
+ tracer_provider = TracerProvider()
46
+ exporter = InMemorySpanExporter()
47
+ tracer_provider.add_span_processor(SimpleSpanProcessor(exporter))
48
+ tracer = tracer_provider.get_tracer(__name__)
49
+
50
+ with freezegun.freeze_time(config.start_time) as time:
51
+ random.seed(config.random_seed)
52
+
53
+ # FIXME the workload section is expected to grow a lot
54
+ with tracer.start_as_current_span("span-one"):
55
+ time.tick()
56
+ with tracer.start_as_current_span("span-two"):
57
+ time.tick()
58
+
59
+ return exporter.get_finished_spans()
60
+
61
+
62
+ def _spans_to_proto_object(spans: Sequence[ReadableSpan]) -> ExportTraceServiceRequest:
63
+ return trace_encoder.encode_spans(spans)
64
+
65
+
66
+ def _proto_to_bytes(data: Message) -> bytes:
67
+ return data.SerializePartialToString()
68
+
69
+
70
+ # FIXME: there are probably 3 different enumerated types in the API
71
+ def _proto_to_json(data: Message) -> bytes:
72
+ dic = MessageToDict(data)
73
+
74
+ for rs in dic["resourceSpans"]:
75
+ for ss in rs["scopeSpans"]:
76
+ for sp in ss["spans"]:
77
+ for k in "parentSpanId spanId traceId".split():
78
+ if k in sp:
79
+ sp[k] = base64.b64decode(sp[k]).hex()
80
+ sp["kind"] = {
81
+ "SPAN_KIND_UNSPECIFIED": 0,
82
+ "SPAN_KIND_INTERNAL": 1,
83
+ "SPAN_KIND_SERVER": 2,
84
+ "SPAN_KIND_CLIENT": 3,
85
+ "SPAN_KIND_PRODUCER": 4,
86
+ "SPAN_KIND_CONSUMER": 5,
87
+ }[sp["kind"]]
88
+
89
+ return json.dumps(dic).encode("utf-8")
@@ -0,0 +1,54 @@
1
+ [project]
2
+ name = "otlp-test-data"
3
+ version = "0.9.0"
4
+ description = "Produces OTLP data using OTEL instrumentation"
5
+ requires-python = ">=3.8"
6
+ # https://github.com/astral-sh/uv/issues/4204
7
+ # license = "MIT"
8
+ readme = "readme.md"
9
+ classifiers = [
10
+ "Development Status :: 3 - Alpha",
11
+ "Intended Audience :: Developers",
12
+ "License :: OSI Approved :: MIT License",
13
+ "Natural Language :: English",
14
+ "Operating System :: OS Independent",
15
+ "Programming Language :: Python",
16
+ "Programming Language :: Python :: 3",
17
+ "Programming Language :: Python :: 3.8",
18
+ "Programming Language :: Python :: 3.9",
19
+ "Programming Language :: Python :: 3.10",
20
+ "Programming Language :: Python :: 3.11",
21
+ "Programming Language :: Python :: 3.12",
22
+ "Programming Language :: Python :: 3.13",
23
+ "Programming Language :: Python :: 3.14",
24
+ "Programming Language :: Python :: 3 :: Only",
25
+ "Programming Language :: Python :: Implementation :: CPython",
26
+ "Programming Language :: Python :: Implementation :: PyPy",
27
+ "Topic :: Software Development :: Testing",
28
+ "Topic :: Software Development :: Testing :: Traffic Generation",
29
+ "Framework :: OpenTelemetry",
30
+ "Framework :: OpenTelemetry :: Exporters",
31
+ ]
32
+ dependencies = [
33
+ "freezegun ~= 1.5",
34
+ "opentelemetry-api ~= 1.30",
35
+ "opentelemetry-exporter-otlp ~= 1.30",
36
+ "opentelemetry-exporter-otlp-proto-http ~= 1.30",
37
+ ]
38
+
39
+ [dependency-groups]
40
+ dev = [
41
+ "pyright ~= 1.1",
42
+ "ruff ~= 0.9",
43
+ ]
44
+ testing = [
45
+ "pytest ~= 8.3.4",
46
+ ]
47
+
48
+ [tool.semantic_release]
49
+ version_variables = ["pyproject.toml:project.version"]
50
+
51
+ [tool.semantic_release.changelog]
52
+ changelog_file = "changelog.md"
53
+ exclude_commit_patterns = ["ci", "test"]
54
+ mode = "update"
@@ -0,0 +1,21 @@
1
+ # otlp-test-data
2
+
3
+ Produces OTLP data using OTEL instrumentation.
4
+
5
+ ### Features
6
+
7
+ - fixed, configurable timestamps
8
+ - aims to cover as much of OTEL API as possible
9
+ - aims to cover all valid data types
10
+
11
+ ### Limitations
12
+
13
+ - currently only tracing data is generated, PRs are welcome to add metrics and logs data
14
+ - data is generated in process, remote (forwarded) spans are not supported
15
+
16
+ ### TODO
17
+
18
+ - Events
19
+ - Links
20
+ - Baggage
21
+ - Schemata, when https://github.com/open-telemetry/opentelemetry-python/pull/4359 lands
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,15 @@
1
+ import json
2
+
3
+ from otlp_test_data import Config, sample_proto, sample_json
4
+
5
+
6
+ def test_same_json():
7
+ assert json.loads(sample_json(Config())) == json.loads(sample_json(Config()))
8
+
9
+
10
+ def test_same_json_verbatim():
11
+ assert sample_json(Config()) == sample_json(Config())
12
+
13
+
14
+ def test_same_proto_verbatim():
15
+ assert sample_proto(Config()) == sample_proto(Config())