@zuplo/cli 7.14.8 → 7.15.1

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 (118) hide show
  1. package/LICENSE.third-party.txt +236 -0
  2. package/LICENSE.txt +5 -78
  3. package/README.md +18 -3
  4. package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/jwe/general/decrypt.js +3 -2
  5. package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/jwks/remote.js +1 -1
  6. package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/jws/general/verify.js +2 -8
  7. package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/lib/jwe_decrypt.js +11 -8
  8. package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/lib/jwt_claims_set.js +2 -0
  9. package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/lib/key_management.js +0 -1
  10. package/node_modules/@modelcontextprotocol/client/node_modules/jose/package.json +1 -1
  11. package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jwe/general/decrypt.js +3 -2
  12. package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jwks/remote.js +1 -1
  13. package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jws/general/verify.js +2 -8
  14. package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/jwe_decrypt.js +11 -8
  15. package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/jwt_claims_set.js +2 -0
  16. package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/key_management.js +0 -1
  17. package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/package.json +1 -1
  18. package/node_modules/@posthog/core/dist/privacy.d.ts +6 -1
  19. package/node_modules/@posthog/core/dist/privacy.d.ts.map +1 -1
  20. package/node_modules/@posthog/core/dist/privacy.js +69 -10
  21. package/node_modules/@posthog/core/dist/privacy.mjs +65 -9
  22. package/node_modules/@posthog/core/dist/traces/span.d.ts +6 -0
  23. package/node_modules/@posthog/core/dist/traces/span.d.ts.map +1 -1
  24. package/node_modules/@posthog/core/dist/traces/span.js +18 -0
  25. package/node_modules/@posthog/core/dist/traces/span.mjs +18 -0
  26. package/node_modules/@posthog/core/package.json +2 -2
  27. package/node_modules/@posthog/core/src/privacy.ts +100 -18
  28. package/node_modules/@posthog/core/src/traces/span.spec.ts +15 -1
  29. package/node_modules/@posthog/core/src/traces/span.ts +23 -0
  30. package/node_modules/@posthog/types/dist/traces.d.ts +10 -0
  31. package/node_modules/@posthog/types/dist/traces.d.ts.map +1 -1
  32. package/node_modules/@posthog/types/package.json +1 -1
  33. package/node_modules/@posthog/types/src/traces.ts +12 -0
  34. package/node_modules/@zuplo/core/LICENSE.third-party.txt +622 -0
  35. package/node_modules/@zuplo/core/LICENSE.txt +5 -78
  36. package/node_modules/@zuplo/core/README.md +7 -0
  37. package/node_modules/@zuplo/core/constants.minified.js +7 -20
  38. package/node_modules/@zuplo/core/customer.cli.minified.js +28 -41
  39. package/node_modules/@zuplo/core/index.minified.js +35 -48
  40. package/node_modules/@zuplo/core/package.json +4 -2
  41. package/node_modules/@zuplo/core/zeno.js +8 -21
  42. package/node_modules/@zuplo/graphql/LICENSE.third-party.txt +29 -0
  43. package/node_modules/@zuplo/graphql/LICENSE.txt +5 -78
  44. package/node_modules/@zuplo/graphql/README.md +7 -0
  45. package/node_modules/@zuplo/graphql/out/esm/index.js +7 -20
  46. package/node_modules/@zuplo/graphql/out/esm/index.js.map +1 -1
  47. package/node_modules/@zuplo/graphql/package.json +3 -2
  48. package/node_modules/@zuplo/openapi-tools/LICENSE.txt +7 -0
  49. package/node_modules/@zuplo/openapi-tools/README.md +7 -0
  50. package/node_modules/@zuplo/openapi-tools/package.json +3 -2
  51. package/node_modules/@zuplo/otel/LICENSE.third-party.txt +243 -0
  52. package/node_modules/@zuplo/otel/LICENSE.txt +5 -78
  53. package/node_modules/@zuplo/otel/README.md +33 -0
  54. package/node_modules/@zuplo/otel/out/esm/chunk-6YAK7LGJ.js +13 -0
  55. package/node_modules/@zuplo/otel/out/esm/chunk-6YAK7LGJ.js.map +1 -0
  56. package/node_modules/@zuplo/otel/out/esm/index.js +8 -21
  57. package/node_modules/@zuplo/otel/out/types/index.d.ts +41 -0
  58. package/node_modules/@zuplo/otel/package.json +3 -2
  59. package/node_modules/@zuplo/runtime/LICENSE.third-party.txt +511 -0
  60. package/node_modules/@zuplo/runtime/LICENSE.txt +5 -78
  61. package/node_modules/@zuplo/runtime/README.md +7 -0
  62. package/node_modules/@zuplo/runtime/out/esm/chunk-5JGLAPFA.js +13 -0
  63. package/node_modules/@zuplo/runtime/out/esm/chunk-5JGLAPFA.js.map +1 -0
  64. package/node_modules/@zuplo/runtime/out/esm/{chunk-6R2COTV6.js → chunk-AJ3MMWJS.js} +9 -22
  65. package/node_modules/@zuplo/runtime/out/esm/chunk-AJ3MMWJS.js.map +1 -0
  66. package/node_modules/@zuplo/runtime/out/esm/chunk-BH4DKEES.js +13 -0
  67. package/node_modules/@zuplo/runtime/out/esm/chunk-BH4DKEES.js.map +1 -0
  68. package/node_modules/@zuplo/runtime/out/esm/chunk-G42UYZ6V.js +24 -0
  69. package/node_modules/@zuplo/runtime/out/esm/{chunk-2HVCLUM4.js.map → chunk-G42UYZ6V.js.map} +1 -1
  70. package/node_modules/@zuplo/runtime/out/esm/chunk-OE2WMJXK.js +431 -0
  71. package/node_modules/@zuplo/runtime/out/esm/chunk-OE2WMJXK.js.map +1 -0
  72. package/node_modules/@zuplo/runtime/out/esm/chunk-R6UNMRUU.js +13 -0
  73. package/node_modules/@zuplo/runtime/out/esm/chunk-R6UNMRUU.js.map +1 -0
  74. package/node_modules/@zuplo/runtime/out/esm/{chunk-PY52EHDX.js → chunk-T2WKOG7J.js} +9 -22
  75. package/node_modules/@zuplo/runtime/out/esm/chunk-T2WKOG7J.js.map +1 -0
  76. package/node_modules/@zuplo/runtime/out/esm/{chunk-SNTU476S.js → chunk-TOJD4RET.js} +9 -22
  77. package/node_modules/@zuplo/runtime/out/esm/chunk-TOJD4RET.js.map +1 -0
  78. package/node_modules/@zuplo/runtime/out/esm/chunk-VXPFMOL5.js +13 -0
  79. package/node_modules/@zuplo/runtime/out/esm/chunk-VXPFMOL5.js.map +1 -0
  80. package/node_modules/@zuplo/runtime/out/esm/index.js +8 -21
  81. package/node_modules/@zuplo/runtime/out/esm/index.js.map +1 -1
  82. package/node_modules/@zuplo/runtime/out/esm/internal/index.js +8 -21
  83. package/node_modules/@zuplo/runtime/out/esm/mcp/messages/index.js +8 -21
  84. package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js +11 -39
  85. package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js.map +1 -1
  86. package/node_modules/@zuplo/runtime/out/esm/mocks/index.js +8 -21
  87. package/node_modules/@zuplo/runtime/out/esm/mocks/index.js.map +1 -1
  88. package/node_modules/@zuplo/runtime/out/esm/sdks/aws/index.js +8 -21
  89. package/node_modules/@zuplo/runtime/out/esm/sdks/aws/index.js.map +1 -1
  90. package/node_modules/@zuplo/runtime/out/types/index.d.ts +248 -6
  91. package/node_modules/@zuplo/runtime/out/types/internal/index.d.ts +101 -0
  92. package/node_modules/@zuplo/runtime/out/types/mcp-gateway/index.d.ts +127 -0
  93. package/node_modules/@zuplo/runtime/package.json +3 -2
  94. package/node_modules/ansi-regex/index.js +22 -17
  95. package/node_modules/ansi-regex/package.json +1 -1
  96. package/node_modules/ansi-regex/readme.md +8 -0
  97. package/node_modules/express-rate-limit/dist/index.cjs +33 -4
  98. package/node_modules/express-rate-limit/dist/index.mjs +33 -4
  99. package/node_modules/express-rate-limit/package.json +1 -1
  100. package/package.json +12 -11
  101. package/node_modules/@zuplo/otel/out/esm/chunk-PVCAT62X.js +0 -26
  102. package/node_modules/@zuplo/otel/out/esm/chunk-PVCAT62X.js.map +0 -1
  103. package/node_modules/@zuplo/runtime/out/esm/chunk-2HVCLUM4.js +0 -37
  104. package/node_modules/@zuplo/runtime/out/esm/chunk-6R2COTV6.js.map +0 -1
  105. package/node_modules/@zuplo/runtime/out/esm/chunk-A3QGJZO7.js +0 -26
  106. package/node_modules/@zuplo/runtime/out/esm/chunk-A3QGJZO7.js.map +0 -1
  107. package/node_modules/@zuplo/runtime/out/esm/chunk-DB6LKZ36.js +0 -429
  108. package/node_modules/@zuplo/runtime/out/esm/chunk-DB6LKZ36.js.map +0 -1
  109. package/node_modules/@zuplo/runtime/out/esm/chunk-PY52EHDX.js.map +0 -1
  110. package/node_modules/@zuplo/runtime/out/esm/chunk-SNTU476S.js.map +0 -1
  111. package/node_modules/@zuplo/runtime/out/esm/chunk-TYV53J3B.js +0 -26
  112. package/node_modules/@zuplo/runtime/out/esm/chunk-TYV53J3B.js.map +0 -1
  113. package/node_modules/@zuplo/runtime/out/esm/chunk-UKQQD2JN.js +0 -26
  114. package/node_modules/@zuplo/runtime/out/esm/chunk-UKQQD2JN.js.map +0 -1
  115. package/node_modules/@zuplo/runtime/out/esm/chunk-VP5Q3DEN.js +0 -26
  116. package/node_modules/@zuplo/runtime/out/esm/chunk-VP5Q3DEN.js.map +0 -1
  117. /package/node_modules/@zuplo/runtime/out/esm/{chunk-2HVCLUM4.js.LEGAL.txt → chunk-G42UYZ6V.js.LEGAL.txt} +0 -0
  118. /package/node_modules/@zuplo/runtime/out/esm/{chunk-DB6LKZ36.js.LEGAL.txt → chunk-OE2WMJXK.js.LEGAL.txt} +0 -0
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@zuplo/graphql",
3
3
  "type": "module",
4
- "version": "7.14.8",
4
+ "version": "7.15.1",
5
5
  "repository": "https://github.com/zuplo/zuplo",
6
6
  "author": "Zuplo, Inc.",
