otlp-test-data 0.11.2__py3-none-any.whl → 0.11.4__py3-none-any.whl

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.
@@ -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
  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
@@ -0,0 +1,5 @@
1
+ otlp_test_data/__init__.py,sha256=TMkh9igaySapYKpGIQpFGfkFzMiB1XYyotZOsSMoyVU,7492
2
+ otlp_test_data/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ otlp_test_data-0.11.4.dist-info/METADATA,sha256=9NkybvQe02UOVFvzKoXuFHFm44v89JOP96M6xXmFDRs,2247
4
+ otlp_test_data-0.11.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
5
+ otlp_test_data-0.11.4.dist-info/RECORD,,
@@ -1,5 +0,0 @@
1
- otlp_test_data/__init__.py,sha256=IW5l2LhLFWxl7M3tXxxLIZoT3VFGPc2HMkc7w5feTDM,5543
2
- otlp_test_data/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
- otlp_test_data-0.11.2.dist-info/METADATA,sha256=GiJOaZdD5tWcnoJc4bpZxbKCUqsSrYSrW5s2umVstHM,2247
4
- otlp_test_data-0.11.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
5
- otlp_test_data-0.11.2.dist-info/RECORD,,