dynatrace-openfeature-provider-python 0.1.1__tar.gz → 0.2.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.
Files changed (15) hide show
  1. {dynatrace_openfeature_provider_python-0.1.1 → dynatrace_openfeature_provider_python-0.2.0}/PKG-INFO +17 -1
  2. {dynatrace_openfeature_provider_python-0.1.1 → dynatrace_openfeature_provider_python-0.2.0}/README.md +16 -0
  3. {dynatrace_openfeature_provider_python-0.1.1 → dynatrace_openfeature_provider_python-0.2.0}/pyproject.toml +1 -1
  4. {dynatrace_openfeature_provider_python-0.1.1 → dynatrace_openfeature_provider_python-0.2.0}/pyproject.toml.orig +1 -1
  5. {dynatrace_openfeature_provider_python-0.1.1 → dynatrace_openfeature_provider_python-0.2.0}/src/dynatrace/openfeature/options.py +25 -24
  6. {dynatrace_openfeature_provider_python-0.1.1 → dynatrace_openfeature_provider_python-0.2.0}/src/dynatrace/openfeature/provider.py +2 -2
  7. {dynatrace_openfeature_provider_python-0.1.1 → dynatrace_openfeature_provider_python-0.2.0}/LICENSE +0 -0
  8. {dynatrace_openfeature_provider_python-0.1.1 → dynatrace_openfeature_provider_python-0.2.0}/src/dynatrace/openfeature/__init__.py +0 -0
  9. {dynatrace_openfeature_provider_python-0.1.1 → dynatrace_openfeature_provider_python-0.2.0}/src/dynatrace/openfeature/_cdn.py +0 -0
  10. {dynatrace_openfeature_provider_python-0.1.1 → dynatrace_openfeature_provider_python-0.2.0}/src/dynatrace/openfeature/_metrics_aggregator.py +0 -0
  11. {dynatrace_openfeature_provider_python-0.1.1 → dynatrace_openfeature_provider_python-0.2.0}/src/dynatrace/openfeature/_metrics_flusher.py +0 -0
  12. {dynatrace_openfeature_provider_python-0.1.1 → dynatrace_openfeature_provider_python-0.2.0}/src/dynatrace/openfeature/_metrics_hook.py +0 -0
  13. {dynatrace_openfeature_provider_python-0.1.1 → dynatrace_openfeature_provider_python-0.2.0}/src/dynatrace/openfeature/_polling.py +0 -0
  14. {dynatrace_openfeature_provider_python-0.1.1 → dynatrace_openfeature_provider_python-0.2.0}/src/dynatrace/openfeature/_retry.py +0 -0
  15. {dynatrace_openfeature_provider_python-0.1.1 → dynatrace_openfeature_provider_python-0.2.0}/src/dynatrace/openfeature/py.typed +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dynatrace-openfeature-provider-python
3
- Version: 0.1.1
3
+ Version: 0.2.0
4
4
  Summary: The official Dynatrace OpenFeature provider for Python
5
5
  Keywords: openfeature,dynatrace,feature-flags,feature-management
6
6
  Author: Dynatrace
@@ -62,6 +62,22 @@ api.set_provider(
62
62
  )
63
63
  ```
64
64
 
65
+ ### Metrics origin override
66
+
67
+ By default the metrics ingest endpoint is derived from the SDK key. To point
68
+ metrics at a different environment or an SDK proxy, pass `metrics_origin`. The
69
+ value is an origin only: scheme, host, and optional port, with no path. The
70
+ provider appends `/v1/metrics` itself.
71
+
72
+ ```python
73
+ api.set_provider(
74
+ DynatraceProvider(
75
+ sdk_key,
76
+ metrics_origin='https://metrics.eu.fm.dynatracelabs.com',
77
+ )
78
+ )
79
+ ```
80
+
65
81
  ## Architecture
66
82
 
67
83
  The provider performs in-process flag evaluation using [flagd-core](https://github.com/open-feature/python-sdk-contrib/tree/main/tools/openfeature-flagd-core).
@@ -44,6 +44,22 @@ api.set_provider(
44
44
  )
45
45
  ```
