otlp-test-data 0.11.2__tar.gz → 0.11.4__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: otlp-test-data
3
- Version: 0.11.2
3
+ Version: 0.11.4
4
4
  Summary: Produces OTLP data using OTEL instrumentation
5
5
  Project-URL: Repository, https://github.com/dimaqq/otlp-test-data
6
6
  Project-URL: Issues, https://github.com/dimaqq/otlp-test-data/issues
@@ -3,6 +3,7 @@ from __future__ import annotations
3
3
  import base64
4
4
  import dataclasses
5
5
  import json
6
+ import logging
6
7
  import random
7
8
  from typing import Sequence, TYPE_CHECKING
8
9
  from typing_extensions import reveal_type as reveal_type # temp
@@ -104,6 +105,12 @@ def _proto_to_json(data: Message) -> bytes:
104
105
  "SPAN_KIND_PRODUCER": 4,
105
106
  "SPAN_KIND_CONSUMER": 5,
106
107
  }[sp["kind"]]
108
+ if status := sp["status"]:
109
+ status["code"] = {
110
+ "STATUS_CODE_UNSET": 0,
111
+ "STATUS_CODE_OK": 1,
112
+ "STATUS_CODE_ERROR": 2,
113
+ }[status["code"]]
107
114
 
108
115
  return json.dumps(dic).encode("utf-8")
109
116
 
@@ -114,6 +121,14 @@ def workload():
114
121
  attribute_types()
115
122
  repeated_attributes()
116
123
  events()
124
+ instrumentation_scopes()
125
+ with_exception()
126
+ with_logs()
127
+ # TODO: status that's not an OK status
128
+ # TODO: captured logs
129
+ # TODO: example exception traceback
130
+ # TODO: instrumentation scope with a version
131
+ # TODO: instrumentation scope with attributes
117
132
 
118
133
 
119
134
  def series_of_spans():
@@ -138,26 +153,76 @@ def outer():
138
153
 
139
154
 
140
155
  @tracer.start_as_current_span("inner")
141
- def inner():
156
+ def inner() -> None:
142
157
  opentelemetry.trace.get_current_span().set_attribute("an-attribute", 42)
143
158
  time.tick()
144
159
 
145
160
 
161
+ @tracer.start_as_current_span("with-exc-outer")
162
+ def with_exception() -> None:
163
+ try:
164
+ with tracer.start_as_current_span("with-exc-inner"):
165
+ 1 / 0 # type: ignore
166
+ except Exception:
167
+ pass
168
+
169
+
170
+ @tracer.start_as_current_span("with-logs")
171
+ def with_logs() -> None:
172
+ logging.warning("sss")
173
+ time.tick()
174
+ logging.warning("sss-sss")
175
+ time.tick()
176
+ logging.warning("sss-sss-sss")
177
+
178
+
146
179
  def attribute_types():
147
180
  with tracer.start_as_current_span("attribute-types") as span:
148
181
  span.set_attributes(
149
- {"int": 42, "bool": False, "float": 3.14, "str": "string-cheese"}
182
+ {"int": 42, "bool": False, "float": 3.14, "str": "cheese", "bytes": b"bb"}
150
183
  )
151
184
  span.set_attributes(
152
185
  {
153
186
  "ints": [1, 42],
154
187
  "bools": [True, False],
155
188
  "floats": [2.72, 3.14],
156
- "strs": ["string-cheese", "strung-cheese"],
189
+ "strs": ["cheese", "mozzarella"],
190
+ "byteses": [b"aa", b"bb"], # type: ignore
157
191
  }
158
192
  )
159
193
 
160
194
 
195
+ def instrumentation_scopes():
196
+ tracer1 = opentelemetry.trace.get_tracer("one", "1.2.3")
197
+ tracer2 = opentelemetry.trace.get_tracer("one", "2.7.18")
198
+ tracer3 = opentelemetry.trace.get_tracer(
199
+ "one",
200
+ "3.14.0a5",
201
+ attributes={
202
+ "bool": True,
203
+ "int": 42,
204
+ "float": -12.34,
205
+ "string": "cheese",
206
+ "bytes": b"bb",
207
+ "empty-list": [],
208
+ # "empty-dict": {}, # not allowed for instrumentation scopes
209
+ },
210
+ )
211
+
212
+ with tracer1.start_as_current_span("1.1"):
213
+ time.tick()
214
+ with tracer2.start_as_current_span("2.1"):
215
+ time.tick()
216
+ with tracer1.start_as_current_span("1.2"):
217
+ time.tick()
218
+ with tracer1.start_as_current_span("1.3"):
219
+ time.tick()
220
+ with tracer3.start_as_current_span("3.1"):
221
+ time.tick()
222
+ with tracer1.start_as_current_span("1.4"):
223
+ time.tick()
224
+
225
+
161
226
  def repeated_attributes():
