I noticed that the `llm.chat.*_tokens` attributes weren't in spans, and it turns out none of the attributes from the wrapped function make it in. only those added synchronously from within `wrapWithSpan` do.
A few things in play here:
1. Switch from `ZoneContextManager` (which doesn't work with native async/await) to `AsyncLocalStorageContextManager` (which does.)
2. (1) requires we use a pnpm patch, since wrangler requires that we import `async_hooks` statically, and the otel code `requires` it, and also requires that it's spelled `node:async_hooks`.
3. encode the payload we try to send _before_ doing the retry loop, so we don't re-encode for each attempt.
4. switch from `startActiveSpan` to `context.with` + `startSpan`. The latter allows us to wrap an async function. the former is for synchronous functions.
Running the prior code in wrangler (but _not_ `npm run dev`) was generating errors during otel initialization. I was ultimately unable to figure out why, or how to fix them:
```
(warn) Initializing OpenTelemetry
(error) Error initializing OpenTelemetry TypeError: Class constructor OTLPExporterBase2 cannot be invoked without 'new'
```
In the end, it was easier to just boil the ocean a little: With claude's help, write a custom otlp exporter and use that. Also use BasicTracerProvider instead of WebTracerProvider.
This version is enough to generate spans from within local wrangler.
The log should contain a warning showing the following once at startup:
```
OpenTelemetry initialization skipped: HONEYCOMB_API_KEY and/or HONEYCOMB_DATASET not set
```
and every time a span would have been created:
```
OpenTelemetry not initialized, skipping span creation
```
Also sneak in a `service.version` attribute that is `${__APP_VERSION}; ${__COMMIT_HASH}`. e.g.:

add some otel initialization, pointing at honeycomb + a function to wrap other functions with spans. use that function to wrap `callAnthropic` and add some context (number of messages sent, token usage, along with some metadata should we ever support other providers.)
The honeycomb api key/dataset are to be passed via env vars `HONEYCOMB_API_KEY` and `HONEYCOMB_DATASET` respectively.
* fixed#333
* Added instruction in case api-key is not set.
* addressed some of the review changes:
1. moved function definiton to useCallback.
2. added a cache to store the env key status and the api call is made only on a cache miss.
* Manages the API-key entered via UI in a better way.
- Persist API keys in cookies when entered via UI
- Automatically load saved keys when switching between providers
- Preserve existing functionality for environment variable based keys
* Re-used map from utils/constants file.
* Code cleanup - Removed redundant API key init in BaseChat as its already handled by APIKeyManager component.
* fixed formatting of faq and enhanced styling
* save
* did further improvements and fixing the sidebar
---------
Co-authored-by: Anirban Kar <thecodacus@gmail.com>
* feat: enhance chat import with multi-format support
- Add support for importing chats from different formats:
- Standard Bolt format
- Chrome extension format
- History array format
- Bolt export format
- Add Import Chats button to Data Management
- Add proper error handling and logging
- Update README with backup/restore feature
* refactor: simplify chat import formats
- Remove multi-format support from DataTab
- Keep only standard Bolt export formats
- Simplify ImportButtons to handle standard format only
* feat: Integrate AWS Bedrock with Claude 3.5 Sonnet, Claude 3 Sonnet, and Claude 3.5 Haiku
* update Dockerfile for AWS Bedrock configuration
* feat: add new Bedrock model 'Mistral' and update Haiku to version 3
* feat: add new bedrock model Nova Lite and Nova Pro
* Update README documentation to reflect the latest changes
* Add the icon for aws bedrock
* add support for serialized AWS Bedrock configuration in api key
* fix: updated logger and model caching
* usage token stream issue fix
* minor changes
* updated starter template change to fix the app title
* starter template bigfix
* fixed hydretion errors and raw logs
* removed raw log
* made auto select template false by default
* more cleaner logs and updated logic to call dynamicModels only if not found in static models
* updated starter template instructions
* browser console log improved for firefox
* provider icons fix icons
* Catch errors from web container
* Show fix error popup on errors in preview
* Remove unneeded action type
* PR comments
* Cleanup urls in stacktrace
---------
Co-authored-by: Anirban Kar <thecodacus@gmail.com>