harness-sdk 1.0.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 (95) hide show
  1. harness_sdk-1.0.0/LICENSE.md +202 -0
  2. harness_sdk-1.0.0/NOTICE.md +28 -0
  3. harness_sdk-1.0.0/PKG-INFO +318 -0
  4. harness_sdk-1.0.0/README.md +252 -0
  5. harness_sdk-1.0.0/pyproject.toml +107 -0
  6. harness_sdk-1.0.0/setup.cfg +4 -0
  7. harness_sdk-1.0.0/setup.py +101 -0
  8. harness_sdk-1.0.0/src/harness_sdk/__init__.py +5 -0
  9. harness_sdk-1.0.0/src/harness_sdk/agent.py +171 -0
  10. harness_sdk-1.0.0/src/harness_sdk/agent_init.py +151 -0
  11. harness_sdk-1.0.0/src/harness_sdk/autoinstrumentation/__init__.py +0 -0
  12. harness_sdk-1.0.0/src/harness_sdk/autoinstrumentation/sitecustomize.py +30 -0
  13. harness_sdk-1.0.0/src/harness_sdk/autoinstrumentation/wrapper.py +78 -0
  14. harness_sdk-1.0.0/src/harness_sdk/config/__init__.py +0 -0
  15. harness_sdk-1.0.0/src/harness_sdk/config/config.py +152 -0
  16. harness_sdk-1.0.0/src/harness_sdk/config/config_pb2.py +112 -0
  17. harness_sdk-1.0.0/src/harness_sdk/config/default.py +58 -0
  18. harness_sdk-1.0.0/src/harness_sdk/config/environment.py +149 -0
  19. harness_sdk-1.0.0/src/harness_sdk/constants.py +9 -0
  20. harness_sdk-1.0.0/src/harness_sdk/custom_logger.py +43 -0
  21. harness_sdk-1.0.0/src/harness_sdk/env.py +10 -0
  22. harness_sdk-1.0.0/src/harness_sdk/excluded_by_attribute_span_processor.py +40 -0
  23. harness_sdk-1.0.0/src/harness_sdk/gen_ai/__init__.py +7 -0
  24. harness_sdk-1.0.0/src/harness_sdk/gen_ai/exceptions.py +17 -0
  25. harness_sdk-1.0.0/src/harness_sdk/instrumentation/__init__.py +222 -0
  26. harness_sdk-1.0.0/src/harness_sdk/instrumentation/aiohttp/__init__.py +218 -0
  27. harness_sdk-1.0.0/src/harness_sdk/instrumentation/anthropic/__init__.py +379 -0
  28. harness_sdk-1.0.0/src/harness_sdk/instrumentation/botocore/__init__.py +11 -0
  29. harness_sdk-1.0.0/src/harness_sdk/instrumentation/django/__init__.py +77 -0
  30. harness_sdk-1.0.0/src/harness_sdk/instrumentation/django/django_auto_instrumentation_compat.py +70 -0
  31. harness_sdk-1.0.0/src/harness_sdk/instrumentation/fast_api/__init__.py +222 -0
  32. harness_sdk-1.0.0/src/harness_sdk/instrumentation/fast_api/fast_api_auto_instrumentation_compat.py +65 -0
  33. harness_sdk-1.0.0/src/harness_sdk/instrumentation/flask/__init__.py +187 -0
  34. harness_sdk-1.0.0/src/harness_sdk/instrumentation/genai_env.py +71 -0
  35. harness_sdk-1.0.0/src/harness_sdk/instrumentation/grpc/__init__.py +266 -0
  36. harness_sdk-1.0.0/src/harness_sdk/instrumentation/httpx/__init__.py +73 -0
  37. harness_sdk-1.0.0/src/harness_sdk/instrumentation/httpx/utils.py +160 -0
  38. harness_sdk-1.0.0/src/harness_sdk/instrumentation/instrumentation_definitions.py +190 -0
  39. harness_sdk-1.0.0/src/harness_sdk/instrumentation/litellm/__init__.py +401 -0
  40. harness_sdk-1.0.0/src/harness_sdk/instrumentation/mcp/__init__.py +40 -0
  41. harness_sdk-1.0.0/src/harness_sdk/instrumentation/mcp/gen_ai_mirror.py +204 -0
  42. harness_sdk-1.0.0/src/harness_sdk/instrumentation/mysql/__init__.py +11 -0
  43. harness_sdk-1.0.0/src/harness_sdk/instrumentation/openai/__init__.py +340 -0
  44. harness_sdk-1.0.0/src/harness_sdk/instrumentation/postgresql/__init__.py +13 -0
  45. harness_sdk-1.0.0/src/harness_sdk/instrumentation/requests/__init__.py +40 -0
  46. harness_sdk-1.0.0/src/harness_sdk/otlp_reporting.py +75 -0
  47. harness_sdk-1.0.0/src/harness_sdk/plugins/__init__.py +12 -0
  48. harness_sdk-1.0.0/src/harness_sdk/plugins/builtin/__init__.py +1 -0
  49. harness_sdk-1.0.0/src/harness_sdk/plugins/builtin/pipeline.py +56 -0
  50. harness_sdk-1.0.0/src/harness_sdk/plugins/builtin/span_attributes.py +26 -0
  51. harness_sdk-1.0.0/src/harness_sdk/plugins/control.py +132 -0
  52. harness_sdk-1.0.0/src/harness_sdk/plugins/loader.py +105 -0
  53. harness_sdk-1.0.0/src/harness_sdk/plugins/observability.py +23 -0
  54. harness_sdk-1.0.0/src/harness_sdk/sampling_span_processor.py +42 -0
  55. harness_sdk-1.0.0/src/harness_sdk/span_attributes_processor.py +19 -0
  56. harness_sdk-1.0.0/src/harness_sdk/version.py +1 -0
  57. harness_sdk-1.0.0/src/harness_sdk.egg-info/PKG-INFO +318 -0
  58. harness_sdk-1.0.0/src/harness_sdk.egg-info/SOURCES.txt +93 -0
  59. harness_sdk-1.0.0/src/harness_sdk.egg-info/dependency_links.txt +1 -0
  60. harness_sdk-1.0.0/src/harness_sdk.egg-info/entry_points.txt +6 -0
  61. harness_sdk-1.0.0/src/harness_sdk.egg-info/requires.txt +58 -0
  62. harness_sdk-1.0.0/src/harness_sdk.egg-info/top_level.txt +2 -0
  63. harness_sdk-1.0.0/src/opentelemetry/instrumentation/anthropic/__init__.py +119 -0
  64. harness_sdk-1.0.0/src/opentelemetry/instrumentation/anthropic/messages_extractors.py +251 -0
  65. harness_sdk-1.0.0/src/opentelemetry/instrumentation/anthropic/package.py +15 -0
  66. harness_sdk-1.0.0/src/opentelemetry/instrumentation/anthropic/patch.py +131 -0
  67. harness_sdk-1.0.0/src/opentelemetry/instrumentation/anthropic/utils.py +243 -0
  68. harness_sdk-1.0.0/src/opentelemetry/instrumentation/anthropic/version.py +15 -0
  69. harness_sdk-1.0.0/src/opentelemetry/instrumentation/anthropic/wrappers.py +435 -0
  70. harness_sdk-1.0.0/src/opentelemetry/instrumentation/openai_v2/__init__.py +168 -0
  71. harness_sdk-1.0.0/src/opentelemetry/instrumentation/openai_v2/instruments.py +52 -0
  72. harness_sdk-1.0.0/src/opentelemetry/instrumentation/openai_v2/package.py +18 -0
  73. harness_sdk-1.0.0/src/opentelemetry/instrumentation/openai_v2/patch.py +952 -0
  74. harness_sdk-1.0.0/src/opentelemetry/instrumentation/openai_v2/response_extractors.py +419 -0
  75. harness_sdk-1.0.0/src/opentelemetry/instrumentation/openai_v2/response_wrappers.py +467 -0
  76. harness_sdk-1.0.0/src/opentelemetry/instrumentation/openai_v2/utils.py +502 -0
  77. harness_sdk-1.0.0/src/opentelemetry/instrumentation/openai_v2/version.py +15 -0
  78. harness_sdk-1.0.0/src/opentelemetry/util/genai/__init__.py +13 -0
  79. harness_sdk-1.0.0/src/opentelemetry/util/genai/_embedding_invocation.py +123 -0
  80. harness_sdk-1.0.0/src/opentelemetry/util/genai/_inference_invocation.py +358 -0
  81. harness_sdk-1.0.0/src/opentelemetry/util/genai/_invocation.py +140 -0
  82. harness_sdk-1.0.0/src/opentelemetry/util/genai/_tool_invocation.py +96 -0
  83. harness_sdk-1.0.0/src/opentelemetry/util/genai/_upload/__init__.py +90 -0
  84. harness_sdk-1.0.0/src/opentelemetry/util/genai/_upload/completion_hook.py +404 -0
  85. harness_sdk-1.0.0/src/opentelemetry/util/genai/_workflow_invocation.py +115 -0
  86. harness_sdk-1.0.0/src/opentelemetry/util/genai/completion_hook.py +126 -0
  87. harness_sdk-1.0.0/src/opentelemetry/util/genai/environment_variables.py +71 -0
  88. harness_sdk-1.0.0/src/opentelemetry/util/genai/handler.py +335 -0
  89. harness_sdk-1.0.0/src/opentelemetry/util/genai/instruments.py +54 -0
  90. harness_sdk-1.0.0/src/opentelemetry/util/genai/invocation.py +47 -0
  91. harness_sdk-1.0.0/src/opentelemetry/util/genai/metrics.py +54 -0
  92. harness_sdk-1.0.0/src/opentelemetry/util/genai/types.py +255 -0
  93. harness_sdk-1.0.0/src/opentelemetry/util/genai/utils.py +143 -0
  94. harness_sdk-1.0.0/src/opentelemetry/util/genai/version.py +15 -0
  95. harness_sdk-1.0.0/test/test_plugin_loader.py +128 -0
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2026 Harness, Inc.
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,28 @@
1
+ # NOTICE
2
+
3
+ ## harness-sdk
4
+
5
+ Copyright 2026 Harness, Inc.
6
+
7
+ Licensed under the Apache License, Version 2.0.
8
+ See [LICENSE.md](LICENSE.md) for the full license text.
9
+
10
+ ## Third-party software
11
+
12
+ This product bundles portions of the following third-party works under the
13
+ Apache License, Version 2.0. Source is vendored from the OpenTelemetry Python
14
+ Contrib repository at build time and distributed under the `opentelemetry`
15
+ namespace in release artifacts.
16
+
17
+ ### OpenTelemetry Python Contrib — GenAI instrumentation
18
+
19
+ Copyright The OpenTelemetry Authors
20
+
21
+ Components included in distributions:
22
+
23
+ - `opentelemetry.util.genai` (from `opentelemetry-util-genai`)
24
+ - `opentelemetry.instrumentation.anthropic` (from `opentelemetry-instrumentation-anthropic`)
25
+ - `opentelemetry.instrumentation.openai_v2` (from `opentelemetry-instrumentation-openai-v2`)
26
+
27
+ - Source: https://github.com/open-telemetry/opentelemetry-python-contrib
28
+ - License: Apache License, Version 2.0 (see [LICENSE.md](LICENSE.md))
@@ -0,0 +1,318 @@
1
+ Metadata-Version: 2.4
2
+ Name: harness-sdk
3
+ Version: 1.0.0
4
+ Summary: Harness Python SDK with instrumentation and plugin architecture
5
+ License-Expression: Apache-2.0
6
+ Requires-Python: >=3.10
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE.md
9
+ License-File: NOTICE.md
10
+ Requires-Dist: opentelemetry-api==1.41.1
11
+ Requires-Dist: opentelemetry-exporter-otlp==1.41.1
12
+ Requires-Dist: opentelemetry-instrumentation==0.62b1
13
+ Requires-Dist: opentelemetry-instrumentation-aiohttp-client==0.62b1
14
+ Requires-Dist: opentelemetry-instrumentation-botocore==0.62b1
15
+ Requires-Dist: opentelemetry-instrumentation-wsgi==0.62b1
16
+ Requires-Dist: opentelemetry-instrumentation-fastapi==0.62b1
17
+ Requires-Dist: opentelemetry-instrumentation-flask==0.62b1
18
+ Requires-Dist: opentelemetry-instrumentation-mysql==0.62b1
19
+ Requires-Dist: opentelemetry-instrumentation-psycopg2==0.62b1
20
+ Requires-Dist: opentelemetry-instrumentation-requests==0.62b1
21
+ Requires-Dist: opentelemetry-instrumentation-httpx==0.62b1
22
+ Requires-Dist: opentelemetry-instrumentation-grpc==0.62b1
23
+ Requires-Dist: opentelemetry-instrumentation-django==0.62b1
24
+ Requires-Dist: opentelemetry-instrumentation-mcp==0.60.0
25
+ Requires-Dist: opentelemetry-semantic-conventions-ai<0.6.0,>=0.5.1
26
+ Requires-Dist: opentelemetry-propagator-b3==1.41.1
27
+ Requires-Dist: opentelemetry-proto==1.41.1
28
+ Requires-Dist: opentelemetry-sdk==1.41.1
29
+ Requires-Dist: opentelemetry-util-http==0.62b1
30
+ Requires-Dist: google>=3.0.0
31
+ Requires-Dist: pyyaml
32
+ Requires-Dist: protobuf
33
+ Requires-Dist: psutil
34
+ Requires-Dist: distro
35
+ Requires-Dist: setuptools
36
+ Requires-Dist: jaraco.text
37
+ Requires-Dist: platformdirs
38
+ Provides-Extra: anthropic
39
+ Requires-Dist: anthropic>=0.34.0; extra == "anthropic"
40
+ Provides-Extra: openai
41
+ Requires-Dist: openai>=1.40.0; extra == "openai"
42
+ Provides-Extra: litellm
43
+ Requires-Dist: litellm>=1.60.0; extra == "litellm"
44
+ Provides-Extra: dev
45
+ Requires-Dist: pytest==7.4.3; extra == "dev"
46
+ Requires-Dist: pytest-cov==3.0.0; extra == "dev"
47
+ Requires-Dist: pytest-asyncio; extra == "dev"
48
+ Requires-Dist: pytest-django==4.12.0; extra == "dev"
49
+ Requires-Dist: flask==3.1.3; extra == "dev"
50
+ Requires-Dist: Werkzeug==3.1.8; extra == "dev"
51
+ Requires-Dist: aiohttp; extra == "dev"
52
+ Requires-Dist: fastapi>=0.75.0; extra == "dev"
53
+ Requires-Dist: psycopg2-binary; extra == "dev"
54
+ Requires-Dist: mysql-connector-python==8.0.26; extra == "dev"
55
+ Requires-Dist: boto3==1.35.43; extra == "dev"
56
+ Requires-Dist: moto==3.0.3; extra == "dev"
57
+ Requires-Dist: docker; extra == "dev"
58
+ Requires-Dist: httpx; extra == "dev"
59
+ Requires-Dist: Django==5.2.13; extra == "dev"
60
+ Requires-Dist: anthropic>=0.34.0; extra == "dev"
61
+ Requires-Dist: openai>=1.40.0; extra == "dev"
62
+ Requires-Dist: litellm>=1.60.0; extra == "dev"
63
+ Requires-Dist: grpcio; extra == "dev"
64
+ Dynamic: license-file
65
+ Dynamic: requires-python
66
+
67
+ # harness-sdk (otel-python-sdk)
68
+
69
+ Generic Python agent SDK with OpenTelemetry instrumentation and a plugin architecture.
70
+
71
+ ## Local development
72
+
73
+ ```bash
74
+ bash scripts/fetch-vendor.sh
75
+ pip install -e ".[dev,anthropic,openai,litellm]"
76
+ ./scripts/run-unit-tests.sh
77
+ ```
78
+
79
+ Environment variables for SDK configuration use the `HA_` prefix (for example `HA_SERVICE_NAME`, `HA_REPORTING_ENDPOINT`).
80
+
81
+ ### Integration tests (MySQL / PostgreSQL)
82
+
83
+ ```bash
84
+ cd test/externalServices && docker compose up -d --wait
85
+ cd ../..
86
+ RUN_SDK_INTEGRATION_TESTS=1 ./scripts/run-unit-tests.sh
87
+ ```
88
+
89
+ ## CI
90
+
91
+ GitHub Actions workflows (public repo, `ubuntu-latest`):
92
+
93
+ | Workflow | Trigger | Purpose |
94
+ |----------|---------|---------|
95
+ | [pr_build.yaml](.github/workflows/pr_build.yaml) | PR + push to `main` | Build manylinux wheels, lint, pytest (with Docker for DB tests) |
96
+ | [publish.yaml](.github/workflows/publish.yaml) | Tag `v*.*.*` | Build release artifacts and publish to PyPI / TestPyPI |
97
+ | [staticanalysis.yaml](.github/workflows/staticanalysis.yaml) | PR, `main`, weekly | Trivy filesystem scan |
98
+
99
+ ## Publishing to PyPI
100
+
101
+ 1. Configure [trusted publishing](https://docs.pypi.org/trusted-publishers/) on PyPI (and TestPyPI for RCs):
102
+ - **PyPI**: environment `pypi`, workflow `publish.yaml`, job `publish-pypi`
103
+ - **TestPyPI**: environment `testpypi`, workflow `publish.yaml`, job `publish-testpypi`
104
+ 2. Create and push a release tag:
105
+ ```bash
106
+ git tag v0.1.0
107
+ git push origin v0.1.0
108
+ ```
109
+ 3. Release candidates (`v1.0.0-rc.1`) publish to **TestPyPI** only; stable tags publish to **PyPI**.
110
+
111
+ Version is taken from the tag (`v1.2.3` → `1.2.3`) via `scripts/build.sh`, which updates `src/harness_sdk/version.py` and `pyproject.toml`.
112
+
113
+ ## Installing
114
+
115
+ ### From PyPI (stable releases)
116
+
117
+ ```bash
118
+ pip install harness-sdk
119
+ ```
120
+
121
+ Optional instrumentation extras:
122
+
123
+ ```bash
124
+ pip install "harness-sdk[anthropic,openai,litellm]"
125
+ ```
126
+
127
+ ### From TestPyPI (release candidates)
128
+
129
+ Tags containing `-rc` (for example `v1.0.0-rc.1`) are published only to [TestPyPI](https://test.pypi.org/project/harness-sdk/). Use TestPyPI as the primary index and PyPI as a fallback so dependencies that are not on TestPyPI still resolve:
130
+
131
+ ```bash
132
+ pip install \
133
+ --index-url https://test.pypi.org/simple/ \
134
+ --extra-index-url https://pypi.org/simple/ \
135
+ "harness-sdk==1.0.0-rc.1"
136
+ ```
137
+
138
+ With optional extras:
139
+
140
+ ```bash
141
+ pip install \
142
+ --index-url https://test.pypi.org/simple/ \
143
+ --extra-index-url https://pypi.org/simple/ \
144
+ "harness-sdk[anthropic,openai,litellm]==1.0.0-rc.1"
145
+ ```
146
+
147
+ Pin the version to the RC you want (see [published files](https://test.pypi.org/project/harness-sdk/#history) on TestPyPI). The version string matches the tag without the leading `v` (tag `v1.0.0-rc.1` → `1.0.0-rc.1`). In a virtualenv or `requirements.txt`, the same flags apply:
148
+
149
+ ```text
150
+ --index-url https://test.pypi.org/simple/
151
+ --extra-index-url https://pypi.org/simple/
152
+ harness-sdk==1.0.0-rc.1
153
+ ```
154
+
155
+ After install, import and auto-instrument work the same as a PyPI release:
156
+
157
+ ```python
158
+ from harness_sdk.agent import Agent
159
+ ```
160
+
161
+ ```bash
162
+ harness-instrument python app.py
163
+ ```
164
+
165
+ ## Usage
166
+
167
+ ```python
168
+ from harness_sdk.agent import Agent
169
+
170
+ agent = Agent()
171
+ agent.instrument()
172
+ ```
173
+
174
+ Auto-instrumentation:
175
+
176
+ ```bash
177
+ export HA_CONFIG_FILE=/path/to/config.yaml
178
+ harness-instrument python app.py
179
+ ```
180
+
181
+ ## Plugins
182
+
183
+ The SDK loads extensions via [setuptools entry points](https://setuptools.pypa.io/en/latest/userguide/entry_point.html). Each plugin has a **name** (the entry-point key). Names are listed in config or environment variables; only installed plugins are loaded, in the order you configure.
184
+
185
+ | Type | Entry-point group | Config key / env |
186
+ |------|-------------------|------------------|
187
+ | Control | `harness_sdk_control_plugin` | `plugins.control` / `HA_CONTROL_PLUGINS` |
188
+ | Observability | `harness_sdk_observability_plugin` | `plugins.observability` / `HA_OBSERVABILITY_PLUGINS` |
189
+
190
+ Built-in observability plugins (shipped with `harness-sdk`):
191
+
192
+ - `builtin_pipeline` — OTLP export, sampling, exclusion processors
193
+ - `builtin_span_attributes` — service name and configured span attributes
194
+
195
+ Example `agent-config.yaml`:
196
+
197
+ ```yaml
198
+ service_name: my-service
199
+ reporting:
200
+ endpoint: http://localhost:4318
201
+ plugins:
202
+ control:
203
+ - my_policy # order matters: first plugin runs first
204
+ observability:
205
+ - builtin_pipeline
206
+ - builtin_span_attributes
207
+ - my_exporter # custom plugin after builtins
208
+ ```
209
+
210
+ Or via environment (comma-separated, same order semantics):
211
+
212
+ ```bash
213
+ export HA_CONTROL_PLUGINS=my_policy
214
+ export HA_OBSERVABILITY_PLUGINS=builtin_pipeline,builtin_span_attributes,my_exporter
215
+ ```
216
+
217
+ ### Create a control plugin
218
+
219
+ Control plugins evaluate HTTP/gRPC ingress and GenAI spans. They return a `ControlResult` (block, headers, span attributes, etc.). Plugins run in config order; the chain stops when one returns `block=True`.
220
+
221
+ 1. **Implement the plugin** in your package (see `harness_sdk.plugins.control.ControlPlugin`):
222
+
223
+ ```python
224
+ # my_company_policy/plugin.py
225
+ from typing import Any
226
+ from opentelemetry.trace import Span
227
+ from harness_sdk.plugins.control import ControlResult, ControlPlugin
228
+
229
+
230
+ class MyPolicyPlugin:
231
+ name = "my_policy"
232
+ provides_blocking = True # set True if this plugin can block requests
233
+
234
+ def on_init(self, config: Any) -> None:
235
+ self._config = config
236
+
237
+ def evaluate(
238
+ self, span: Span, url: str, headers: dict, body, is_grpc: bool
239
+ ) -> ControlResult:
240
+ result = ControlResult()
241
+ # result.block = True
242
+ # result.response_status_code = 403
243
+ return result
244
+
245
+ def evaluate_agent_span(self, span: Span, body: str = "") -> ControlResult:
246
+ return ControlResult()
247
+
248
+ def shutdown(self) -> None:
249
+ pass
250
+
251
+
252
+ def factory(config: Any) -> ControlPlugin:
253
+ return MyPolicyPlugin()
254
+ ```
255
+
256
+ 2. **Register the entry point** in your package `pyproject.toml`:
257
+
258
+ ```toml
259
+ [project.entry-points.harness_sdk_control_plugin]
260
+ my_policy = "my_company_policy.plugin:factory"
261
+ ```
262
+
263
+ (Equivalent in `setup.py`: `entry_points={'harness_sdk_control_plugin': ['my_policy = ...']}`.)
264
+
265
+ 3. **Install** your package in the same environment as the app (`pip install my-company-policy`).
266
+
267
+ 4. **Enable** the plugin by name in config or `HA_CONTROL_PLUGINS` (see above).
268
+
269
+ For tests or one-off wiring you can also call `agent.register_control_plugin(plugin)` after `Agent()` is constructed.
270
+
271
+ Reference implementation: the Traceable agent ships a control plugin as `traceable` (`traceableai.plugins.traceable_control:factory`).
272
+
273
+ ### Create an observability plugin
274
+
275
+ Observability plugins contribute OpenTelemetry `SpanProcessor` instances to the tracer provider. Processors are registered in config order (each plugin’s `create_span_processors` may return multiple processors).
276
+
277
+ 1. **Implement the plugin** (see `harness_sdk.plugins.observability.ObservabilityPlugin`):
278
+
279
+ ```python
280
+ # my_company_telemetry/plugin.py
281
+ from typing import Any, List
282
+ from opentelemetry.sdk.trace import SpanProcessor
283
+ from opentelemetry.sdk.trace.export import ConsoleSpanExporter, SimpleSpanProcessor
284
+
285
+
286
+ class MyExporterPlugin:
287
+ name = "my_exporter"
288
+ priority = 300 # informational; ordering is driven by config list
289
+
290
+ def on_init(self, config: Any) -> None:
291
+ self._config = config
292
+
293
+ def create_span_processors(self, config: Any) -> List[SpanProcessor]:
294
+ return [SimpleSpanProcessor(ConsoleSpanExporter())]
295
+
296
+ def shutdown(self) -> None:
297
+ pass
298
+
299
+
300
+ def factory(config: Any) -> MyExporterPlugin:
301
+ return MyExporterPlugin()
302
+ ```
303
+
304
+ 2. **Register the entry point**:
305
+
306
+ ```toml
307
+ [project.entry-points.harness_sdk_observability_plugin]
308
+ my_exporter = "my_company_telemetry.plugin:factory"
309
+ ```
310
+
311
+ 3. **Install** your package and **enable** it under `plugins.observability` or `HA_OBSERVABILITY_PLUGINS`.
312
+
313
+ If you omit observability plugins entirely, the SDK defaults to `builtin_pipeline` and `builtin_span_attributes`. Custom plugins typically keep those builtins and append your entry after them.
314
+
315
+ Reference implementations in this repo:
316
+
317
+ - `harness_sdk.plugins.builtin.pipeline`
318
+ - `harness_sdk.plugins.builtin.span_attributes`