otlp-test-data 0.11.3__py3-none-any.whl → 0.12.0__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.
@@ -42,6 +42,13 @@ class Config:
42
42
  time: freezegun.api.FrozenDateTimeFactory = None # type: ignore
43
43
 
44
44
 
45
+ class LogsToEvents(logging.Handler):
46
+ def emit(self, record):
47
+ span = opentelemetry.trace.get_current_span()
48
+ if span and span.is_recording():
49
+ span.add_event(record.getMessage(), {"severity": record.levelname})
50
+
51
+
45
52
  def sample_proto(config: Config | None = None) -> bytes:
46
53
  return _proto_to_bytes(_spans_to_proto_object(sample_spans(config)))
47
54
 
@@ -54,6 +61,9 @@ def sample_spans(config: Config | None = None) -> Sequence[ReadableSpan]:
54
61
  """Creates and finishes two spans, then returns them as a list."""
55
62
  global time
56
63
  config = config or Config()
64
+ logging.basicConfig(level="DEBUG")
65
+ if not any(isinstance(h, LogsToEvents) for h in logging.root.handlers):
66
+ logging.root.addHandler(LogsToEvents())
57
67
  resource = Resource.create(
58
68
  attributes={
59
69
  "service.namespace": "1234-1234", # a unique id
@@ -105,6 +115,12 @@ def _proto_to_json(data: Message) -> bytes:
105
115
  "SPAN_KIND_PRODUCER": 4,
106
116
  "SPAN_KIND_CONSUMER": 5,
107
117
  }[sp["kind"]]
118
+ if status := sp["status"]:
119
+ status["code"] = {
120
+ "STATUS_CODE_UNSET": 0,
121
+ "STATUS_CODE_OK": 1,
122
+ "STATUS_CODE_ERROR": 2,
123
+ }[status["code"]]
108
124
 
109
125
  return json.dumps(dic).encode("utf-8")
110
126
 
@@ -199,7 +215,7 @@ def instrumentation_scopes():
199
215
  "string": "cheese",
200
216
  "bytes": b"bb",
201
217
  "empty-list": [],
202
- "empty-dict": {}, # type: ignore
218
+ # "empty-dict": {}, # not allowed for instrumentation scopes
203
219
  },
204
220
  )
205
221
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: otlp-test-data
3
- Version: 0.11.3
3
+ Version: 0.12.0
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=2pIN7_pPN92AtYDGeZUmB1PB5_bx8ca4LkM1fuEaX_M,7897
2
+ otlp_test_data/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ otlp_test_data-0.12.0.dist-info/METADATA,sha256=VQMQcLR4ZOPYAc3kcM7BfcTF4cfEp-IPO7vZkxmXrzw,2247
4
+ otlp_test_data-0.12.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
5
+ otlp_test_data-0.12.0.dist-info/RECORD,,
@@ -1,5 +0,0 @@
1
- otlp_test_data/__init__.py,sha256=Lgb6VmoSnPZ_kepsPMcxSAVx1NLYsYfNjrV1bPD48iE,7203
2
- otlp_test_data/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
- otlp_test_data-0.11.3.dist-info/METADATA,sha256=vYuSUVDR2yxYt7C25_7Pd4ZsiMyUxotLsT8eS3hZ39k,2247
4
- otlp_test_data-0.11.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
5
- otlp_test_data-0.11.3.dist-info/RECORD,,