46
46
 
47
+ ### Metrics origin override
48
+
49
+ By default the metrics ingest endpoint is derived from the SDK key. To point
50
+ metrics at a different environment or an SDK proxy, pass `metrics_origin`. The
51
+ value is an origin only: scheme, host, and optional port, with no path. The
52
+ provider appends `/v1/metrics` itself.
53
+
54
+ ```python
55
+ api.set_provider(
56
+ DynatraceProvider(
57
+ sdk_key,
58
+ metrics_origin='https://metrics.eu.fm.dynatracelabs.com',
59
+ )
60
+ )
61
+ ```
62
+
47
63
  ## Architecture
48
64
 
49
65
  The provider performs in-process flag evaluation using [flagd-core](https://github.com/open-feature/python-sdk-contrib/tree/main/tools/openfeature-flagd-core).
@@ -4,7 +4,7 @@ build-backend = "uv_build"
4
4
 
5
5
  [project]
6
6
  name = "dynatrace-openfeature-provider-python"
7
- version = "0.1.1"
7
+ version = "0.2.0"
8
8
  description = "The official Dynatrace OpenFeature provider for Python"
9
9
  readme = "README.md"
10
10
  license = "Apache-2.0"
@@ -4,7 +4,7 @@ build-backend = "uv_build"
4
4
 
5
5
  [project]
6
6
  name = "dynatrace-openfeature-provider-python"
7
- version = "0.1.1"
7
+ version = "0.2.0"
8
8
  description = "The official Dynatrace OpenFeature provider for Python"
9
9
  readme = "README.md"
10
10
  authors = [{ name = "Dynatrace" }]
@@ -10,39 +10,37 @@ _KEY_PATTERN = re.compile(
10
10
  )
11
11
 
12
12
  _ALLOWED_SCHEMES = ("http", "https")
13
+ _METRICS_PATH = "/v1/metrics"
13
14
 
14
15
 
15
- def _normalise_config_origin(value: str) -> str:
16
+ def _normalise_origin(value: str, field: str) -> str:
16
17
  """Validate that ``value`` is a bare origin and return it in canonical form.
17
18
 
18
- An origin is a scheme, host, and optional port — nothing else. Anything the
19
- platform and key segments could not be safely appended to is rejected here,
20
- so a malformed override fails at construction rather than as a 404 on the
21
- first config fetch.
19
+ An origin is a scheme, host, and optional port; nothing else. Anything that
20
+ could not be safely appended to is rejected here, so a malformed override
21
+ fails at construction rather than as a 404 on the first request.
22
22
  """
23
23
  try:
24
24
  parsed = urlparse(value)
25
25
  except ValueError as exc:
26
- raise ValueError(f"config_origin is not a valid URL; got {value!r}") from exc
26
+ raise ValueError(f"{field} is not a valid URL; got {value!r}") from exc
27
27
  if parsed.scheme not in _ALLOWED_SCHEMES:
28
- raise ValueError(f"config_origin must use http or https; got {value!r}")
28
+ raise ValueError(f"{field} must use http or https; got {value!r}")
29
29
  try:
30
30
  # Accessing .port raises if the port is present but not a valid integer.
31
31
  _ = parsed.port
32
32
  except ValueError as exc:
33
- raise ValueError(f"config_origin has an invalid port; got {value!r}") from exc
33
+ raise ValueError(f"{field} has an invalid port; got {value!r}") from exc
34
34
  if not parsed.hostname:
35
- raise ValueError(f"config_origin must include a host; got {value!r}")
36
- if parsed.path.rstrip("/"):
37
- raise ValueError(f"config_origin must not include a path; got {value!r}")
35
+ raise ValueError(f"{field} must include a host; got {value!r}")
36
+ if parsed.path and parsed.path != "/":
37
+ raise ValueError(f"{field} must not include a path; got {value!r}")
38
38
  if parsed.query:
39
- raise ValueError(
40
- f"config_origin must not include a query string; got {value!r}"
41
- )
39
+ raise ValueError(f"{field} must not include a query string; got {value!r}")
42
40
  if parsed.fragment:
43
- raise ValueError(f"config_origin must not include a fragment; got {value!r}")
41
+ raise ValueError(f"{field} must not include a fragment; got {value!r}")
44
42
  if parsed.username or parsed.password:
45
- raise ValueError(f"config_origin must not include user info; got {value!r}")
43
+ raise ValueError(f"{field} must not include user info; got {value!r}")
46
44
  # netloc rather than hostname + port: it preserves the brackets around an IPv6
47
45
  # literal, which hostname strips. User info is already rejected above, so at
48
46
  # this point netloc is exactly the host and optional port.
@@ -62,7 +60,7 @@ class DynatraceProviderOptions:
62
60
  cls,
63
61
  sdk_key: str,
64
62
  config_origin: str | None = None,
65
- metrics_url: str | None = None,
63
+ metrics_origin: str | None = None,
66
64
  ) -> DynatraceProviderOptions:
