otlp-test-data 0.11.4__tar.gz → 0.12.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: otlp-test-data
3
- Version: 0.11.4
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
@@ -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
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "otlp-test-data"
3
- version = "0.11.4"
3
+ version = "0.12.0"
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
@@ -7,9 +7,13 @@ def test_spans():
7
7
  assert sample_spans()
8
8
 
9
9
 
10
- def test_json():
10
+ def test_sample_json():
11
11
  data = sample_json()
12
12
  assert json.loads(data)
13
+
14
+
15
+ def test_no_enum_labels():
16
+ data = sample_json()
13
17
  # Ensure that all enum labels have been converted to ints
14
18
  assert b"SPAN_KIND_" not in data
15
19
  assert b"SPAN_FLAGS_" not in data
@@ -22,5 +26,15 @@ def test_json():
22
26
  assert b"LOG_RECORD_FLAGS_" not in data
23
27
 
24
28
 
29
+ def test_logging_integration():
30
+ data = sample_json()
31
+ assert b"sss-sss-sss" in data
32
+
33
+
34
+ def test_exceptions():
35
+ data = sample_json()
36
+ assert b"Traceback" in data
37
+
38
+
25
39
  def test_proto():
26
40
  assert sample_proto()
@@ -374,7 +374,7 @@ wheels = [
374
374
 
375
375
  [[package]]
376
376
  name = "otlp-test-data"
377
- version = "0.11.4"
377
+ version = "0.12.0"
378
378
  source = { editable = "." }
379
379
  dependencies = [
380
380
  { name = "freezegun" },