robotframework-tracer 0.2.1__tar.gz → 0.2.2__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.
Files changed (17) hide show
  1. {robotframework_tracer-0.2.1 → robotframework_tracer-0.2.2}/PKG-INFO +12 -1
  2. {robotframework_tracer-0.2.1 → robotframework_tracer-0.2.2}/README.md +11 -0
  3. {robotframework_tracer-0.2.1 → robotframework_tracer-0.2.2}/pyproject.toml +1 -1
  4. {robotframework_tracer-0.2.1 → robotframework_tracer-0.2.2}/src/robotframework_tracer/listener.py +43 -55
  5. {robotframework_tracer-0.2.1 → robotframework_tracer-0.2.2}/src/robotframework_tracer/span_builder.py +2 -2
  6. robotframework_tracer-0.2.2/src/robotframework_tracer/version.py +1 -0
  7. {robotframework_tracer-0.2.1 → robotframework_tracer-0.2.2}/src/robotframework_tracer.egg-info/PKG-INFO +12 -1
  8. robotframework_tracer-0.2.1/src/robotframework_tracer/version.py +0 -1
  9. {robotframework_tracer-0.2.1 → robotframework_tracer-0.2.2}/setup.cfg +0 -0
  10. {robotframework_tracer-0.2.1 → robotframework_tracer-0.2.2}/setup.py +0 -0
  11. {robotframework_tracer-0.2.1 → robotframework_tracer-0.2.2}/src/robotframework_tracer/__init__.py +0 -0
  12. {robotframework_tracer-0.2.1 → robotframework_tracer-0.2.2}/src/robotframework_tracer/attributes.py +0 -0
  13. {robotframework_tracer-0.2.1 → robotframework_tracer-0.2.2}/src/robotframework_tracer/config.py +0 -0
  14. {robotframework_tracer-0.2.1 → robotframework_tracer-0.2.2}/src/robotframework_tracer.egg-info/SOURCES.txt +0 -0
  15. {robotframework_tracer-0.2.1 → robotframework_tracer-0.2.2}/src/robotframework_tracer.egg-info/dependency_links.txt +0 -0
  16. {robotframework_tracer-0.2.1 → robotframework_tracer-0.2.2}/src/robotframework_tracer.egg-info/requires.txt +0 -0
  17. {robotframework_tracer-0.2.1 → robotframework_tracer-0.2.2}/src/robotframework_tracer.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: robotframework-tracer
3
- Version: 0.2.1
3
+ Version: 0.2.2
4
4
  Summary: OpenTelemetry distributed tracing for Robot Framework
5
5
  Author: Robot Framework Tracer Contributors
6
6
  License: Apache-2.0
@@ -108,9 +108,20 @@ docker run -d --name jaeger \
108
108
  ### 2. Run your tests with the listener
109
109
 
110
110
  ```bash
111
+ # Basic usage (uses default endpoint localhost:4318)
111
112
  robot --listener robotframework_tracer.TracingListener tests/
113
+
114
+ # With environment variables (recommended for custom endpoints)
115
+ export OTEL_EXPORTER_OTLP_ENDPOINT=http://jaeger:4318/v1/traces
116
+ export OTEL_SERVICE_NAME=my-tests
117
+ robot --listener robotframework_tracer.TracingListener tests/
118
+
119
+ # With inline options (comma-separated key=value pairs)
120
+ robot --listener "robotframework_tracer.TracingListener:service_name=my-tests,capture_logs=true" tests/
112
121
  ```
113
122
 
123
+ > **Note:** Robot Framework splits listener arguments on `:`. URLs containing `://` are automatically reconstructed by the listener.
124
+
114
125
  ### 3. View traces
115
126
 
116
127
  Open http://localhost:16686 in your browser to see your test traces in Jaeger UI.
@@ -71,9 +71,20 @@ docker run -d --name jaeger \
71
71
  ### 2. Run your tests with the listener
72
72
 