67
65
  if not sdk_key or not sdk_key.strip():
68
66
  raise ValueError("sdk_key must not be null or blank")
@@ -80,18 +78,21 @@ class DynatraceProviderOptions:
80
78
  config_origin = config_origin.strip()
81
79
  if not config_origin:
82
80
  raise ValueError("config_origin must not be blank")
83
- origin = _normalise_config_origin(config_origin)
81
+ origin = _normalise_origin(config_origin, "config_origin")
84
82
  base = origin + "/" + platform + "/"
85
83
  else:
86
84
  base = f"https://cdn.{geo}.fm.dynatrace.com/{platform}/"
87
85
  cdn_url = base + trimmed + ".json"
88
- if metrics_url is not None:
89
- metrics_url = metrics_url.strip()
90
- if not metrics_url:
91
- raise ValueError("metrics_url must not be blank")
92
- resolved_metrics_url = metrics_url
86
+ if metrics_origin is not None:
87
+ metrics_origin = metrics_origin.strip()
88
+ if not metrics_origin:
89
+ raise ValueError("metrics_origin must not be blank")
90
+ origin = _normalise_origin(metrics_origin, "metrics_origin")
91
+ resolved_metrics_url = origin + _METRICS_PATH
93
92
  else:
94
- resolved_metrics_url = f"https://metrics.{geo}.fm.dynatrace.com/v1/metrics"
93
+ resolved_metrics_url = (
94
+ f"https://metrics.{geo}.fm.dynatrace.com{_METRICS_PATH}"
95
+ )
95
96
  return cls(key=trimmed, cdn_url=cdn_url, metrics_url=resolved_metrics_url)
96
97
 
97
98
  @property
@@ -50,7 +50,7 @@ class DynatraceProvider(AbstractProvider):
50
50
  sdk_key: str,
51
51
  *,
52
52
  config_origin: str | None = None,
53
- metrics_url: str | None = None,
53
+ metrics_origin: str | None = None,
54
54
  flagd_core: FlagdCore | None = None,
55
55
  fetcher: CdnFetcher | None = None,
56
56
  metrics_flusher: EvaluationMetricsFlusher | None = None,
@@ -59,7 +59,7 @@ class DynatraceProvider(AbstractProvider):
59
59
  metrics_flush_interval_s: float = _METRICS_FLUSH_INTERVAL_S,
60
60
  ) -> None:
61
61
  options = DynatraceProviderOptions.from_sdk_key(
62
- sdk_key, config_origin=config_origin, metrics_url=metrics_url
62
+ sdk_key, config_origin=config_origin, metrics_origin=metrics_origin
63
63
  )
64
64
  if fetcher is None and poll_interval_s <= _REQUEST_TIMEOUT_S:
65
65
  raise ValueError(