162
227
  with tracer.start_as_current_span("attribute-types") as span:
163
228
  span.set_attribute("int", 42)
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "otlp-test-data"
3
- version = "0.11.2"
3
+ version = "0.11.4"
4
4
  description = "Produces OTLP data using OTEL instrumentation"
5
5
  requires-python = ">=3.8"
6
6
  # https://github.com/astral-sh/uv/issues/4204
@@ -0,0 +1,26 @@
1
+ import json
2
+
3
+ from otlp_test_data import sample_proto, sample_spans, sample_json
4
+
5
+
6
+ def test_spans():
7
+ assert sample_spans()
8
+
9
+
10
+ def test_json():
11
+ data = sample_json()
12
+ assert json.loads(data)
13
+ # Ensure that all enum labels have been converted to ints
14
+ assert b"SPAN_KIND_" not in data
15
+ assert b"SPAN_FLAGS_" not in data
16
+ assert b"STATUS_CODE_" not in data
17
+ # Metrics
18
+ assert b"AGGREGATION_TEMPORALITY_" not in data
19
+ assert b"DATA_POINT_FLAGS_" not in data
20
+ # Logs
21
+ assert b"SEVERITY_NUMBER_" not in data
22
+ assert b"LOG_RECORD_FLAGS_" not in data
23
+
24
+
25
+ def test_proto():
26
+ assert sample_proto()
@@ -374,7 +374,7 @@ wheels = [
374
374
 
375
375
  [[package]]
376
376
  name = "otlp-test-data"
377
- version = "0.10.0"
377
+ version = "0.11.4"
378
378
  source = { editable = "." }
379
379
  dependencies = [
380
380
  { name = "freezegun" },
@@ -447,15 +447,15 @@ wheels = [
447
447
 
448
448
  [[package]]
449
449
  name = "pyright"
450
- version = "1.1.394"
450
+ version = "1.1.395"
451
451
  source = { registry = "https://pypi.org/simple" }
452
452
  dependencies = [
453
453
  { name = "nodeenv" },
454
454
  { name = "typing-extensions" },
455
455
  ]
456
- sdist = { url = "https://files.pythonhosted.org/packages/b1/e4/79f4d8a342eed6790fdebdb500e95062f319ee3d7d75ae27304ff995ae8c/pyright-1.1.394.tar.gz", hash = "sha256:56f2a3ab88c5214a451eb71d8f2792b7700434f841ea219119ade7f42ca93608", size = 3809348 }
456
+ sdist = { url = "https://files.pythonhosted.org/packages/fb/47/a2e1dfd70f9f0db34f70d5b108c82be57bf24185af69c95acff57f9239fa/pyright-1.1.395.tar.gz", hash = "sha256:53703169068c160bfb41e1b44ba3e2512492869c26cfad927e1268cb3fbb1b1c", size = 3813566 }
457
457
  wheels = [
458
- { url = "https://files.pythonhosted.org/packages/d6/4c/50c74e3d589517a9712a61a26143b587dba6285434a17aebf2ce6b82d2c3/pyright-1.1.394-py3-none-any.whl", hash = "sha256:5f74cce0a795a295fb768759bbeeec62561215dea657edcaab48a932b031ddbb", size = 5679540 },
458
+ { url = "https://files.pythonhosted.org/packages/5f/a1/531897f8caa6c6cc99862cd1c908ddd8a366a51d968e83ab4523ded98b30/pyright-1.1.395-py3-none-any.whl", hash = "sha256:f9bc726870e740c6c77c94657734d90563a3e9765bb523b39f5860198ed75eef", size = 5688787 },
459
459
  ]
460
460
 
461
461
  [[package]]
@@ -505,27 +505,27 @@ wheels = [
505
505
 
506
506
  [[package]]
507
507
  name = "ruff"
508
- version = "0.9.7"
509
- source = { registry = "https://pypi.org/simple" }
510
- sdist = { url = "https://files.pythonhosted.org/packages/39/8b/a86c300359861b186f18359adf4437ac8e4c52e42daa9eedc731ef9d5b53/ruff-0.9.7.tar.gz", hash = "sha256:643757633417907510157b206e490c3aa11cab0c087c912f60e07fbafa87a4c6", size = 3669813 }
511
- wheels = [
512
- { url = "https://files.pythonhosted.org/packages/b1/f3/3a1d22973291226df4b4e2ff70196b926b6f910c488479adb0eeb42a0d7f/ruff-0.9.7-py3-none-linux_armv6l.whl", hash = "sha256:99d50def47305fe6f233eb8dabfd60047578ca87c9dcb235c9723ab1175180f4", size = 11774588 },
513
- { url = "https://files.pythonhosted.org/packages/8e/c9/b881f4157b9b884f2994fd08ee92ae3663fb24e34b0372ac3af999aa7fc6/ruff-0.9.7-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:d59105ae9c44152c3d40a9c40d6331a7acd1cdf5ef404fbe31178a77b174ea66", size = 11746848 },
514
- { url = "https://files.pythonhosted.org/packages/14/89/2f546c133f73886ed50a3d449e6bf4af27d92d2f960a43a93d89353f0945/ruff-0.9.7-py3-none-macosx_11_0_arm64.whl", hash = "sha256:f313b5800483770bd540cddac7c90fc46f895f427b7820f18fe1822697f1fec9", size = 11177525 },
515
- { url = "https://files.pythonhosted.org/packages/d7/93/6b98f2c12bf28ab9def59c50c9c49508519c5b5cfecca6de871cf01237f6/ruff-0.9.7-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:042ae32b41343888f59c0a4148f103208bf6b21c90118d51dc93a68366f4e903", size = 11996580 },
516
- { url = "https://files.pythonhosted.org/packages/8e/3f/b3fcaf4f6d875e679ac2b71a72f6691a8128ea3cb7be07cbb249f477c061/ruff-0.9.7-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:87862589373b33cc484b10831004e5e5ec47dc10d2b41ba770e837d4f429d721", size = 11525674 },
517
- { url = "https://files.pythonhosted.org/packages/f0/48/33fbf18defb74d624535d5d22adcb09a64c9bbabfa755bc666189a6b2210/ruff-0.9.7-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a17e1e01bee0926d351a1ee9bc15c445beae888f90069a6192a07a84af544b6b", size = 12739151 },
518
- { url = "https://files.pythonhosted.org/packages/63/b5/7e161080c5e19fa69495cbab7c00975ef8a90f3679caa6164921d7f52f4a/ruff-0.9.7-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:7c1f880ac5b2cbebd58b8ebde57069a374865c73f3bf41f05fe7a179c1c8ef22", size = 13416128 },
519
- { url = "https://files.pythonhosted.org/packages/4e/c8/b5e7d61fb1c1b26f271ac301ff6d9de5e4d9a9a63f67d732fa8f200f0c88/ruff-0.9.7-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:e63fc20143c291cab2841dbb8260e96bafbe1ba13fd3d60d28be2c71e312da49", size = 12870858 },
520
- { url = "https://files.pythonhosted.org/packages/da/cb/2a1a8e4e291a54d28259f8fc6a674cd5b8833e93852c7ef5de436d6ed729/ruff-0.9.7-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:91ff963baed3e9a6a4eba2a02f4ca8eaa6eba1cc0521aec0987da8d62f53cbef", size = 14786046 },
521
- { url = "https://files.pythonhosted.org/packages/ca/6c/c8f8a313be1943f333f376d79724260da5701426c0905762e3ddb389e3f4/ruff-0.9.7-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:88362e3227c82f63eaebf0b2eff5b88990280fb1ecf7105523883ba8c3aaf6fb", size = 12550834 },
522
- { url = "https://files.pythonhosted.org/packages/9d/ad/f70cf5e8e7c52a25e166bdc84c082163c9c6f82a073f654c321b4dff9660/ruff-0.9.7-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:0372c5a90349f00212270421fe91874b866fd3626eb3b397ede06cd385f6f7e0", size = 11961307 },
523
- { url = "https://files.pythonhosted.org/packages/52/d5/4f303ea94a5f4f454daf4d02671b1fbfe2a318b5fcd009f957466f936c50/ruff-0.9.7-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:d76b8ab60e99e6424cd9d3d923274a1324aefce04f8ea537136b8398bbae0a62", size = 11612039 },
524
- { url = "https://files.pythonhosted.org/packages/eb/c8/bd12a23a75603c704ce86723be0648ba3d4ecc2af07eecd2e9fa112f7e19/ruff-0.9.7-py3-none-musllinux_1_2_i686.whl", hash = "sha256:0c439bdfc8983e1336577f00e09a4e7a78944fe01e4ea7fe616d00c3ec69a3d0", size = 12168177 },
525
- { url = "https://files.pythonhosted.org/packages/cc/57/d648d4f73400fef047d62d464d1a14591f2e6b3d4a15e93e23a53c20705d/ruff-0.9.7-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:115d1f15e8fdd445a7b4dc9a30abae22de3f6bcabeb503964904471691ef7606", size = 12610122 },
526
- { url = "https://files.pythonhosted.org/packages/49/79/acbc1edd03ac0e2a04ae2593555dbc9990b34090a9729a0c4c0cf20fb595/ruff-0.9.7-py3-none-win32.whl", hash = "sha256:e9ece95b7de5923cbf38893f066ed2872be2f2f477ba94f826c8defdd6ec6b7d", size = 9988751 },
527
- { url = "https://files.pythonhosted.org/packages/6d/95/67153a838c6b6ba7a2401241fd8a00cd8c627a8e4a0491b8d853dedeffe0/ruff-0.9.7-py3-none-win_amd64.whl", hash = "sha256:3770fe52b9d691a15f0b87ada29c45324b2ace8f01200fb0c14845e499eb0c2c", size = 11002987 },
528
- { url = "https://files.pythonhosted.org/packages/63/6a/aca01554949f3a401991dc32fe22837baeaccb8a0d868256cbb26a029778/ruff-0.9.7-py3-none-win_arm64.whl", hash = "sha256:b075a700b2533feb7a01130ff656a4ec0d5f340bb540ad98759b8401c32c2037", size = 10177763 },
508
+ version = "0.9.9"
509
+ source = { registry = "https://pypi.org/simple" }
510
+ sdist = { url = "https://files.pythonhosted.org/packages/6f/c3/418441a8170e8d53d05c0b9dad69760dbc7b8a12c10dbe6db1e1205d2377/ruff-0.9.9.tar.gz", hash = "sha256:0062ed13f22173e85f8f7056f9a24016e692efeea8704d1a5e8011b8aa850933", size = 3717448 }
511
+ wheels = [
512
+ { url = "https://files.pythonhosted.org/packages/bc/c3/2c4afa9ba467555d074b146d9aed0633a56ccdb900839fb008295d037b89/ruff-0.9.9-py3-none-linux_armv6l.whl", hash = "sha256:628abb5ea10345e53dff55b167595a159d3e174d6720bf19761f5e467e68d367", size = 10027252 },
513
+ { url = "https://files.pythonhosted.org/packages/33/d1/439e58487cf9eac26378332e25e7d5ade4b800ce1eec7dc2cfc9b0d7ca96/ruff-0.9.9-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:b6cd1428e834b35d7493354723543b28cc11dc14d1ce19b685f6e68e07c05ec7", size = 10840721 },
514
+ { url = "https://files.pythonhosted.org/packages/50/44/fead822c38281ba0122f1b76b460488a175a9bd48b130650a6fb6dbcbcf9/ruff-0.9.9-py3-none-macosx_11_0_arm64.whl", hash = "sha256:5ee162652869120ad260670706f3cd36cd3f32b0c651f02b6da142652c54941d", size = 10161439 },
515
+ { url = "https://files.pythonhosted.org/packages/11/ae/d404a2ab8e61ddf6342e09cc6b7f7846cce6b243e45c2007dbe0ca928a5d/ruff-0.9.9-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3aa0f6b75082c9be1ec5a1db78c6d4b02e2375c3068438241dc19c7c306cc61a", size = 10336264 },
516
+ { url = "https://files.pythonhosted.org/packages/6a/4e/7c268aa7d84cd709fb6f046b8972313142cffb40dfff1d2515c5e6288d54/ruff-0.9.9-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:584cc66e89fb5f80f84b05133dd677a17cdd86901d6479712c96597a3f28e7fe", size = 9908774 },
517
+ { url = "https://files.pythonhosted.org/packages/cc/26/c618a878367ef1b76270fd027ca93692657d3f6122b84ba48911ef5f2edc/ruff-0.9.9-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:abf3369325761a35aba75cd5c55ba1b5eb17d772f12ab168fbfac54be85cf18c", size = 11428127 },
518
+ { url = "https://files.pythonhosted.org/packages/d7/9a/c5588a93d9bfed29f565baf193fe802fa676a0c837938137ea6cf0576d8c/ruff-0.9.9-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:3403a53a32a90ce929aa2f758542aca9234befa133e29f4933dcef28a24317be", size = 12133187 },
519
+ { url = "https://files.pythonhosted.org/packages/3e/ff/e7980a7704a60905ed7e156a8d73f604c846d9bd87deda9cabfa6cba073a/ruff-0.9.9-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:18454e7fa4e4d72cffe28a37cf6a73cb2594f81ec9f4eca31a0aaa9ccdfb1590", size = 11602937 },
520
+ { url = "https://files.pythonhosted.org/packages/24/78/3690444ad9e3cab5c11abe56554c35f005b51d1d118b429765249095269f/ruff-0.9.9-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:0fadfe2c88724c9617339f62319ed40dcdadadf2888d5afb88bf3adee7b35bfb", size = 13771698 },
521
+ { url = "https://files.pythonhosted.org/packages/6e/bf/e477c2faf86abe3988e0b5fd22a7f3520e820b2ee335131aca2e16120038/ruff-0.9.9-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6df104d08c442a1aabcfd254279b8cc1e2cbf41a605aa3e26610ba1ec4acf0b0", size = 11249026 },
522
+ { url = "https://files.pythonhosted.org/packages/f7/82/cdaffd59e5a8cb5b14c408c73d7a555a577cf6645faaf83e52fe99521715/ruff-0.9.9-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:d7c62939daf5b2a15af48abbd23bea1efdd38c312d6e7c4cedf5a24e03207e17", size = 10220432 },
523
+ { url = "https://files.pythonhosted.org/packages/fe/a4/2507d0026225efa5d4412b6e294dfe54725a78652a5c7e29e6bd0fc492f3/ruff-0.9.9-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:9494ba82a37a4b81b6a798076e4a3251c13243fc37967e998efe4cce58c8a8d1", size = 9874602 },
524
+ { url = "https://files.pythonhosted.org/packages/d5/be/f3aab1813846b476c4bcffe052d232244979c3cd99d751c17afb530ca8e4/ruff-0.9.9-py3-none-musllinux_1_2_i686.whl", hash = "sha256:4efd7a96ed6d36ef011ae798bf794c5501a514be369296c672dab7921087fa57", size = 10851212 },
525
+ { url = "https://files.pythonhosted.org/packages/8b/45/8e5fd559bea0d2f57c4e12bf197a2fade2fac465aa518284f157dfbca92b/ruff-0.9.9-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:ab90a7944c5a1296f3ecb08d1cbf8c2da34c7e68114b1271a431a3ad30cb660e", size = 11327490 },
526
+ { url = "https://files.pythonhosted.org/packages/42/55/e6c90f13880aeef327746052907e7e930681f26a164fe130ddac28b08269/ruff-0.9.9-py3-none-win32.whl", hash = "sha256:6b4c376d929c25ecd6d87e182a230fa4377b8e5125a4ff52d506ee8c087153c1", size = 10227912 },
527
+ { url = "https://files.pythonhosted.org/packages/35/b2/da925693cb82a1208aa34966c0f36cb222baca94e729dd22a587bc22d0f3/ruff-0.9.9-py3-none-win_amd64.whl", hash = "sha256:837982ea24091d4c1700ddb2f63b7070e5baec508e43b01de013dc7eff974ff1", size = 11355632 },
528
+ { url = "https://files.pythonhosted.org/packages/31/d8/de873d1c1b020d668d8ec9855d390764cb90cf8f6486c0983da52be8b7b7/ruff-0.9.9-py3-none-win_arm64.whl", hash = "sha256:3ac78f127517209fe6d96ab00f3ba97cafe38718b23b1db3e96d8b2d39e37ddf", size = 10435860 },
529
529
  ]
530
530
 
531
531
  [[package]]
@@ -1,15 +0,0 @@
1
- import json
2
-
3
- from otlp_test_data import sample_proto, sample_spans, sample_json
4
-
5
-
6
- def test_spans():
7
- assert sample_spans()
8
-
9
-
10
- def test_json():
11
- assert json.loads(sample_json())
12
-
13
-
14
- def test_proto():
15
- assert sample_proto()