73
73
  ```bash
74
+ # Basic usage (uses default endpoint localhost:4318)
74
75
  robot --listener robotframework_tracer.TracingListener tests/
76
+
77
+ # With environment variables (recommended for custom endpoints)
78
+ export OTEL_EXPORTER_OTLP_ENDPOINT=http://jaeger:4318/v1/traces
79
+ export OTEL_SERVICE_NAME=my-tests
80
+ robot --listener robotframework_tracer.TracingListener tests/
81
+
82
+ # With inline options (comma-separated key=value pairs)
83
+ robot --listener "robotframework_tracer.TracingListener:service_name=my-tests,capture_logs=true" tests/
75
84
  ```
76
85
 
86
+ > **Note:** Robot Framework splits listener arguments on `:`. URLs containing `://` are automatically reconstructed by the listener.
87
+
77
88
  ### 3. View traces
78
89
 
79
90
  Open http://localhost:16686 in your browser to see your test traces in Jaeger UI.
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "robotframework-tracer"
7
- version = "0.2.1"
7
+ version = "0.2.2"
8
8
  description = "OpenTelemetry distributed tracing for Robot Framework"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.8"
@@ -1,14 +1,15 @@
1
+ import platform
2
+ import sys
3
+
4
+ import robot
1
5
  from opentelemetry import trace
2
6
  from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter as HTTPExporter
3
- from opentelemetry.sdk.resources import Resource, SERVICE_NAME, SERVICE_VERSION
7
+ from opentelemetry.propagate import inject
8
+ from opentelemetry.sdk.resources import SERVICE_NAME, Resource
4
9
  from opentelemetry.sdk.trace import TracerProvider
5
10
  from opentelemetry.sdk.trace.export import BatchSpanProcessor
6
- from opentelemetry.sdk.trace.sampling import TraceIdRatioBased, ParentBased
11
+ from opentelemetry.sdk.trace.sampling import ParentBased, TraceIdRatioBased
7
12
  from opentelemetry.semconv.resource import ResourceAttributes
8
- from opentelemetry.propagate import inject
9
- import platform
10
- import sys
11
- import robot
12
13
 
13
14
  from .config import TracerConfig
14
15
  from .span_builder import SpanBuilder
@@ -37,57 +38,20 @@ class TracingListener:
37
38
 
38
39
  ROBOT_LISTENER_API_VERSION = 3
39
40
 
40
- def __init__(
41
- self,
42
- endpoint=None,
43
- service_name=None,
44
- protocol=None,
45
- capture_arguments=None,
46
- max_arg_length=None,
47
- capture_logs=None,
48
- sample_rate=None,
49
- span_prefix_style=None,
50
- log_level=None,
51
- max_log_length=None,
52
- ):
41
+ def __init__(self, *args, **kwargs):
53
42
  """Initialize the tracing listener.
54
43
 
55
- Args:
56
- endpoint: OTLP endpoint URL
57
- service_name: Service name for traces
58
- protocol: Protocol (http or grpc)
59
- capture_arguments: Whether to capture keyword arguments
60
- max_arg_length: Maximum length for arguments
61
- capture_logs: Whether to capture log messages
62
- sample_rate: Sampling rate (0.0-1.0)
63
- span_prefix_style: Span prefix style (none, text, emoji)
64
- log_level: Minimum log level to capture (DEBUG, INFO, WARN, ERROR)
65
- max_log_length: Maximum length for log messages
44
+ Accepts arguments in multiple formats:
45
+ - Environment variables (recommended): OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_SERVICE_NAME
46
+ - Keyword arguments: endpoint=..., service_name=...
47
+ - RF listener args: key=value pairs (comma-separated)
48
+
49
+ Note: Robot Framework splits listener arguments on ':' which breaks URLs.
50
+ This listener automatically reconstructs URLs that were split.
66
51
  """
67
- # Build kwargs dict from provided arguments
68
- kwargs = {}
69
- if endpoint is not None:
70
- kwargs["endpoint"] = endpoint
71
- if service_name is not None:
72
- kwargs["service_name"] = service_name
73
- if protocol is not None:
74
- kwargs["protocol"] = protocol
75
- if capture_arguments is not None:
76
- kwargs["capture_arguments"] = capture_arguments
77
- if max_arg_length is not None:
78
- kwargs["max_arg_length"] = max_arg_length
79
- if capture_logs is not None:
80
- kwargs["capture_logs"] = capture_logs
81
- if sample_rate is not None:
82
- kwargs["sample_rate"] = sample_rate
83
- if span_prefix_style is not None:
84
- kwargs["span_prefix_style"] = span_prefix_style
85
- if log_level is not None:
86
- kwargs["log_level"] = log_level
87
- if max_log_length is not None:
88
- kwargs["max_log_length"] = max_log_length
89
-
90
- self.config = TracerConfig(**kwargs)
52
+ parsed_kwargs = self._parse_listener_args(args)
53
+ parsed_kwargs.update(kwargs)
54
+ self.config = TracerConfig(**parsed_kwargs)
91
55
 