7
7
  "exports": {
@@ -21,7 +21,8 @@
21
21
  "files": [
22
22
  "out/**/*",
23
23
  "README.md",
24
- "LICENSE.txt"
24
+ "LICENSE.txt",
25
+ "LICENSE.third-party.txt"
25
26
  ],
26
27
  "devDependencies": {
27
28
  "@types/node": "^22.13.4",
@@ -0,0 +1,7 @@
1
+ Copyright (c) Zuplo, Inc. All rights reserved.
2
+
3
+ Use of this software is governed by the Zuplo Terms of Service at
4
+ https://zuplo.com/legal/terms, or by a separate agreement your company has
5
+ signed with Zuplo.
6
+
7
+ See https://zuplo.com/legal/eula for more information.
@@ -1,3 +1,10 @@
1
1
  # @zuplo/openapi-tools
2
2
 
3
3
  Common tooling for OpenAPI files.
4
+
5
+ ## License
6
+
7
+ Copyright (c) Zuplo, Inc. All rights reserved. Use of this package is governed
8
+ by the [Zuplo Terms of Service](https://zuplo.com/legal/terms), or by a separate
9
+ agreement your company has signed with Zuplo. See `LICENSE.txt` and
10
+ [zuplo.com/legal/eula](https://zuplo.com/legal/eula).
@@ -2,7 +2,7 @@
2
2
  "name": "@zuplo/openapi-tools",
3
3
  "type": "module",
4
4
  "sideEffects": false,
5
- "version": "7.14.8",
5
+ "version": "7.15.1",
6
6
  "description": "Tooling for OpenAPI files",
7
7
  "repository": {
8
8
  "type": "git",
@@ -15,6 +15,7 @@
15
15
  }
16
16
  },
17
17
  "files": [
18
+ "LICENSE.txt",
18
19
  "dist/**/*",
19
20
  "*.js",
20
21
  "*.d.ts",
@@ -23,7 +24,7 @@
23
24
  "!dist/**/__tests__/**"
24
25
  ],
25
26
  "author": "Zuplo",
26
- "license": "Copyright 2021",
27
+ "license": "SEE LICENSE IN LICENSE.txt",
27
28
  "scripts": {
28
29
  "build": "tsc --build",
29
30
  "test": "node --test --enable-source-maps --test-reporter=../../scripts/test-reporter.mjs dist/**/*.spec.js",
@@ -0,0 +1,243 @@
1
+ This package includes code from the open source projects below, each
2
+ under its own license. The license texts follow.
3
+
4
+ ==============================================================================
5
+ OpenTelemetry JavaScript
6
+ https://github.com/open-telemetry/opentelemetry-js
7
+ ==============================================================================
8
+
9
+ Apache License
10
+ Version 2.0, January 2004
11
+ http://www.apache.org/licenses/
12
+
13
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
14
+
15
+ 1. Definitions.
16
+
17
+ "License" shall mean the terms and conditions for use, reproduction,
18
+ and distribution as defined by Sections 1 through 9 of this document.
19
+
20
+ "Licensor" shall mean the copyright owner or entity authorized by
21
+ the copyright owner that is granting the License.
22
+
23
+ "Legal Entity" shall mean the union of the acting entity and all
24
+ other entities that control, are controlled by, or are under common
25
+ control with that entity. For the purposes of this definition,
26
+ "control" means (i) the power, direct or indirect, to cause the
27
+ direction or management of such entity, whether by contract or
28
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
29
+ outstanding shares, or (iii) beneficial ownership of such entity.
30
+
31
+ "You" (or "Your") shall mean an individual or Legal Entity
32
+ exercising permissions granted by this License.
33
+
34
+ "Source" form shall mean the preferred form for making modifications,
35
+ including but not limited to software source code, documentation
36
+ source, and configuration files.
37
+
38
+ "Object" form shall mean any form resulting from mechanical
39
+ transformation or translation of a Source form, including but
40
+ not limited to compiled object code, generated documentation,
41
+ and conversions to other media types.
42
+
43
+ "Work" shall mean the work of authorship, whether in Source or
44
+ Object form, made available under the License, as indicated by a
45
+ copyright notice that is included in or attached to the work
46
+ (an example is provided in the Appendix below).
47
+
48
+ "Derivative Works" shall mean any work, whether in Source or Object
49
+ form, that is based on (or derived from) the Work and for which the
50
+ editorial revisions, annotations, elaborations, or other modifications
51
+ represent, as a whole, an original work of authorship. For the purposes
52
+ of this License, Derivative Works shall not include works that remain
53
+ separable from, or merely link (or bind by name) to the interfaces of,
54
+ the Work and Derivative Works thereof.
55
+
56
+ "Contribution" shall mean any work of authorship, including
57
+ the original version of the Work and any modifications or additions
58
+ to that Work or Derivative Works thereof, that is intentionally
59
+ submitted to Licensor for inclusion in the Work by the copyright owner
60
+ or by an individual or Legal Entity authorized to submit on behalf of
61
+ the copyright owner. For the purposes of this definition, "submitted"
62
+ means any form of electronic, verbal, or written communication sent
63
+ to the Licensor or its representatives, including but not limited to
64
+ communication on electronic mailing lists, source code control systems,
65
+ and issue tracking systems that are managed by, or on behalf of, the
66
+ Licensor for the purpose of discussing and improving the Work, but
67
+ excluding communication that is conspicuously marked or otherwise
68
+ designated in writing by the copyright owner as "Not a Contribution."
69
+
70
+ "Contributor" shall mean Licensor and any individual or Legal Entity
71
+ on behalf of whom a Contribution has been received by Licensor and
72
+ subsequently incorporated within the Work.
73
+
74
+ 2. Grant of Copyright 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
+ copyright license to reproduce, prepare Derivative Works of,
78
+ publicly display, publicly perform, sublicense, and distribute the
79
+ Work and such Derivative Works in Source or Object form.
80
+
81
+ 3. Grant of Patent License. Subject to the terms and conditions of
82
+ this License, each Contributor hereby grants to You a perpetual,
83
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
84
+ (except as stated in this section) patent license to make, have made,
85
+ use, offer to sell, sell, import, and otherwise transfer the Work,
86
+ where such license applies only to those patent claims licensable
87
+ by such Contributor that are necessarily infringed by their
88
+ Contribution(s) alone or by combination of their Contribution(s)
89
+ with the Work to which such Contribution(s) was submitted. If You
90
+ institute patent litigation against any entity (including a
91
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
92
+ or a Contribution incorporated within the Work constitutes direct
93
+ or contributory patent infringement, then any patent licenses
94
+ granted to You under this License for that Work shall terminate
95
+ as of the date such litigation is filed.
96
+
97
+ 4. Redistribution. You may reproduce and distribute copies of the
98
+ Work or Derivative Works thereof in any medium, with or without
99
+ modifications, and in Source or Object form, provided that You
100
+ meet the following conditions:
101
+
102
+ (a) You must give any other recipients of the Work or
103
+ Derivative Works a copy of this License; and
104
+
105
+ (b) You must cause any modified files to carry prominent notices
106
+ stating that You changed the files; and
107
+
108
+ (c) You must retain, in the Source form of any Derivative Works
109
+ that You distribute, all copyright, patent, trademark, and
110
+ attribution notices from the Source form of the Work,
111
+ excluding those notices that do not pertain to any part of
112
+ the Derivative Works; and
113
+
114
+ (d) If the Work includes a "NOTICE" text file as part of its
115
+ distribution, then any Derivative Works that You distribute must
116
+ include a readable copy of the attribution notices contained
117
+ within such NOTICE file, excluding those notices that do not
118
+ pertain to any part of the Derivative Works, in at least one
119
+ of the following places: within a NOTICE text file distributed
120
+ as part of the Derivative Works; within the Source form or
121
+ documentation, if provided along with the Derivative Works; or,
122
+ within a display generated by the Derivative Works, if and
123
+ wherever such third-party notices normally appear. The contents
124
+ of the NOTICE file are for informational purposes only and
125
+ do not modify the License. You may add Your own attribution
126
+ notices within Derivative Works that You distribute, alongside
127
+ or as an addendum to the NOTICE text from the Work, provided
128
+ that such additional attribution notices cannot be construed
129
+ as modifying the License.
130
+
131
+ You may add Your own copyright statement to Your modifications and
132
+ may provide additional or different license terms and conditions
133
+ for use, reproduction, or distribution of Your modifications, or
134
+ for any such Derivative Works as a whole, provided Your use,
135
+ reproduction, and distribution of the Work otherwise complies with
136
+ the conditions stated in this License.
137
+
138
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
139
+ any Contribution intentionally submitted for inclusion in the Work
140
+ by You to the Licensor shall be under the terms and conditions of
141
+ this License, without any additional terms or conditions.
142
+ Notwithstanding the above, nothing herein shall supersede or modify
143
+ the terms of any separate license agreement you may have executed
144
+ with Licensor regarding such Contributions.
145
+
146
+ 6. Trademarks. This License does not grant permission to use the trade
147
+ names, trademarks, service marks, or product names of the Licensor,
148
+ except as required for reasonable and customary use in describing the
149
+ origin of the Work and reproducing the content of the NOTICE file.
150
+
151
+ 7. Disclaimer of Warranty. Unless required by applicable law or
152
+ agreed to in writing, Licensor provides the Work (and each
153
+ Contributor provides its Contributions) on an "AS IS" BASIS,
154
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
155
+ implied, including, without limitation, any warranties or conditions
156
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
157
+ PARTICULAR PURPOSE. You are solely responsible for determining the
158
+ appropriateness of using or redistributing the Work and assume any
159
+ risks associated with Your exercise of permissions under this License.
160
+
161
+ 8. Limitation of Liability. In no event and under no legal theory,
162
+ whether in tort (including negligence), contract, or otherwise,
163
+ unless required by applicable law (such as deliberate and grossly
164
+ negligent acts) or agreed to in writing, shall any Contributor be
165
+ liable to You for damages, including any direct, indirect, special,
166
+ incidental, or consequential damages of any character arising as a
167
+ result of this License or out of the use or inability to use the
168
+ Work (including but not limited to damages for loss of goodwill,
169
+ work stoppage, computer failure or malfunction, or any and all
170
+ other commercial damages or losses), even if such Contributor
171
+ has been advised of the possibility of such damages.
172
+
173
+ 9. Accepting Warranty or Additional Liability. While redistributing
174
+ the Work or Derivative Works thereof, You may choose to offer,
175
+ and charge a fee for, acceptance of support, warranty, indemnity,
176
+ or other liability obligations and/or rights consistent with this
177
+ License. However, in accepting such obligations, You may act only
178
+ on Your own behalf and on Your sole responsibility, not on behalf
179
+ of any other Contributor, and only if You agree to indemnify,
180
+ defend, and hold each Contributor harmless for any liability
181
+ incurred by, or claims asserted against, such Contributor by reason
182
+ of your accepting any such warranty or additional liability.
183
+
184
+ END OF TERMS AND CONDITIONS
185
+
186
+ APPENDIX: How to apply the Apache License to your work.
187
+
188
+ To apply the Apache License to your work, attach the following
189
+ boilerplate notice, with the fields enclosed by brackets "[]"
190
+ replaced with your own identifying information. (Don't include
191
+ the brackets!) The text should be enclosed in the appropriate
192
+ comment syntax for the file format. We also recommend that a
193
+ file or class name and description of purpose be included on the
194
+ same "printed page" as the copyright notice for easier
195
+ identification within third-party archives.
196
+
197
+ Copyright [yyyy] [name of copyright owner]
198
+
199
+ Licensed under the Apache License, Version 2.0 (the "License");
200
+ you may not use this file except in compliance with the License.
201
+ You may obtain a copy of the License at
202
+
203
+ http://www.apache.org/licenses/LICENSE-2.0
204
+
205
+ Unless required by applicable law or agreed to in writing, software
206
+ distributed under the License is distributed on an "AS IS" BASIS,
207
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
208
+ See the License for the specific language governing permissions and
209
+ limitations under the License.
210
+
211
+ ==============================================================================
212
+ otel-cf-workers
213
+ https://github.com/evanderkoogh/otel-cf-workers/tree/d0e5e58b1e7d3d49b69e32b98050ac32ab259fd7
214
+ ==============================================================================
215
+
216
+ BSD 3-Clause License
217
+
218
+ Copyright (c) 2023, Erwin van der Koogh
219
+
220
+ Redistribution and use in source and binary forms, with or without
221
+ modification, are permitted provided that the following conditions are met:
222
+
223
+ 1. Redistributions of source code must retain the above copyright notice, this
224
+ list of conditions and the following disclaimer.
225
+
226
+ 2. Redistributions in binary form must reproduce the above copyright notice,
227
+ this list of conditions and the following disclaimer in the documentation
228
+ and/or other materials provided with the distribution.
229
+
230
+ 3. Neither the name of the copyright holder nor the names of its
231
+ contributors may be used to endorse or promote products derived from
232
+ this software without specific prior written permission.
233
+
234
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
235
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
236
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
237
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
238
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
239
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
240
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
241
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
242
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
243
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -1,80 +1,7 @@
1
- # End User License Agreement (EULA)
1
+ Copyright (c) Zuplo, Inc. All rights reserved.
2
2
 
3
- This End User License Agreement ("Agreement") is a legal agreement between you
4
- ("User") and **Zuplo, Inc.**, a Delaware corporation ("Zuplo"), governing the
5
- use of Zuplo’s proprietary software tool designed for local development (the
6
- "Software").
3
+ Use of this software is governed by the Zuplo Terms of Service at
4
+ https://zuplo.com/legal/terms, or by a separate agreement your company has
5
+ signed with Zuplo.
7
6
 
8
- By installing, copying, or otherwise using the Software, you agree to be bound
9
- by the terms of this Agreement. If you do not agree, do not install or use the
10
- Software.
11
-
12
- ## 1. License Grant
13
-
14
- Subject to the terms of this Agreement, Zuplo grants you a limited,
15
- non-exclusive, non-transferable, non-sublicensable license to use the Software
16
- **solely for internal local development purposes** and **only if you are an
17
- active customer of Zuplo**.
18
-
19
- ## 2. Restrictions
20
-
21
- You may **not**:
22
-
23
- - Distribute, sublicense, lease, rent, or otherwise make the Software available
24
- to any third party;
25
- - Use the Software for any commercial purpose other than in connection with your
26
- authorized use of Zuplo services;
27
- - Reverse engineer, decompile, disassemble, or attempt to derive the source code
28
- of the Software;
29
- - Use the Software if you are not a current customer of Zuplo.
30
-
31
- ## 3. Intellectual Property Ownership
32
-
33
- All intellectual property rights in and to the Software — including but not
34
- limited to all code, documentation, interfaces, design, and trademarks — are and
35
- shall remain the exclusive property of Zuplo and its licensors.
36
- This Agreement does not grant you any rights, title, or interest in or to any
37
- trademarks, trade secrets, copyrights, patents, or other intellectual property
38
- owned by Zuplo, except for the limited license expressly set forth in Section 1.
39
-
40
- Any feedback, suggestions, or improvements you provide regarding the Software
41
- may be freely used by Zuplo without any obligation to you.
42
-
43
- ## 4. Open Source Software Notice
44
-
45
- The Software may include or rely on components that are subject to separate open
46
- source licenses. These components are not governed by this Agreement but instead
47
- by their respective licenses.
48
-
49
- Copies of the applicable open source licenses are provided in the distribution
50
- of the Software.
51
-
52
- ## 5. Termination
53
-
54
- This license is effective until terminated. It will automatically terminate
55
- without notice if you cease to be a customer of Zuplo or fail to comply with any
56
- term of this Agreement. Upon termination, you must immediately cease all use of
57
- the Software and destroy all copies.
58
-
59
- ## 6. No Warranty
60
-
61
- The Software is provided "**as is**," without warranty of any kind, express or
62
- implied, including but not limited to the implied warranties of merchantability
63
- or fitness for a particular purpose.
64
-
65
- ## 7. Limitation of Liability
66
-
67
- In no event shall Zuplo be liable for any indirect, incidental, special, or
68
- consequential damages, or damages for loss of profits, revenue, data, or use,
69
- incurred by you or any third party, whether in an action in contract or tort,
70
- arising from your use of the Software.
71
-
72
- ## 8. Governing Law
73
-
74
- This Agreement is governed by and construed in accordance with the laws of the
75
- State of Delaware, without regard to its conflict of law principles.
76
-
77
- ## 9. Entire Agreement
78
-
79
- This Agreement constitutes the entire agreement between the parties with respect
80
- to the Software and supersedes all prior or contemporaneous understandings.
7
+ See https://zuplo.com/legal/eula for more information.
@@ -186,6 +186,32 @@ new OpenTelemetryPlugin({
186
186
  });
187
187
  ```
188
188
 
189
+ ## AI Gateway GenAI spans
190
+
191
+ AI Gateway routes record one OpenTelemetry GenAI inference span (`gen_ai.*`) for
192
+ each call to an LLM provider: the primary call, each fallback and each
193
+ rate-limit retry. Each span is named `{operation} {model}`, for example
194
+ `chat gpt-5`, and carries the provider, request parameters, response id, model
195
+ and finish reasons, and the token usage and cost AI Gateway meters.
196
+
197
+ Prompt and completion content is not recorded unless you turn it on:
198
+
199
+ ```ts
200
+ new OpenTelemetryPlugin({
201
+ exporter: { url: "https://collector.example.com/v1/traces" },
202
+ instrumentation: { genAi: { captureContent: true } },
203
+ });
204
+ ```
205
+
206
+ Content lands in `gen_ai.system_instructions`, `gen_ai.input.messages` and
207
+ `gen_ai.output.messages`, each capped at 8 KiB and kept valid JSON. Input is
208
+ recorded as sent to the provider, after policies such as DLP changed it. Output
209
+ is recorded as returned to the client, after every response-sending hook.
210
+ Well-known credential formats (API keys, bearer tokens, JWTs, private keys,
211
+ cloud and GitHub tokens) are replaced by placeholders such as
212
+ `[REDACTED:api_key]`. Personal data is not scrubbed: mask it with a DLP policy,
213
+ which runs before the content is recorded.
214
+
189
215
  ## Exports
190
216
 
191
217
  | Export | Purpose |
@@ -196,3 +222,10 @@ new OpenTelemetryPlugin({
196
222
  | `OTLPSpanExporter` | OTLP/HTTP span exporter; pair with a span processor. |
197
223
  | `OTLPExporterConfig` | Configuration (`url`, optional `headers`) for an OTLP exporter. |
198
224
  | `BatchTraceSpanProcessor` | Per-trace batching span processor; wrap an exporter to add a destination. |
225
+
226
+ ## License
227
+
228
+ Copyright (c) Zuplo, Inc. All rights reserved. Use of this package is governed
229
+ by the [Zuplo Terms of Service](https://zuplo.com/legal/terms), or by a separate
230
+ agreement your company has signed with Zuplo. See `LICENSE.txt` and
231
+ [zuplo.com/legal/eula](https://zuplo.com/legal/eula).
@@ -0,0 +1,13 @@
1
+
2
+ /*!
3
+ * Copyright (c) Zuplo, Inc. All rights reserved.
4
+ *
5
+ * Use of this software is governed by the Zuplo Terms of Service at
6
+ * https://zuplo.com/legal/terms, or by a separate agreement your company has
7
+ * signed with Zuplo.
8
+ *
9
+ * See https://zuplo.com/legal/eula for more information.
10
+ */
11
+
12
+ var nr=Object.defineProperty;var o=(t,e)=>nr(t,"name",{value:e,configurable:!0});import{Buffer as or}from"node:buffer";Object.assign(globalThis,{Buffer:or});import{ExportResultCode as pe}from"@opentelemetry/core";import{JsonLogsSerializer as ar,JsonTraceSerializer as cr}from"@opentelemetry/otlp-transformer";import{BackgroundDispatchError as F,BackgroundDispatcher as Ve}from"@zuplo/runtime";function sr(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}o(sr,"isPlainObject");function Me(t){if(t==null)return"";if(Array.isArray(t)){for(let e=0;e<t.length;e+=1)t[e]=Me(t[e]);return t}return sr(t)&&H(t),t}o(Me,"sanitizeValue");function H(t){Object.keys(t).forEach(e=>{t[e]=Me(t[e])})}o(H,"sanitizeEmptyAttributes");var ae=Symbol("unwrap");function Ue(t){return t&&!!t[ae]}o(Ue,"isWrapped");function ir(t){return t!==null&&typeof t=="object"||typeof t=="function"}o(ir,"isProxyable");function z(t,e,r=!0){if(Ue(t)||!ir(t))return t;let n=Object.assign({},e);return n.get=(s,i,a)=>{if(i===ae)return t;if(e.get)return e.get(s,i,a);if(i==="bind")return()=>a;if(r)return ce(s,i)},n.apply=(s,i,a)=>{if(e.apply)return e.apply(w(s),w(i),a)},new Proxy(t,n)}o(z,"wrap");function w(t){return t&&Ue(t)?t[ae]:t}o(w,"unwrap");function ce(t,e,r){let n=w(t);r=w(r)||n;let s=Reflect.get(n,e);return typeof s=="function"?s.constructor.name==="RpcProperty"?(...i)=>n[e](...i):s.bind(r):s}o(ce,"passthroughGet");var Ke={accept:"application/json","content-type":"application/json"},pr=new Set(["accept","content-encoding","content-type"]);function ur(t){try{let e=new URL(t);return e.username="",e.password="",e.search="",e.hash="",e.toString()}catch{return"<invalid-url>"}}o(ur,"sanitizeOtlpUrl");function lr(t){let e={};for(let[r,n]of Object.entries(t)){let s=r.toLowerCase();pr.has(s)&&(e[s]=n)}return e}o(lr,"sanitizeOtlpRequestHeaders");function He(t,e){return{message:"OpenTelemetry collector request failed; request metadata is sanitized: URL credentials, search parameters, fragments, and non-allowlisted headers are omitted",fields:{otelSignal:t.signal,request:{method:"POST",url:ur(t.url),headers:lr(t.headers),bodySizeBytes:t.bodySizeBytes,itemCount:t.itemCount},...e?{response:{status:e.status,statusText:e.statusText}}:{}}}}o(He,"requestDebugLog");var dr=20;async function fr(t){if(!t)return;let e=t.cancel().catch(()=>{}),r,n=new Promise(s=>{r=setTimeout(s,dr)});try{await Promise.race([e,n])}finally{clearTimeout(r)}}o(fr,"releaseResponseBody");var ze=8,mr=100,qe=1e4,gr=new Set([429,502,503,504]),hr=3,Sr=250,Tr=2e3,xr=2,Be=.2;function Rr(t,e=Date.now()){if(t===null||t.trim()==="")return;if(/^\d+$/.test(t.trim()))return Number(t.trim())*1e3;if(/^[\d.+\-eExX]+$/.test(t.trim()))return;let r=Date.parse(t);return Number.isNaN(r)?void 0:Math.max(0,r-e)}o(Rr,"parseRetryAfterMs");function br(t){return Math.min(Tr,Sr*xr**(t-1))*(1-Be+Math.random()*2*Be)}o(br,"backoffMs");function Cr(t){return new Promise(e=>setTimeout(e,t))}o(Cr,"sleep");async function Ge(t){let e=Date.now()+qe;for(let r=1;;r++){let n;try{n=await w(fetch)(t.url,{method:"POST",body:t.body,headers:t.headers,signal:AbortSignal.timeout(Math.max(1,e-Date.now()))})}catch(s){let i=s instanceof Error&&(s.name==="TimeoutError"||s.name==="AbortError");throw new F(i?`OTLP ${t.signal} export timed out after ${qe} ms. Verify the collector is reachable and responding.`:`OTLP ${t.signal} export could not reach the collector. Verify the collector URL and network access.`,{cause:s,debugLog:He(t)})}if(await fr(n.body),n.ok)return;if(gr.has(n.status)&&r<hr){let s=Rr(n.headers.get("retry-after"))??br(r);if(Date.now()+s<e){await Cr(s);continue}}throw new F(`OTLP ${t.signal} export failed with HTTP ${n.status} ${n.statusText}. Verify the collector URL and authentication headers.`,{debugLog:He(t,n)})}}o(Ge,"sendOtlpRequest");function je(t,e){try{t(e)}catch{}}o(je,"settleQuietly");function $e(t,e,r,n){if(t.length===0){try{n({code:pe.SUCCESS})}catch{}return}let s=t.length,i,a=o(c=>{c!==void 0&&i===void 0&&(i=c instanceof Error?c:new Error(`OTLP ${r} export failed`,{cause:c})),s-=1,s===0&&n(i?{code:pe.FAILED,error:i}:{code:pe.SUCCESS})},"settle");for(let c of t){let u=!1,d=o(l=>{u||(u=!0,a(l))},"settleOnce");try{let l=e.totalDropped;e.enqueue({item:c,settle:d}),e.totalDropped>l&&je(d,new F(`OTLP ${r} export dropped a payload because the export queue is full. The collector is not keeping up with the volume of telemetry being produced.`))}catch(l){je(d,new F(`OTLP ${r} export could not queue a payload for delivery. This usually means the export was attempted outside a request, where the runtime has no event context to keep background work alive; export from within a request, or install an event context first.`,{cause:l}))}}}o($e,"enqueueForExport");function ue(t,e){let r;for(let n of t)try{n.settle(e)}catch(s){r??=s}return r}o(ue,"settleAll");var q=class{static{o(this,"RequestConcurrency")}inFlight=0;totalDroppedBatches=0};async function We(t,e,r,n){if(t.length===0)return;if(r.inFlight>=ze){r.totalDroppedBatches+=1;let i=new F(`OTLP ${n} export dropped a batch of ${t.length} because ${ze} requests to the collector are already in flight. The collector is not keeping up with the volume of telemetry being produced.`),a=ue(t,i),c=r.totalDroppedBatches;if(c===1||c%mr===0)throw i;if(a!==void 0)throw a;return}r.inFlight+=1;try{await e(t.map(i=>i.item))}catch(i){throw ue(t,i),i}finally{r.inFlight-=1}let s=ue(t);if(s!==void 0)throw s}o(We,"dispatchExportBatch");var y=class{static{o(this,"OTLPSpanExporter")}headers;url;constructor(e){this.url=e.url,this.headers=Object.assign({},Ke,e.headers)}export(e,r){$e(e,this.batcher,"traces",r)}shutdown(){return this.batcher.flush()}forceFlush(){return this.batcher.flush()}concurrency=new q;dispatchFunction=o(async e=>We(e,async r=>{r.forEach(s=>{H(s.attributes)});let n=cr.serializeRequest(r);await Ge({signal:"traces",url:this.url,headers:this.headers,body:n??"",bodySizeBytes:n?.byteLength??0,itemCount:r.length})},this.concurrency,"traces"),"dispatchFunction");batcher=new Ve(this.dispatchFunction,{name:"otlp-span-exporter",msDelay:10})},B=class{static{o(this,"OTLPLogExporter")}headers;url;batcher;concurrency=new q;constructor(e,r){this.url=e.url,this.headers=Object.assign({},Ke,e.headers),this.batcher=new Ve(this.dispatchFunction,{name:"otlp-log-exporter",msDelay:r?.scheduledDelayMillis??10})}export(e,r){$e(e,this.batcher,"logs",r)}shutdown(){return this.batcher.flush()}forceFlush(){return this.batcher.flush()}dispatchFunction=o(async e=>We(e,async r=>{r.forEach(s=>{H(s.attributes)});let n=ar.serializeRequest(r);await Ge({signal:"logs",url:this.url,headers:this.headers,body:n??"",bodySizeBytes:n?.byteLength??0,itemCount:r.length})},this.concurrency,"logs"),"dispatchFunction")};import{TelemetryPlugin as Xn,trackFeature as Yn}from"@zuplo/runtime";import{context as D,propagation as jt,SpanKind as M,SpanStatusCode as Vt,trace as Fe}from"@opentelemetry/api";import{isTracingSuppressed as Dn}from"@opentelemetry/core";import{context as zt}from"@opentelemetry/api";import{W3CTraceContextPropagator as An}from"@opentelemetry/core";var j=class{static{o(this,"DefaultLogProcessor")}exporter;constructor(e){this.exporter=e}forceFlush(){return this.exporter.forceFlush?.()??Promise.resolve()}shutdown(){return this.exporter.shutdown()}onEmit(e){this.exporter.export([e],r=>{})}};import{SpanStatusCode as yr,TraceFlags as Ze}from"@opentelemetry/api";import{ParentBasedSampler as Xe,TraceIdRatioBasedSampler as Er}from"@opentelemetry/sdk-trace-base";import{SemanticAttributes as le}from"@zuplo/runtime";function Ye(t){return e=>{let{attributes:r}=e.localRootSpan;return r[le.SystemTrace]===!0||r[le.RouteSystem]===!0||r[le.RouteTrace]===!1?!1:t(e)}}o(Ye,"internalTailSampler");function Je(t){return e=>t.reduce((r,n)=>r||n(e),!1)}o(Je,"multiTailSampler");var Qe=o(t=>(t.localRootSpan.spanContext().traceFlags&Ze.SAMPLED)===Ze.SAMPLED,"isHeadSampled"),et=o(t=>t.localRootSpan.status.code===yr.ERROR,"isRootErrorSpan");function tt(t){let e=new Er(t.ratio);return typeof t.acceptRemote=="boolean"&&!t.acceptRemote?new Xe({root:e,remoteParentSampled:e,remoteParentNotSampled:e}):new Xe({root:e})}o(tt,"createSampler");import{SpanKind as bn,SpanStatusCode as ie}from"@opentelemetry/api";import{hrTimeDuration as Cn,isAttributeValue as yn,isTimeInput as En,sanitizeAttributes as Nt}from"@opentelemetry/core";import{ATTR_EXCEPTION_MESSAGE as Dt,ATTR_EXCEPTION_STACKTRACE as _n,ATTR_EXCEPTION_TYPE as Mt}from"@opentelemetry/semantic-conventions";import{createRedactionBudget as Pn,hasTelemetryRedactors as vn,redactTelemetryAttributes as Le,redactTelemetryString as we}from"@zuplo/runtime";import{context as _e,context as on,propagation as sn,ROOT_CONTEXT as an,SpanStatusCode as cn,trace as Pe}from"@opentelemetry/api";import{resourceFromAttributes as Ee}from"@opentelemetry/resources";import{ATTR_CLOUD_ACCOUNT_ID as pn,ATTR_CLOUD_PLATFORM as un,ATTR_CLOUD_PROVIDER as ln,ATTR_SERVICE_NAME as dn,ATTR_SERVICE_NAMESPACE as fn,ATTR_SERVICE_VERSION as mn,ATTR_TELEMETRY_SDK_NAME as gn}from"@opentelemetry/semantic-conventions/incubating";import{SemanticAttributes as se}from"@zuplo/runtime";import{AsyncLocalStorage as _r}from"node:async_hooks";import{EventEmitter as Pr}from"node:events";import{ROOT_CONTEXT as vr}from"@opentelemetry/api";var Lr=["addListener","on","once","prependListener","prependOnceListener"],de=class{static{o(this,"AbstractAsyncHooksContextManager")}bind(e,r){return r instanceof Pr?this._bindEventEmitter(e,r):typeof r=="function"?this._bindFunction(e,r):r}_bindFunction(e,r){let n=this,s=o(function(...i){return n.with(e,()=>r.apply(this,i))},"contextWrapper");return Object.defineProperty(s,"length",{enumerable:!1,configurable:!0,writable:!1,value:r.length}),s}_bindEventEmitter(e,r){return this._getPatchMap(r)!==void 0||(this._createPatchMap(r),Lr.forEach(s=>{r[s]!==void 0&&(r[s]=this._patchAddListener(r,r[s],e))}),typeof r.removeListener=="function"&&(r.removeListener=this._patchRemoveListener(r,r.removeListener)),typeof r.off=="function"&&(r.off=this._patchRemoveListener(r,r.off)),typeof r.removeAllListeners=="function"&&(r.removeAllListeners=this._patchRemoveAllListeners(r,r.removeAllListeners))),r}_patchRemoveListener(e,r){let n=this;return function(s,i){let a=n._getPatchMap(e)?.[s];if(a===void 0)return r.call(this,s,i);let c=a.get(i);return r.call(this,s,c||i)}}_patchRemoveAllListeners(e,r){let n=this;return function(s){let i=n._getPatchMap(e);return i!==void 0&&(arguments.length===0?n._createPatchMap(e):i[s]!==void 0&&delete i[s]),r.apply(this,arguments)}}_patchAddListener(e,r,n){let s=this;return function(i,a){if(s._wrapped)return r.call(this,i,a);let c=s._getPatchMap(e);c===void 0&&(c=s._createPatchMap(e));let u=c[i];u===void 0&&(u=new WeakMap,c[i]=u);let d=s.bind(n,a);u.set(a,d),s._wrapped=!0;try{return r.call(this,i,d)}finally{s._wrapped=!1}}}_createPatchMap(e){let r=Object.create(null);return e[this._kOtListeners]=r,r}_getPatchMap(e){return e[this._kOtListeners]}_kOtListeners=Symbol("OtListeners");_wrapped=!1},V=class extends de{static{o(this,"AsyncLocalStorageContextManager")}_asyncLocalStorage;constructor(){super(),this._asyncLocalStorage=new _r}active(){return this._asyncLocalStorage.getStore()??vr}with(e,r,n,...s){let i=n==null?r:r.bind(n);return this._asyncLocalStorage.run(e,i,...s)}enable(){return this}disable(){return this._asyncLocalStorage.disable(),this}};import{trace as rs}from"@opentelemetry/api";import{context as fe,INVALID_SPAN_CONTEXT as Ar,SpanKind as Or,TraceFlags as me,trace as A}from"@opentelemetry/api";import{isTracingSuppressed as Ir,sanitizeAttributes as lt}from"@opentelemetry/core";import{RandomIdGenerator as Fr,SamplingDecision as dt}from"@opentelemetry/sdk-trace-base";import{SemanticAttributes as ft}from"@zuplo/runtime";import{createContextKey as nt}from"@opentelemetry/api";var ot=nt("zuplo.otel.invocation_id"),st=nt("zuplo.otel.entry_span"),wr="\0",rt=0;function it(){return rt+=1,rt.toString(36)}o(it,"nextInvocationId");function at(t,e){return t.setValue(ot,e)}o(at,"withInvocationId");function ct(t){let e=t.getValue(ot);return typeof e=="string"?e:void 0}o(ct,"getInvocationId");function pt(t,e){return t.setValue(st,e)}o(pt,"withEntrySpan");function ut(t){return t.getValue(st)}o(ut,"getEntrySpan");function K(t,e){return e===void 0?t:`${t}${wr}${e}`}o(K,"traceStateKey");var mt=new Fr,kr=[ft.RequestId,ft.RayId];function Nr(t,e){return(t>>e-1&1)*e}o(Nr,"getFlagAt");var P=class{static{o(this,"WorkerTracer")}spanProcessors;resource;constructor(e,r){this.spanProcessors=e,this.resource=r}async waitForLongLivedSpans(e,r){await Promise.allSettled(this.spanProcessors.map(n=>n.waitForLongLivedSpans?.(e,r)))}async forceFlush(e){let r=this.spanProcessors.map(async n=>{await n.forceFlush(e)});await Promise.allSettled(r)}addToResource(e){this.resource.merge(e)}startSpan(e,r={},n=fe.active()){if(r.root&&(n=A.deleteSpan(n)),Ir(n))return A.wrapSpanContext(Ar);let s=R();if(!s)throw new Error("Config is undefined. This is a bug in the instrumentation logic");let i=A.getSpan(n)?.spanContext(),a=i&&A.isSpanContextValid(i)?i:void 0,{traceId:c,randomTraceFlag:u}=Dr(a),d=r.kind||Or.INTERNAL,l=lt(r.attributes),S=r.links?r.links.map(x=>({context:x.context,attributes:lt(x.attributes)})):[],T=s.sampling.headSampler.shouldSample(n,c,e,d,l,S),{decision:h,attributes:m}=T,O=T.traceState??a?.traceState,f=ut(n),p=mt.generateSpanId();if(h===dt.NOT_RECORD&&f!==void 0&&!s.sampling.recordUnsampledSpans)return A.wrapSpanContext({traceId:c,spanId:p,traceFlags:me.NONE+u,traceState:O});let _=Object.assign({},l,m);if(f instanceof k)for(let x of kr){let U=f.attributes[x];U!==void 0&&_[x]===void 0&&(_[x]=U)}let I=a?.spanId,tr=(h===dt.RECORD_AND_SAMPLED?me.SAMPLED:me.NONE)+u,rr={traceId:c,spanId:p,traceFlags:tr,traceState:O},De=new k({attributes:_,name:e,links:S,onEnd:o(x=>{this.spanProcessors.forEach(U=>{U.onEnd(x)})},"onEnd"),resource:this.resource,spanContext:rr,parentSpanContext:a,limits:s.spanLimits,parentSpanId:I,spanKind:d,startTime:r.startTime});return this.spanProcessors.forEach(x=>{x.onStart(De,n)}),De}startActiveSpan(e,...r){let n=r.length>1?r[0]:void 0,s=r.length>2?r[1]:fe.active(),i=r[r.length-1],a=this.startSpan(e,n,s),c=A.setSpan(s,a);return fe.with(c,i,void 0,a)}};function Dr(t){if(t){let{traceId:e,traceFlags:r}=t;return{traceId:e,randomTraceFlag:Nr(r,2)}}else return{traceId:mt.generateTraceId(),randomTraceFlag:2}}o(Dr,"getTraceInfo");var ge=class{static{o(this,"PromiseTracker")}_trackedPromises=[];get trackedPromiseCount(){return this._trackedPromises.length}track(e){this._trackedPromises.push(e)}async wait(e){if(this._trackedPromises.length!==0){if(e===void 0){await gt(this._trackedPromises);return}await Promise.race([gt(this._trackedPromises),scheduler.wait(e)])}}};function Mr(t,e,r){return z(t,{apply(s,i,a){return r.track(a[0]),Reflect.apply(s,e,a)}})}o(Mr,"createWaitUntil");function ht(t){let e=new ge;return{event:new Proxy(t,{get(n,s){if(s==="waitUntil"){let i=Reflect.get(n,s);return Mr(i,t,e)}else return ce(n,s)}}),tracker:e}}o(ht,"proxyExecutionContext");async function gt(t){let e;do e=await Promise.allSettled(t);while(e.length!==t.length);return e}o(gt,"allSettledMutable");import{logs as Xr}from"@opentelemetry/api-logs";import{diag as te}from"@opentelemetry/api";import{createNoopLogger as Gr}from"@opentelemetry/api-logs";import{defaultResource as $r}from"@opentelemetry/resources";import{BindOnceFuture as Wr}from"@opentelemetry/core";import{SeverityNumber as Hr}from"@opentelemetry/api-logs";import{context as Rt,trace as zr,TraceFlags as bt,isSpanContextValid as qr}from"@opentelemetry/api";import*as E from"@opentelemetry/api";import{timeInputToHrTime as Tt}from"@opentelemetry/core";import{ATTR_EXCEPTION_MESSAGE as G,ATTR_EXCEPTION_STACKTRACE as xt,ATTR_EXCEPTION_TYPE as $}from"@opentelemetry/semantic-conventions";import{diag as he}from"@opentelemetry/api";function Ur(t){return Se(t,new WeakSet)}o(Ur,"isLogAttributeValue");function Se(t,e){if(t==null||typeof t=="string"||typeof t=="number"||typeof t=="boolean"||t instanceof Uint8Array)return!0;if(typeof t=="object"){if(e.has(t))return!1;if(e.add(t),Array.isArray(t)){for(let n of t)if(!Se(n,e))return!1;return!0}let r=t;if(r.constructor!==Object&&r.constructor!==void 0)return!1;for(let n in r)if(Object.prototype.hasOwnProperty.call(r,n)&&!Se(r[n],e))return!1;return!0}return!1}o(Se,"isLogAttributeValueInternal");var g;(function(t){t[t.DROP_INVALID=0]="DROP_INVALID",t[t.DROP_LIMIT_REACHED=1]="DROP_LIMIT_REACHED",t[t.ADD_NEW=2]="ADD_NEW",t[t.ADD_OVERWRITE_EXISTING=3]="ADD_OVERWRITE_EXISTING"})(g||(g={}));function xe(t,e,r,n,s){if(n.length===0)return he.warn(`Invalid attribute key: ${n}`),g.DROP_INVALID;if(!Ur(s))return he.warn(`Invalid attribute value set for key: ${n}`),g.DROP_INVALID;let i=!Object.prototype.hasOwnProperty.call(t,n);return i&&r>=e.attributeCountLimit?g.DROP_LIMIT_REACHED:(t[n]=Te(s,e.attributeValueLengthLimit),i?g.ADD_NEW:g.ADD_OVERWRITE_EXISTING)}o(xe,"addAttribute");function Te(t,e){if(e<=0)return he.warn(`Attribute value limit must be positive, got ${e}`),t;if(t==null)return t;if(typeof t=="string")return t.length<=e?t:t.substring(0,e);if(t instanceof Uint8Array)return t;if(Array.isArray(t))return t.map(r=>Te(r,e));if(typeof t=="object"){let r={};for(let[n,s]of Object.entries(t))r[n]=Te(s,e);return r}return t}o(Te,"truncateToSize");function St(t,e){if(e==null)return{};let r={},n=0,s=0;for(let[i,a]of Object.entries(e)){let c=xe(r,t,n,i,a);c===g.ADD_NEW?n+=1:(c===g.DROP_INVALID||c===g.DROP_LIMIT_REACHED)&&(s+=1)}return{attributes:n>0?r:void 0,droppedAttributesCount:s}}o(St,"normalizeScopeAttributes");var W=class{static{o(this,"LogRecordImpl")}hrTime;hrTimeObserved;spanContext;resource;instrumentationScope;attributes={};_severityText;_severityNumber;_body;_eventName;_attributesCount=0;_droppedAttributesCount=0;_isReadonly=!1;_logRecordLimits;set severityText(e){this._isLogRecordReadonly()||(this._severityText=e)}get severityText(){return this._severityText}set severityNumber(e){this._isLogRecordReadonly()||(this._severityNumber=e)}get severityNumber(){return this._severityNumber}set body(e){this._isLogRecordReadonly()||(this._body=e)}get body(){return this._body}get eventName(){return this._eventName}set eventName(e){this._isLogRecordReadonly()||(this._eventName=e)}get droppedAttributesCount(){return this._droppedAttributesCount}constructor(e,r,n){let{timestamp:s,observedTimestamp:i,eventName:a,severityNumber:c,severityText:u,body:d,attributes:l={},exception:S,context:C}=n,T=Date.now();if(this.hrTime=Tt(s??T),this.hrTimeObserved=Tt(i??T),C){let h=E.trace.getSpanContext(C);h&&E.isSpanContextValid(h)&&(this.spanContext=h)}this.severityNumber=c,this.severityText=u,this.body=d,this.resource=e.resource,this.instrumentationScope=r,this._logRecordLimits=e.logRecordLimits,this._eventName=a,this.setAttributes(l),S!=null&&this._setException(S)}setAttribute(e,r){if(this._isLogRecordReadonly())return this;let n=xe(this.attributes,this._logRecordLimits,this._attributesCount,e,r);return n===g.DROP_LIMIT_REACHED?(this._droppedAttributesCount++,this._droppedAttributesCount===1&&E.diag.warn("Dropping extra attributes.")):n===g.ADD_NEW&&this._attributesCount++,this}setAttributes(e){for(let[r,n]of Object.entries(e))this.setAttribute(r,n);return this}setBody(e){return this.body=e,this}setEventName(e){return this.eventName=e,this}setSeverityNumber(e){return this.severityNumber=e,this}setSeverityText(e){return this.severityText=e,this}_makeReadonly(){this._isReadonly=!0}_setException(e){let r=!1;if(typeof e=="string"||typeof e=="number")Object.hasOwn(this.attributes,G)||this.setAttribute(G,String(e)),r=!0;else if(e&&typeof e=="object"){let n=e;n.code?(Object.hasOwn(this.attributes,$)||this.setAttribute($,n.code.toString()),r=!0):n.name&&(Object.hasOwn(this.attributes,$)||this.setAttribute($,n.name),r=!0),n.message&&(Object.hasOwn(this.attributes,G)||this.setAttribute(G,n.message),r=!0),n.stack&&(Object.hasOwn(this.attributes,xt)||this.setAttribute(xt,n.stack),r=!0)}r||E.diag.warn(`Failed to record an exception ${e}`)}_isLogRecordReadonly(){return this._isReadonly&&E.diag.warn("Can not execute the operation on emitted log record"),this._isReadonly}};var Z=class{static{o(this,"Logger")}_instrumentationScope;_sharedState;_loggerConfig;constructor(e,r){this._instrumentationScope=e,this._sharedState=r,this._loggerConfig=this._sharedState.getLoggerConfig(this._instrumentationScope)}emit(e){let r=e.context||Rt.active();if(!this.enabled(e))return;let n=new W(this._sharedState,this._instrumentationScope,{context:r,...e});this._sharedState.loggerMetrics.emitLog(),this._sharedState.activeProcessor.onEmit(n,r),n._makeReadonly()}enabled(e){if(this._sharedState.hasShutdown)return!1;let r=this._loggerConfig;if(r.disabled)return!1;let n=e?.severityNumber;if(typeof n=="number"&&n!==Hr.UNSPECIFIED&&n<r.minimumSeverity)return!1;let s=e?.context||Rt.active();if(r.traceBased){let a=zr.getSpanContext(s);if(a&&qr(a)&&!((a.traceFlags&bt.SAMPLED)===bt.SAMPLED))return!1}let i={context:s,instrumentationScope:this._instrumentationScope,severityNumber:e?.severityNumber,eventName:e?.eventName};for(let a of this._sharedState.processors)if(!a.enabled||a.enabled(i))return!0;return!1}};import{createNoopMeter as jr}from"@opentelemetry/api";import{SeverityNumber as Vr}from"@opentelemetry/api-logs";var X=class{static{o(this,"NoopLogRecordProcessor")}forceFlush(){return Promise.resolve()}onEmit(e,r){}shutdown(){return Promise.resolve()}enabled(e){return!1}};import{callWithTimeout as Br}from"@opentelemetry/core";var Y=class{static{o(this,"MultiLogRecordProcessor")}processors;forceFlushTimeoutMillis;constructor(e,r){this.processors=e,this.forceFlushTimeoutMillis=r}async forceFlush(){let e=this.forceFlushTimeoutMillis;await Promise.all(this.processors.map(r=>Br(r.forceFlush(),e)))}onEmit(e,r){this.processors.forEach(n=>n.onEmit(e,r))}async shutdown(){await Promise.all(this.processors.map(e=>e.shutdown()))}enabled(e){for(let r of this.processors)if(!r.enabled||r.enabled(e))return!0;return!1}};function Re(t){if(t===void 0)return["u",null];if(t===null)return["n",null];let e=typeof t;return e==="string"?["s",t]:e==="boolean"?["b",t]:e==="number"?Number.isNaN(t)?["nan",null]:t===1/0?["inf",null]:t===-1/0?["-inf",null]:Object.is(t,-0)?["n0",null]:["d",t]:t instanceof Uint8Array?["bytes",Array.from(t)]:Array.isArray(t)?["arr",t.map(Re)]:["map",Object.entries(t).sort(([r],[n])=>r.localeCompare(n)).map(([r,n])=>[r,Re(n)])]}o(Re,"normalizeAnyValue");function J(t){return JSON.stringify([t.name,t.version||"",t.schemaUrl||"",Re(t.attributes),t.droppedAttributesCount??0])}o(J,"getInstrumentationScopeKey");var Ct="otel.sdk.log.created";var Q=class{static{o(this,"LoggerMetrics")}createdLogs;constructor(e){this.createdLogs=e.createCounter(Ct,{unit:"{log_record}",description:"The number of logs submitted to enabled SDK Loggers."})}emitLog(){this.createdLogs.add(1)}};var yt="0.220.0";var Kr={disabled:!1,minimumSeverity:Vr.UNSPECIFIED,traceBased:!1},be=o(()=>({...Kr}),"DEFAULT_LOGGER_CONFIGURATOR"),ee=class{static{o(this,"LoggerProviderSharedState")}loggers=new Map;activeProcessor;registeredLogRecordProcessors=[];resource;forceFlushTimeoutMillis;logRecordLimits;processors;loggerMetrics;hasShutdown=!1;_loggerConfigurator;_loggerConfigs=new Map;constructor(e,r,n,s,i,a){this.resource=e,this.forceFlushTimeoutMillis=r,this.logRecordLimits=n,this.processors=s,s.length>0?(this.registeredLogRecordProcessors=s,this.activeProcessor=new Y(this.registeredLogRecordProcessors,this.forceFlushTimeoutMillis)):this.activeProcessor=new X,this._loggerConfigurator=i??be;let c=a?a.getMeter("@opentelemetry/sdk-logs",yt):jr();this.loggerMetrics=new Q(c)}getLoggerConfig(e){let r=J(e),n=this._loggerConfigs.get(r);return n||(n=this._loggerConfigurator(e),this._loggerConfigs.set(r,n),n)}};var Zr="unknown",N=class{static{o(this,"LoggerProvider")}_shutdownOnce;_sharedState;constructor(e={}){let r={resource:e.resource??$r(),forceFlushTimeoutMillis:e.forceFlushTimeoutMillis??3e4,logRecordLimits:{attributeCountLimit:e.logRecordLimits?.attributeCountLimit??128,attributeValueLengthLimit:e.logRecordLimits?.attributeValueLengthLimit??1/0},loggerConfigurator:e.loggerConfigurator??be,processors:e.processors??[],meterProvider:e.meterProvider};this._sharedState=new ee(r.resource,r.forceFlushTimeoutMillis,r.logRecordLimits,r.processors,r.loggerConfigurator,r.meterProvider),this._shutdownOnce=new Wr(this._shutdown,this)}getLogger(e,r,n){if(this._shutdownOnce.isCalled)return te.warn("A shutdown LoggerProvider cannot provide a Logger"),Gr();e||te.warn("Logger requested without instrumentation scope name.");let i={name:e||Zr,version:r,schemaUrl:n?.schemaUrl,...St(this._sharedState.logRecordLimits,n?.attributes)},a=J(i);return this._sharedState.loggers.has(a)||this._sharedState.loggers.set(a,new Z(i,this._sharedState)),this._sharedState.loggers.get(a)}forceFlush(){return this._shutdownOnce.isCalled?(te.warn("invalid attempt to force flush after LoggerProvider shutdown"),this._shutdownOnce.promise):this._sharedState.activeProcessor.forceFlush()}shutdown(){return this._shutdownOnce.isCalled?(te.warn("shutdown may only be called once per LoggerProvider"),this._shutdownOnce.promise):this._shutdownOnce.call()}_shutdown(){return this._sharedState.hasShutdown=!0,this._sharedState.activeProcessor.shutdown()}};var re=class{static{o(this,"ZuploOtelLogger")}baseLogger;constructor(e){this.baseLogger=e}emit(e){this.baseLogger.emit(e)}enabled(e){return this.baseLogger.enabled(e)}};var ne=class extends N{static{o(this,"ZuploLoggerProvider")}getLogger(e,r,n){let s=super.getLogger(e,r,n);return new re(s)}register(){Xr.setGlobalLoggerProvider(this)}};import{TraceFlags as Et}from"@opentelemetry/api";import{ExportResultCode as Yr}from"@opentelemetry/core";function Jr(){let t=R();return t||console.log("Could not find config for sampling, sending everything by default"),t?t.sampling.tailSampler:()=>!0}o(Jr,"getSampler");function Qr(t){return t.attributes?.["gen_ai.operation.name"]!==void 0}o(Qr,"isLongLivedSpan");var Ce=class{static{o(this,"TraceState")}unexportedSpans=[];inprogressSpans=new Set;longLivedSpans=new Set;longLivedWaiters=[];exporter;exportPromises=new Set;localRootSpan;traceDecision;isFlushed=!1;bufferedAt=Date.now();constructor(e){this.exporter=e}addSpan(e){let r=e;this.localRootSpan=this.localRootSpan||r,this.unexportedSpans.push(r),this.inprogressSpans.add(e.spanContext().spanId),Qr(r)&&this.longLivedSpans.add(e.spanContext().spanId)}async waitForLongLivedSpans(e){if(this.longLivedSpans.size===0)return;let r;await Promise.race([new Promise(n=>{this.longLivedWaiters.push(n)}),new Promise(n=>{r=setTimeout(n,e)})]),clearTimeout(r)}hasFinished(){return this.inprogressSpans.size===0&&this.isFlushed}async endSpan(e){if(this.inprogressSpans.delete(e.spanContext().spanId),this.longLivedSpans.delete(e.spanContext().spanId)&&this.longLivedSpans.size===0)for(let r of this.longLivedWaiters.splice(0))r();this.inprogressSpans.size===0&&await this.flush()}sample(){if(this.traceDecision===void 0&&this.unexportedSpans.length>0){let e=Jr();this.traceDecision=e({traceId:this.localRootSpan.spanContext().traceId,localRootSpan:this.localRootSpan,spans:this.unexportedSpans})}this.unexportedSpans=this.traceDecision?this.unexportedSpans:[]}async flush(){try{if(this.unexportedSpans.length>0){let e=this.unexportedSpans.filter(r=>this.isSpanInProgress(r));for(let r of e)console.log(`Span ${r.spanContext().spanId} was not ended properly`),r.end();if(this.sample(),this.unexportedSpans.length>0){let r=this.exportSpans([...this.unexportedSpans]);this.unexportedSpans=[],this.exportPromises.add(r),r.catch(()=>{}).finally(()=>{this.exportPromises.delete(r)})}}for(;this.exportPromises.size>0;)await Promise.allSettled([...this.exportPromises])}finally{this.isFlushed=!0}}isSpanInProgress(e){return this.inprogressSpans.has(e.spanContext().spanId)}async exportSpans(e){let r=R();if(!r){console.log("No config found for exporting spans, skipping export");return}let n=r.postProcessor(e);await scheduler.wait(1),await new Promise((i,a)=>{this.exporter.export(n,c=>{c.code===Yr.SUCCESS?i():(console.log(`exporting spans failed! ${c.error}`),a(c.error))})})}},_t=1e3,en=1e4,ye=300*1e3,tn=1e3;function rn(t){return(t.spanContext().traceFlags&Et.SAMPLED)===Et.SAMPLED||R()?.sampling.recordUnsampledSpans===!0}o(rn,"buffersFullTrace");function Pt(t,e){return t===e||t%tn<e}o(Pt,"shouldLogOccurrence");var b=class{constructor(e){this.exporter=e}exporter;static{o(this,"BatchTraceSpanProcessor")}traces=new Map;unsampledTraces=new Map;totalEvicted=0;totalRefused=0;spanTraceKeys=new WeakMap;getTraceState(e,r=!0){let n=this.findTraceState(e);if(n)return n;let s=r?this.traces:this.unsampledTraces;if(!this.makeRoom(r))return;let i=new Ce(this.exporter);return s.set(e,i),i}findTraceState(e){return this.traces.get(e)??this.unsampledTraces.get(e)}release(e,r){this.traces.get(e)===r?this.traces.delete(e):this.unsampledTraces.get(e)===r&&this.unsampledTraces.delete(e)}makeRoom(e){if(!e){if(this.unsampledTraces.size<en)return!0;let n=this.unsampledTraces.keys().next().value;return n!==void 0&&this.unsampledTraces.delete(n),this.recordEviction(),!0}if(this.traces.size<_t)return!0;let r=this.traces.entries().next().value;return r&&Date.now()-r[1].bufferedAt>=ye?(this.traces.delete(r[0]),this.recordEviction(),!0):(this.totalRefused++,Pt(this.totalRefused,1)&&console.log(`BatchTraceSpanProcessor: sampled trace limit (${_t}) reached with every buffered trace still live; not buffering new trace(s)`,{totalRefused:this.totalRefused}),!1)}recordEviction(){this.totalEvicted++,Pt(this.totalEvicted,1)&&console.log("BatchTraceSpanProcessor: buffered trace limit reached; evicting oldest stale or unsampled trace(s)",{totalEvicted:this.totalEvicted})}onStart(e,r){let n=K(e.spanContext().traceId,ct(r)),s=this.unsampledTraces.get(n);if(s){if(this.unsampledTraces.delete(n),!this.makeRoom(!0))return;s.bufferedAt=Date.now(),this.traces.set(n,s)}let i=this.getTraceState(n,rn(e));i&&(this.spanTraceKeys.set(e,n),i.addSpan(e))}onEnd(e){let r=this.spanTraceKeys.get(e)??e.spanContext().traceId,n=this.findTraceState(r);n&&n.endSpan(e).catch(s=>{console.log(s,"Failed to end span")}).finally(()=>{n.hasFinished()&&this.release(r,n)})}async waitForLongLivedSpans(e,r){await this.findTraceState(e)?.waitForLongLivedSpans(r)}async forceFlush(e){if(e){let r=this.findTraceState(e);if(!r)return;try{await r.flush()}finally{this.release(e,r)}}else{let r=[...this.traces.entries(),...this.unsampledTraces.entries()];await Promise.allSettled(r.map(([,n])=>n.flush()));for(let[n,s]of r)this.release(n,s)}}async shutdown(){await this.forceFlush()}};import{trace as nn}from"@opentelemetry/api";var oe=class{static{o(this,"ZuploTracerProvider")}spanProcessors;resource;tracers={};constructor(e,r){this.spanProcessors=e,this.resource=r}getTracer(e,r,n){let s=`${e}@${r||""}:${n?.schemaUrl||""}`;return this.tracers[s]||(this.tracers[s]=new P(this.spanProcessors,this.resource)),this.tracers[s]}register(){nn.setGlobalTracerProvider(this)}};var hn=o((t,e)=>{let r={[ln]:"zuplo",[un]:"zuplo-api",[pn]:t.accountName,"cloud.project.id":t.projectName,"cloud.resource_id":t.deploymentName,"cloud.instance_id":t.instanceId,"deployment.environment.name":t.environmentStage,"zuplo.account_name":t.accountName,"zuplo.project_name":t.projectName,"zuplo.deployment_name":t.deploymentName,[gn]:"@zuplo/otel",[se.ZuploBuildId]:t.buildId,[se.ZuploBuildVersion]:t.zuploVersion,[se.ZuploBuildCompatibilityDate]:t.compatibilityDate,[se.ZuploEnvironmentType]:t.environmentType},n=Ee({[dn]:e.service?.name??t.projectName??t.deploymentName??"zuplo",[fn]:e.service?.namespace,[mn]:e.service?.version}),s=Ee(r).merge(n);return e.resourceAttributes?s.merge(Ee(e.resourceAttributes)):s},"createResource"),vt=!1;function Lt(t,e){if(!vt){e.instrumentation.instrumentGlobalFetch&&kt(),sn.setGlobalPropagator(e.propagator);let r=hn(t,e);new oe(e.spanProcessors,r).register(),e.logProcessors.length>0&&new ne({resource:r,processors:e.logProcessors}).register(),on.setGlobalContextManager(new V),vt=!0}}o(Lt,"init");function At(t,e){if(typeof e=="function")return r=>{let n=ve(e(r));return Lt(t,n),n};{let r;return()=>(r??=ve(e),Lt(t,r),r)}}o(At,"createInitializer");var Sn=5e3,Tn=ye;async function xn(t,e){let r=Pe.getTracer("export");r instanceof P?(await scheduler.wait(1),await e?.wait(Sn),await r.waitForLongLivedSpans(t,Tn),await r.forceFlush(t)):console.error("The global tracer is not of type WorkerTracer and can not export spans")}o(xn,"exportSpans");var wt=!0;function Rn(t){return(e,r)=>{let[n,s]=r,{event:i,tracker:a}=ht(s),c=t.instrumentTrigger?t.instrumentTrigger(n):n,u=Pe.getTracer("handler"),{name:d,options:l,context:S}=t.getInitialSpanInfo(n),C=l.attributes||{};C["faas.coldstart"]=wt,l.attributes=C,wt=!1;let T=it(),h=at(S||_e.active(),T),m=u.startSpan(d,l,h),O=pt(Pe.setSpan(h,m),m);return _e.with(O,async()=>{try{let p=await e(c,i);if(t.getAttributesFromResult){let _=t.getAttributesFromResult(p);m.setAttributes(_)}return t.executionSuccess&&t.executionSuccess(m,n,p),p}catch(p){throw m.recordException(p),m.setStatus({code:cn.ERROR}),t.executionFailed&&t.executionFailed(m,n,p),p}finally{m.end(),s.waitUntil(xn(K(m.spanContext().traceId,T),a))}})}}o(Rn,"createHandlerFlowFn");function Ot(t,e,r){return(n,s)=>{let i=e(n),a=Ft(i,an),c=Rn(r);return _e.with(a,c,n,t,[n,s])}}o(Ot,"createHandlerProxy");var It={name:"@zuplo/otel"};function Ln(t){let e={};return typeof t=="string"?e[Dt]=t:(t.code?e[Mt]=t.code.toString():t.name&&(e[Mt]=t.name),t.message&&(e[Dt]=t.message),t.stack&&(e[_n]=t.stack)),e}o(Ln,"transformExceptionAttributes");function Ae(t){return[Math.trunc(t/1e3),t%1e3*1e6]}o(Ae,"millisToHr");function Oe(t){let e=Date.now();if(t){if(t instanceof Date)return Ae(t.getTime());if(typeof t=="number")return Ae(t);if(Array.isArray(t))return t}else return Ae(e);let r=t;throw new Error(`unreachable value: ${JSON.stringify(r)}`)}o(Oe,"getHrTime");function wn(t){return typeof t=="string"&&t.length>0}o(wn,"isAttributeKey");var Ie={attributeCountLimit:128,eventCountLimit:128,linkCountLimit:128},k=class{static{o(this,"SpanImpl")}name;_spanContext;onEnd;parentSpanId;parentSpanContext;kind;attributes;status={code:ie.UNSET};endTime=[0,0];_duration=[0,0];startTime;events=[];links;resource;instrumentationScope=It;_limits;_ended=!1;_attributeCount=0;_droppedAttributesCount=0;_droppedEventsCount=0;_droppedLinksCount=0;constructor(e){this._limits=e.limits??Ie,this.name=e.name,this._spanContext=e.spanContext,this.parentSpanId=e.parentSpanId,this.parentSpanContext=e.parentSpanContext,this.kind=e.spanKind||bn.INTERNAL,this.attributes={};for(let[r,n]of Object.entries(Nt(e.attributes)))this.setAttribute(r,n);this.startTime=Oe(e.startTime),this.links=[];for(let r of e.links??[])this.addLink(r);this.resource=e.resource,this.onEnd=e.onEnd}addLink(e){if(this._ended)return this;let{linkCountLimit:r}=this._limits;return r===0?(this._droppedLinksCount++,this):(this.links.length>=r&&(this.links.shift(),this._droppedLinksCount++),this.links.push(e),this)}addLinks(e){for(let r of e)this.addLink(r);return this}spanContext(){return this._spanContext}setAttribute(e,r){if(this._ended||r===null||r===void 0||!wn(e)||!yn(r))return this;if(!Object.hasOwn(this.attributes,e)){if(this._attributeCount>=this._limits.attributeCountLimit)return this._droppedAttributesCount++,this;this._attributeCount++}return this.attributes[e]=r,this}setAttributes(e){for(let[r,n]of Object.entries(e))this.setAttribute(r,n);return this}addEvent(e,r,n){if(this._ended)return this;En(r)&&(n=r,r=void 0);let{eventCountLimit:s}=this._limits;if(s===0)return this._droppedEventsCount++,this;this.events.length>=s&&(this.events.shift(),this._droppedEventsCount++);let i=Nt(r),a=Oe(n);return this.events.push({name:e,attributes:i,time:a}),this}setStatus(e){return this._ended||e.code===ie.UNSET||this.status.code===ie.OK?this:(this.status=e.code===ie.ERROR&&typeof e.message=="string"?{code:e.code,message:e.message}:{code:e.code},this)}updateName(e){return this._ended||(this.name=e),this}end(e){this._ended||(this._ended=!0,this.endTime=Oe(e),this._duration=Cn(this.startTime,this.endTime),vn()&&this.redact(),this.onEnd(this))}redact(){let e=Pn();this.name=we(this.name,"name",e);let r=Le(this.attributes,"attributes",e);for(let n of Object.keys(r))this.attributes[n]=r[n];for(let n=0;n<this.events.length;n++){let s=this.events[n];this.events[n]={...s,name:we(s.name,`events[${n}].name`,e),attributes:s.attributes?Le(s.attributes,`events[${n}].attributes`,e):s.attributes}}for(let n=0;n<this.links.length;n++){let s=this.links[n];s.attributes&&(this.links[n]={...s,attributes:Le(s.attributes,`links[${n}].attributes`,e)})}this.status.message!==void 0&&(this.status={...this.status,message:we(this.status.message,"status.message",e)})}isRecording(){return!this._ended}recordException(e,r){let n=Ln(e);this.addEvent("exception",n,r)}get duration(){return this._duration}get ended(){return this._ended}get droppedAttributesCount(){return this._droppedAttributesCount}get droppedEventsCount(){return this._droppedEventsCount}get droppedLinksCount(){return this._droppedLinksCount}};function Ut(t){return!!t.spanProcessors}o(Ut,"isSpanProcessorConfig");function Ht(t){let e=!!t.spanProcessors,r=!!t.logProcessors;return e&&r}o(Ht,"isProcessorConfig");var qt=Symbol("Otel Tracing Configuration");function Ft(t,e=zt.active()){return e.setValue(qt,t)}o(Ft,"setConfig");function R(){return zt.active().getValue(qt)||void 0}o(R,"getActiveConfig");function On(t){return!!t.shouldSample}o(On,"isSampler");function In(t){return!!t.exporter}o(In,"isTraceConfigExporter");function Fn(t){return typeof t.export=="function"}o(Fn,"isSpanExporterInstance");function kn(t){return!!t.logUrl&&!!t.traceUrl&&!!t.headers}o(kn,"isTraceAndLogConfigExporter");function ve(t){let e=[],r=[];if(In(t)){let i=Fn(t.exporter)?t.exporter:new y(t.exporter);e=[new b(i)]}else kn(t)?(e=[new b(new y({url:t.traceUrl,headers:t.headers}))],r=[new j(new B({url:t.logUrl,headers:t.headers}))]):Ht(t)?(e=Array.isArray(t.spanProcessors)?t.spanProcessors:[t.spanProcessors],r=Array.isArray(t.logProcessors)?t.logProcessors:[t.logProcessors]):Ut(t)&&(e=Array.isArray(t.spanProcessors)?t.spanProcessors:[t.spanProcessors]);let n=t.sampling?.headSampler||{ratio:1},s=On(n)?n:tt(n);return{fetch:{includeTraceContext:t.fetch?.includeTraceContext??!0},handlers:{fetch:{acceptTraceContext:t.handlers?.fetch?.acceptTraceContext??!0}},postProcessor:t.postProcessor||(i=>i),sampling:{headSampler:s,tailSampler:Ye(t.sampling?.tailSampler??Je([Qe,et])),recordUnsampledSpans:t.sampling?.tailSampler!==void 0},service:t.service,resourceAttributes:t.resourceAttributes,spanProcessors:e,propagator:t.propagator||new An,instrumentation:{instrumentGlobalFetch:t.instrumentation?.instrumentGlobalFetch??!0},spanLimits:Nn(t.spanLimits),logProcessors:r}}o(ve,"parseConfig");function Nn(t){let e={...Ie};for(let r of Object.keys(e)){let n=t?.[r];typeof n=="number"&&n>=0&&(e[r]=Math.floor(n))}return e}o(Nn,"resolveSpanLimits");var Mn=["AWSAccessKeyId","Signature","sig","X-Goog-Signature"];function Un(t){return t===""?t:t.split("&").map(e=>{let r=e.indexOf("=");if(r===-1)return e;let n=e.slice(0,r);return Mn.includes(Hn(n))?`${n}=REDACTED`:e}).join("&")}o(Un,"redactQuery");function Hn(t){try{return decodeURIComponent(t.replaceAll("+"," "))}catch{return t}}o(Hn,"decodeParamName");function Kt(t){if(t===null||!/^\d+$/.test(t))return;let e=Number(t);return Number.isSafeInteger(e)?e:void 0}o(Kt,"parseContentLength");function v(t,e,r){r!=null&&(t[e]=r)}o(v,"setIfPresent");var zn={http:80,https:443};function Gt(t,e){let r={},n=t.headers;r["http.request.method"]=t.method.toUpperCase(),v(r,"http.request.body.size",Kt(n.get("content-length"))),v(r,"user_agent.original",n.get("user-agent")),v(r,"http.mime_type",n.get("content-type")),v(r,"http.accepts",n.get("accept"));let s=e??new URL(t.url),i=s.protocol.slice(0,-1),a=Un(s.search.slice(1));return r["url.full"]=`${s.protocol}//${s.host}${s.pathname}${a?`?${a}`:""}`,r["server.address"]=s.hostname.replace(/^\[(.*)\]$/,"$1"),v(r,"server.port",s.port?Number(s.port):zn[i]),r["url.scheme"]=i,r["url.path"]=s.pathname,a&&(r["url.query"]=a),r}o(Gt,"gatherRequestAttributes");function $t(t){let e={};return e["http.response.status_code"]=t.status,v(e,"http.response.body.size",Kt(t.headers.get("content-length"))),v(e,"http.mime_type",t.headers.get("content-type")),e}o($t,"gatherResponseAttributes");function Wt(t,e,r){let n=r===M.SERVER?500:400;e>=n&&(t.setAttribute("error.type",String(e)),t.setStatus({code:Vt.ERROR}))}o(Wt,"setHttpResponseStatus");function Zt(t){return t instanceof Error&&t.name?t.name:"_OTHER"}o(Zt,"errorTypeOf");function qn(t){return jt.extract(D.active(),t,{get(e,r){return e.get(r)||void 0},keys(e){return[...e.keys()]}})}o(qn,"getParentContextFromHeaders");function Bn(t){let e=R();return e===void 0?D.active():(typeof e.handlers.fetch.acceptTraceContext=="function"?e.handlers.fetch.acceptTraceContext(t):e.handlers.fetch.acceptTraceContext??!0)?qn(t.headers):D.active()}o(Bn,"getParentContextFromRequest");function Bt(t,e){let r=t;if(r.attributes?.["http.route"]){let n=e.method.toUpperCase();t.updateName(`${n} ${r.attributes["http.route"]}`)}}o(Bt,"updateSpanNameOnRoute");var Xt={getInitialSpanInfo:o(t=>{let e=Bn(t),r={"faas.trigger":"http","faas.invocation_id":t.headers.get("zp-rid")??void 0,"cf.ray_id":t.headers.get("cf-ray")??void 0};return Object.assign(r,Gt(t)),{name:t.method.toUpperCase(),options:{attributes:r,kind:M.SERVER},context:e}},"getInitialSpanInfo"),getAttributesFromResult:o(t=>$t(t),"getAttributesFromResult"),executionSuccess:o((t,e,r)=>{Bt(t,e),Wt(t,r.status,M.SERVER)},"executionSuccess"),executionFailed:o((t,e,r)=>{Bt(t,e),t.setAttribute("error.type",Zt(r))},"executionFailed")},jn={set:o((t,e,r)=>t.set(e,typeof r=="string"?r:String(r)),"set")};function ke(t){let e=D.active(),r=Fe.getSpanContext(e);r!==void 0&&Fe.isSpanContextValid(r)&&t.delete("tracestate"),jt.inject(e,t,jn)}o(ke,"injectTraceContext");function Yt(t,e){return typeof t.includeTraceContext=="function"?t.includeTraceContext(e()):t.includeTraceContext??!0}o(Yt,"shouldIncludeTraceContext");function Vn(t,e){let r=t[0],n=t[1];if(typeof e.includeTraceContext=="function"){let i=new Request(r,n);return e.includeTraceContext(i)&&ke(i.headers),n?.zuplo?[i,{zuplo:n.zuplo}]:[i]}if(!Yt(e,()=>new Request(r,n)))return t;let s=new Headers(n?.headers??(r instanceof Request?r.headers:void 0));return ke(s),[r,{...n,headers:s}]}o(Vn,"unrecordedFetchArgs");function Kn(t){return typeof t=="string"?t:t instanceof URL?t.href:t.url}o(Kn,"inputUrl");function Gn(t,e,r){return z(t,{apply:o((s,i,a)=>{let c=R();if(!c){let f=new Request(a[0],a[1]);if(!f.url.startsWith("http"))return Reflect.apply(s,i,a);let p=a[1]?.zuplo;return Reflect.apply(s,i,p?[f,{zuplo:p}]:[f])}if(Dn(D.active()))return Reflect.apply(s,i,a);let u=a[0],d=a[1],l;try{l=new URL(Kn(u))}catch{return Reflect.apply(s,i,a)}if(!l.protocol.startsWith("http"))return Reflect.apply(s,i,a);let S=e(c),C=Fe.getTracer("fetcher"),T={kind:M.CLIENT,attributes:r},h=(d?.method??(u instanceof Request?u.method:"GET")).toUpperCase(),m=typeof r?.name=="string"?r?.name:`${h}: ${l.host}`;return C.startActiveSpan(m,T,async f=>{try{if(!f.isRecording())return await Reflect.apply(s,i,Vn(a,S));let p=new Request(u,d),_=d?.zuplo?[p,{zuplo:d.zuplo}]:[p];Yt(S,()=>p)&&ke(p.headers),f.setAttributes(Gt(p,l));let I=await Reflect.apply(s,i,_);return f.setAttributes($t(I)),Wt(f,I.status,M.CLIENT),I}catch(p){throw f.recordException(p),f.setAttribute("error.type",Zt(p)),f.setStatus({code:Vt.ERROR}),p}finally{f.end()}})},"apply")},!0)}o(Gn,"instrumentClientFetch");function kt(){globalThis.fetch=Gn(globalThis.fetch,t=>t.fetch)}o(kt,"instrumentGlobalFetch");import{ConfigurationError as $n}from"@zuplo/runtime";var Wn="/otel/v1/traces",Jt;function Qt(t){Jt=t}o(Qt,"setManagedTraceEndpoint");function Zn(){return new $n("The Zuplo OpenTelemetry exporter (ZuploSpanExporter) is not available because the Zuplo-managed trace ingest is not configured for this deployment. This exporter only works in deployed Zuplo environments. For local development, configure your own `exporter` (or guard the ZuploSpanExporter behind an environment check) instead.")}o(Zn,"missingIngestError");var L=class{static{o(this,"ZuploSpanExporter")}delegate;resolveDelegate(){if(this.delegate)return this.delegate;let e=Jt;if(!e||!e.token)throw Zn();return this.delegate=new y({url:new URL(Wn,e.url).toString(),headers:{authorization:`Bearer ${e.token}`}}),this.delegate}export(e,r){this.resolveDelegate().export(e,r)}shutdown(){return this.delegate?.shutdown()??Promise.resolve()}forceFlush(){return this.delegate?.forceFlush()??Promise.resolve()}};function er(t){return Array.isArray(t)?t.length>0:!!t}o(er,"hasProcessors");function Jn(t){let e=t;return!!e.exporter||er(e.spanProcessors)||er(e.logProcessors)||!!(e.logUrl&&e.traceUrl)}o(Jn,"hasDestination");function Qn(t){let e=t??{};return Jn(e)?e:{...e,spanProcessors:[new b(new L)]}}o(Qn,"withZuploDefaults");function eo(t){let e=t;return e.exporter instanceof L?!0:e.spanProcessors?(Array.isArray(e.spanProcessors)?e.spanProcessors:[e.spanProcessors]).some(n=>n instanceof b&&n.exporter instanceof L):!1}o(eo,"usesZuploExporter");var Ne=class extends Xn{static{o(this,"OpenTelemetryPlugin")}config;constructor(e){super(),Yn("opentelemetry"),this.config=e}instrument(e){let r=this.config?.instrumentation?.genAi?.captureContent===!0;Qt({url:e.__internalOnlyRemoteLogUrl,token:e.__internalOnlyRemoteLogToken});let n=Qn(this.config);if(eo(n)&&!e.__internalOnlyRemoteLogToken)return{requestHandlerProxy:o(a=>a,"requestHandlerProxy"),__internalOnlyGenAiCaptureContent:r};let s=At(e,n);return{requestHandlerProxy:o(a=>Ot(a,s,Xt),"requestHandlerProxy"),__internalOnlyGenAiCaptureContent:r}}};export{y as a,b,L as c,Ne as d};
13
+ //# sourceMappingURL=chunk-6YAK7LGJ.js.map