92
56
  # Initialize OpenTelemetry with automatic resource detection
93
57
  resource_attrs = {
@@ -130,6 +94,30 @@ class TracingListener:
130
94
  self.tracer = trace.get_tracer(__name__)
131
95
  self.span_stack = []
132
96
 
97
+ @staticmethod
98
+ def _parse_listener_args(args):
99
+ """Parse Robot Framework listener arguments.
100
+
101
+ RF splits arguments on ':' which breaks URLs like http://host:port.
102
+ This method reconstructs the original string and parses key=value pairs.
103
+ """
104
+ if not args:
105
+ return {}
106
+
107
+ import re
108
+
109
+ # Rejoin with ':' to reconstruct original (RF splits on ':')
110
+ rejoined = ":".join(args)
111
+
112
+ # Match: key=value where value may contain URLs (stops at comma+key= or end)
113
+ kwargs = {}
114
+ pattern = r"(\w+)=([^,]*?)(?=,\w+=|$)"
115
+ for match in re.finditer(pattern, rejoined):
116
+ key, value = match.groups()
117
+ kwargs[key.strip()] = value.strip()
118
+
119
+ return kwargs
120
+
133
121
  def _set_trace_context_variables(self):
134
122
  """Set Robot Framework variables with current trace context."""
135
123
  if not BUILTIN_AVAILABLE:
@@ -170,7 +158,7 @@ class TracingListener:
170
158
  if headers.get("tracestate"):
171
159
  builtin.set_test_variable("${TRACESTATE}", headers["tracestate"])
172
160
 
173
- except Exception as e:
161
+ except Exception:
174
162
  # Silently ignore errors to avoid breaking tests
175
163
  pass
176
164
 
@@ -1,6 +1,6 @@
1
- from opentelemetry import trace, baggage
2
- from opentelemetry.trace import Status, StatusCode
3
1
  import robot
2
+ from opentelemetry import baggage, trace
3
+ from opentelemetry.trace import Status, StatusCode
4
4
 
5
5
  from .attributes import AttributeExtractor, RFAttributes
6
6
 
@@ -0,0 +1 @@
1
+ __version__ = "0.2.2"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: robotframework-tracer
3
- Version: 0.2.1
3
+ Version: 0.2.2
4
4
  Summary: OpenTelemetry distributed tracing for Robot Framework
5
5
  Author: Robot Framework Tracer Contributors
6
6
  License: Apache-2.0
@@ -108,9 +108,20 @@ docker run -d --name jaeger \
108
108
  ### 2. Run your tests with the listener
109
109
 
110
110
  ```bash
111
+ # Basic usage (uses default endpoint localhost:4318)
111
112
  robot --listener robotframework_tracer.TracingListener tests/
113
+
114
+ # With environment variables (recommended for custom endpoints)
115
+ export OTEL_EXPORTER_OTLP_ENDPOINT=http://jaeger:4318/v1/traces
116
+ export OTEL_SERVICE_NAME=my-tests
117
+ robot --listener robotframework_tracer.TracingListener tests/
118
+
119
+ # With inline options (comma-separated key=value pairs)
120
+ robot --listener "robotframework_tracer.TracingListener:service_name=my-tests,capture_logs=true" tests/
112
121
  ```
113
122
 
123
+ > **Note:** Robot Framework splits listener arguments on `:`. URLs containing `://` are automatically reconstructed by the listener.
124
+
114
125
  ### 3. View traces
115
126
 
116
127
  Open http://localhost:16686 in your browser to see your test traces in Jaeger UI.
@@ -1 +0,0 @@
1
- __version__ = "0.2.1"