@reactionary/source 0.0.37 → 0.0.39
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.
- package/.env-template +10 -0
- package/.github/workflows/pull-request.yml +5 -3
- package/core/package.json +1 -2
- package/core/src/client/client.ts +4 -2
- package/core/src/index.ts +3 -9
- package/core/src/providers/analytics.provider.ts +6 -1
- package/core/src/providers/base.provider.ts +33 -3
- package/core/src/providers/cart.provider.ts +7 -1
- package/core/src/providers/category.provider.ts +91 -0
- package/core/src/providers/identity.provider.ts +5 -1
- package/core/src/providers/inventory.provider.ts +4 -0
- package/core/src/providers/price.provider.ts +54 -0
- package/core/src/providers/product.provider.ts +4 -0
- package/core/src/providers/search.provider.ts +6 -0
- package/core/src/schemas/capabilities.schema.ts +3 -2
- package/core/src/schemas/models/base.model.ts +42 -1
- package/core/src/schemas/models/cart.model.ts +27 -3
- package/core/src/schemas/models/category.model.ts +23 -0
- package/core/src/schemas/models/identifiers.model.ts +29 -1
- package/core/src/schemas/models/inventory.model.ts +6 -2
- package/core/src/schemas/models/price.model.ts +11 -3
- package/core/src/schemas/models/search.model.ts +4 -2
- package/core/src/schemas/queries/category.query.ts +32 -0
- package/core/src/schemas/queries/index.ts +9 -0
- package/core/src/schemas/queries/inventory.query.ts +18 -3
- package/core/src/schemas/session.schema.ts +13 -2
- package/examples/next/.swcrc +30 -0
- package/examples/next/eslint.config.mjs +21 -0
- package/examples/next/index.d.ts +6 -0
- package/examples/next/next-env.d.ts +5 -0
- package/examples/next/next.config.js +20 -0
- package/examples/next/project.json +9 -0
- package/examples/next/public/.gitkeep +0 -0
- package/examples/next/public/favicon.ico +0 -0
- package/examples/next/src/app/global.css +0 -0
- package/examples/next/src/app/layout.tsx +18 -0
- package/examples/next/src/app/page.module.scss +2 -0
- package/examples/next/src/app/page.tsx +51 -0
- package/examples/next/src/instrumentation.ts +9 -0
- package/examples/next/tsconfig.json +44 -0
- package/examples/node/src/basic/basic-node-provider-model-extension.spec.ts +0 -1
- package/examples/node/src/basic/basic-node-setup.spec.ts +0 -1
- package/otel/README.md +152 -172
- package/otel/package.json +0 -1
- package/otel/src/index.ts +15 -5
- package/otel/src/metrics.ts +3 -3
- package/otel/src/test/otel.spec.ts +8 -0
- package/otel/src/trace-decorator.ts +87 -108
- package/otel/src/tracer.ts +3 -3
- package/package.json +2 -1
- package/providers/commercetools/package.json +1 -0
- package/providers/commercetools/src/core/initialize.ts +7 -3
- package/providers/commercetools/src/providers/cart.provider.ts +84 -8
- package/providers/commercetools/src/providers/category.provider.ts +244 -0
- package/providers/commercetools/src/providers/index.ts +7 -0
- package/providers/commercetools/src/providers/inventory.provider.ts +31 -14
- package/providers/commercetools/src/providers/price.provider.ts +74 -18
- package/providers/commercetools/src/providers/product.provider.ts +19 -15
- package/providers/commercetools/src/providers/search.provider.ts +9 -7
- package/providers/commercetools/src/schema/capabilities.schema.ts +2 -1
- package/providers/commercetools/src/schema/configuration.schema.ts +1 -1
- package/providers/commercetools/src/test/cart.provider.spec.ts +119 -0
- package/providers/commercetools/src/test/category.provider.spec.ts +180 -0
- package/providers/commercetools/src/test/price.provider.spec.ts +80 -0
- package/providers/commercetools/src/test/product.provider.spec.ts +29 -14
- package/providers/commercetools/src/test/search.provider.spec.ts +51 -9
- package/providers/commercetools/src/test/test-utils.ts +35 -0
- package/providers/commercetools/tsconfig.lib.json +1 -1
- package/providers/fake/jest.config.ts +10 -0
- package/providers/fake/src/core/initialize.ts +15 -1
- package/providers/fake/src/index.ts +2 -9
- package/providers/fake/src/providers/cart.provider.ts +74 -15
- package/providers/fake/src/providers/category.provider.ts +152 -0
- package/providers/fake/src/providers/index.ts +8 -0
- package/providers/fake/src/providers/inventory.provider.ts +23 -9
- package/providers/fake/src/providers/price.provider.ts +46 -6
- package/providers/fake/src/providers/search.provider.ts +13 -4
- package/providers/fake/src/schema/capabilities.schema.ts +4 -2
- package/providers/fake/src/schema/configuration.schema.ts +5 -0
- package/providers/fake/src/test/cart.provider.spec.ts +126 -0
- package/providers/fake/src/test/category.provider.spec.ts +134 -0
- package/providers/fake/src/test/price.provider.spec.ts +80 -0
- package/providers/fake/src/test/test-utils.ts +42 -0
- package/providers/fake/tsconfig.json +4 -0
- package/providers/fake/tsconfig.lib.json +3 -1
- package/providers/fake/tsconfig.spec.json +16 -0
- package/trpc/package.json +1 -2
- package/trpc/src/client.ts +1 -3
- package/trpc/src/integration.spec.ts +16 -10
- package/trpc/src/transparent-client.spec.ts +23 -17
- package/tsconfig.base.json +2 -0
- package/core/src/decorators/trpc.decorators.ts +0 -144
- package/otel/src/sdk.ts +0 -57
package/otel/README.md
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
# @reactionary/otel
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
OpenTelemetry instrumentation for the Reactionary framework. Provides decorators and utilities for tracing function execution and performance monitoring.
|
|
4
|
+
|
|
5
|
+
## Important: SDK Initialization Required
|
|
6
|
+
|
|
7
|
+
This library provides **instrumentation only**. The host application is responsible for initializing the OpenTelemetry SDK. Without proper SDK initialization, traces will be created as `NonRecordingSpan` instances with zero trace/span IDs.
|
|
4
8
|
|
|
5
9
|
## Features
|
|
6
10
|
|
|
7
|
-
- **
|
|
8
|
-
- **
|
|
9
|
-
- **
|
|
10
|
-
- **
|
|
11
|
-
- **
|
|
12
|
-
- **Metrics Collection**: Request counts, durations, errors automatically tracked
|
|
13
|
-
- **Lazy Initialization**: Only starts when actually used
|
|
11
|
+
- **Tracing Decorators**: Automatic span creation for decorated methods
|
|
12
|
+
- **Manual Instrumentation**: Utilities for custom tracing
|
|
13
|
+
- **Framework Integration**: Built-in support for tRPC and providers
|
|
14
|
+
- **Zero Dependencies**: Only requires OpenTelemetry API
|
|
15
|
+
- **Graceful Degradation**: Works without SDK initialization (produces no-op spans)
|
|
14
16
|
|
|
15
17
|
## Installation
|
|
16
18
|
|
|
@@ -18,230 +20,208 @@ Zero-configuration OpenTelemetry instrumentation for Reactionary framework. Auto
|
|
|
18
20
|
pnpm add @reactionary/otel
|
|
19
21
|
```
|
|
20
22
|
|
|
21
|
-
|
|
23
|
+
**Important**: You must also install and configure the OpenTelemetry SDK in your host application.
|
|
22
24
|
|
|
23
|
-
##
|
|
25
|
+
## Usage
|
|
24
26
|
|
|
25
|
-
|
|
27
|
+
### Basic Tracing with Decorators
|
|
26
28
|
|
|
27
29
|
```typescript
|
|
28
|
-
|
|
29
|
-
// Just use your tRPC router or providers normally
|
|
30
|
-
import { createTRPCRouter } from '@reactionary/trpc';
|
|
31
|
-
|
|
32
|
-
const router = createTRPCRouter(client);
|
|
33
|
-
// ↑ Automatically instrumented when OTEL env vars are set
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
## Configuration
|
|
37
|
-
|
|
38
|
-
Use standard OpenTelemetry environment variables. No code changes needed.
|
|
39
|
-
|
|
40
|
-
### Standard Environment Variables
|
|
41
|
-
|
|
42
|
-
```bash
|
|
43
|
-
# Service identification
|
|
44
|
-
OTEL_SERVICE_NAME=my-service
|
|
45
|
-
OTEL_SERVICE_VERSION=1.0.0
|
|
46
|
-
|
|
47
|
-
# Traces exporter (console | otlp | otlp/http | none)
|
|
48
|
-
OTEL_TRACES_EXPORTER=otlp
|
|
49
|
-
|
|
50
|
-
# Metrics exporter (console | otlp | otlp/http | none)
|
|
51
|
-
OTEL_METRICS_EXPORTER=otlp
|
|
52
|
-
|
|
53
|
-
# OTLP endpoint and headers
|
|
54
|
-
OTEL_EXPORTER_OTLP_ENDPOINT=https://api.honeycomb.io
|
|
55
|
-
OTEL_EXPORTER_OTLP_HEADERS=x-honeycomb-team=your-api-key
|
|
56
|
-
|
|
57
|
-
# Or use specific endpoints
|
|
58
|
-
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=https://api.honeycomb.io/v1/traces
|
|
59
|
-
OTEL_EXPORTER_OTLP_METRICS_ENDPOINT=https://api.honeycomb.io/v1/metrics
|
|
60
|
-
|
|
61
|
-
# Debug logging
|
|
62
|
-
OTEL_LOG_LEVEL=debug
|
|
63
|
-
|
|
64
|
-
# Metrics export interval (milliseconds)
|
|
65
|
-
OTEL_METRIC_EXPORT_INTERVAL=60000
|
|
66
|
-
```
|
|
30
|
+
import { traced } from '@reactionary/otel';
|
|
67
31
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
OTEL_TRACES_EXPORTER=console
|
|
75
|
-
OTEL_METRICS_EXPORTER=console
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
### OTLP (Production)
|
|
79
|
-
Works with any OTLP-compatible backend:
|
|
80
|
-
|
|
81
|
-
```bash
|
|
82
|
-
OTEL_TRACES_EXPORTER=otlp
|
|
83
|
-
OTEL_METRICS_EXPORTER=otlp
|
|
84
|
-
OTEL_EXPORTER_OTLP_ENDPOINT=https://api.honeycomb.io
|
|
85
|
-
OTEL_EXPORTER_OTLP_HEADERS=x-honeycomb-team=your-api-key
|
|
86
|
-
```
|
|
32
|
+
class MyService {
|
|
33
|
+
@traced()
|
|
34
|
+
async fetchData(id: string): Promise<Data> {
|
|
35
|
+
// This method will be automatically traced
|
|
36
|
+
return await dataSource.get(id);
|
|
37
|
+
}
|
|
87
38
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
39
|
+
@traced({
|
|
40
|
+
spanName: 'custom-operation',
|
|
41
|
+
captureResult: false
|
|
42
|
+
})
|
|
43
|
+
processData(data: Data): void {
|
|
44
|
+
// Custom span name and no result capture
|
|
45
|
+
}
|
|
46
|
+
}
|
|
92
47
|
```
|
|
93
48
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
### Manual Spans
|
|
97
|
-
|
|
98
|
-
Create custom spans for specific operations:
|
|
49
|
+
### Manual Instrumentation
|
|
99
50
|
|
|
100
51
|
```typescript
|
|
101
52
|
import { withSpan, getTracer } from '@reactionary/otel';
|
|
102
53
|
|
|
103
54
|
// Using withSpan helper
|
|
104
|
-
const result = await withSpan('
|
|
105
|
-
span.setAttribute('
|
|
106
|
-
|
|
107
|
-
return someAsyncOperation();
|
|
55
|
+
const result = await withSpan('my-operation', async (span) => {
|
|
56
|
+
span.setAttribute('operation.id', operationId);
|
|
57
|
+
return await performOperation();
|
|
108
58
|
});
|
|
109
59
|
|
|
110
60
|
// Using tracer directly
|
|
111
61
|
const tracer = getTracer();
|
|
112
62
|
const span = tracer.startSpan('manual-span');
|
|
113
63
|
try {
|
|
114
|
-
// Your
|
|
64
|
+
// Your code here
|
|
115
65
|
span.setStatus({ code: SpanStatusCode.OK });
|
|
116
66
|
} catch (error) {
|
|
117
|
-
span.recordException(error);
|
|
118
67
|
span.setStatus({ code: SpanStatusCode.ERROR });
|
|
119
|
-
|
|
68
|
+
span.recordException(error);
|
|
120
69
|
} finally {
|
|
121
70
|
span.end();
|
|
122
71
|
}
|
|
123
72
|
```
|
|
124
73
|
|
|
125
|
-
|
|
74
|
+
## Setting Up OpenTelemetry SDK
|
|
126
75
|
|
|
127
|
-
|
|
76
|
+
### Next.js Applications
|
|
128
77
|
|
|
129
|
-
|
|
130
|
-
import { BaseProvider } from '@reactionary/core';
|
|
78
|
+
1. Create an `instrumentation.ts` file in your project root:
|
|
131
79
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
80
|
+
```typescript
|
|
81
|
+
// instrumentation.ts
|
|
82
|
+
export async function register() {
|
|
83
|
+
if (process.env.NEXT_RUNTIME === 'nodejs') {
|
|
84
|
+
const { NodeSDK } = await import('@opentelemetry/sdk-node');
|
|
85
|
+
const { getNodeAutoInstrumentations } = await import('@opentelemetry/auto-instrumentations-node');
|
|
86
|
+
|
|
87
|
+
const sdk = new NodeSDK({
|
|
88
|
+
instrumentations: [getNodeAutoInstrumentations()],
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
sdk.start();
|
|
140
92
|
}
|
|
141
93
|
}
|
|
142
94
|
```
|
|
143
95
|
|
|
144
|
-
|
|
96
|
+
2. Enable instrumentation in `next.config.js`:
|
|
145
97
|
|
|
146
|
-
|
|
98
|
+
```javascript
|
|
99
|
+
/** @type {import('next').NextConfig} */
|
|
100
|
+
const nextConfig = {
|
|
101
|
+
experimental: {
|
|
102
|
+
instrumentationHook: true,
|
|
103
|
+
},
|
|
104
|
+
};
|
|
147
105
|
|
|
148
|
-
|
|
149
|
-
|
|
106
|
+
module.exports = nextConfig;
|
|
107
|
+
```
|
|
150
108
|
|
|
151
|
-
|
|
109
|
+
3. Configure environment variables:
|
|
152
110
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
111
|
+
```bash
|
|
112
|
+
# .env.local
|
|
113
|
+
OTEL_SERVICE_NAME=my-nextjs-app
|
|
114
|
+
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318
|
|
115
|
+
OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Node.js Applications
|
|
158
119
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
120
|
+
```typescript
|
|
121
|
+
// Initialize at the very beginning of your application
|
|
122
|
+
import { NodeSDK } from '@opentelemetry/sdk-node';
|
|
123
|
+
import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';
|
|
124
|
+
|
|
125
|
+
const sdk = new NodeSDK({
|
|
126
|
+
instrumentations: [getNodeAutoInstrumentations()],
|
|
163
127
|
});
|
|
128
|
+
|
|
129
|
+
sdk.start();
|
|
130
|
+
|
|
131
|
+
// Now import and use your application code
|
|
132
|
+
import './app';
|
|
164
133
|
```
|
|
165
134
|
|
|
166
|
-
|
|
135
|
+
### Environment Variables
|
|
167
136
|
|
|
168
|
-
|
|
137
|
+
The OpenTelemetry SDK can be configured using environment variables:
|
|
169
138
|
|
|
170
139
|
```bash
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
OTEL_EXPORTER_OTLP_HEADERS=x-honeycomb-team=your-api-key
|
|
175
|
-
```
|
|
140
|
+
# Service identification
|
|
141
|
+
OTEL_SERVICE_NAME=my-app
|
|
142
|
+
OTEL_SERVICE_VERSION=1.0.0
|
|
176
143
|
|
|
177
|
-
|
|
144
|
+
# OTLP Exporter (for Jaeger, etc.)
|
|
145
|
+
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318
|
|
146
|
+
OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
|
|
178
147
|
|
|
179
|
-
|
|
180
|
-
OTEL_SERVICE_NAME=my-service-dev
|
|
148
|
+
# Console exporter (for development)
|
|
181
149
|
OTEL_TRACES_EXPORTER=console
|
|
182
|
-
|
|
150
|
+
|
|
151
|
+
# Sampling (optional)
|
|
152
|
+
OTEL_TRACES_SAMPLER=always_on
|
|
153
|
+
|
|
154
|
+
# Debug logging
|
|
155
|
+
OTEL_LOG_LEVEL=debug
|
|
183
156
|
```
|
|
184
157
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
- OTEL_SERVICE_NAME=my-service
|
|
194
|
-
|
|
195
|
-
jaeger:
|
|
196
|
-
image: jaegertracing/all-in-one:latest
|
|
197
|
-
ports:
|
|
198
|
-
- "16686:16686" # Jaeger UI
|
|
199
|
-
- "4318:4318" # OTLP HTTP
|
|
158
|
+
## Troubleshooting
|
|
159
|
+
|
|
160
|
+
### ProxyTracer with NonRecordingSpan
|
|
161
|
+
|
|
162
|
+
If you see logs like:
|
|
163
|
+
```
|
|
164
|
+
tracer: ProxyTracer { _provider: ProxyTracerProvider {} }
|
|
165
|
+
ending span: NonRecordingSpan { _spanContext: { traceId: '00000000000000000000000000000000' } }
|
|
200
166
|
```
|
|
201
167
|
|
|
202
|
-
|
|
168
|
+
This means the OpenTelemetry SDK has not been initialized. Ensure you have:
|
|
169
|
+
1. Created an `instrumentation.ts` file (Next.js)
|
|
170
|
+
2. Initialized the SDK at application startup (Node.js)
|
|
171
|
+
3. Set the required environment variables
|
|
203
172
|
|
|
204
|
-
|
|
173
|
+
### Missing Traces
|
|
205
174
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
| `reactionary.requests.active` | UpDownCounter | Number of active requests |
|
|
211
|
-
| `reactionary.errors` | Counter | Total number of errors |
|
|
212
|
-
| `reactionary.provider.calls` | Counter | Total provider calls |
|
|
213
|
-
| `reactionary.provider.duration` | Histogram | Provider call duration |
|
|
214
|
-
| `reactionary.cache.hits` | Counter | Cache hit count |
|
|
215
|
-
| `reactionary.cache.misses` | Counter | Cache miss count |
|
|
175
|
+
If the decorator is being applied but you don't see traces:
|
|
176
|
+
1. Verify the OTEL exporter is configured correctly
|
|
177
|
+
2. Check that your tracing backend is running
|
|
178
|
+
3. Ensure sampling is enabled (`OTEL_TRACES_SAMPLER=always_on`)
|
|
216
179
|
|
|
217
|
-
##
|
|
180
|
+
## API Reference
|
|
218
181
|
|
|
219
|
-
|
|
220
|
-
2. **Set Service Name**: Always set `OTEL_SERVICE_NAME` for service identification
|
|
221
|
-
3. **Environment-based Config**: Use different configs for dev/staging/production
|
|
222
|
-
4. **Add Context**: Use span attributes to add business context to traces
|
|
223
|
-
5. **Handle Errors**: Ensure spans are properly closed even on errors
|
|
224
|
-
6. **Sample Wisely**: Consider sampling strategies for high-volume services
|
|
225
|
-
7. **Monitor Performance**: Watch for overhead in high-throughput scenarios
|
|
182
|
+
### Decorators
|
|
226
183
|
|
|
227
|
-
|
|
184
|
+
#### `@traced(options?)`
|
|
228
185
|
|
|
229
|
-
|
|
186
|
+
Decorates a method to automatically create spans for its execution.
|
|
230
187
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
188
|
+
**Options:**
|
|
189
|
+
- `captureArgs?: boolean` - Capture function arguments (default: true)
|
|
190
|
+
- `captureResult?: boolean` - Capture return value (default: true)
|
|
191
|
+
- `spanName?: string` - Custom span name (default: ClassName.methodName)
|
|
192
|
+
- `spanKind?: SpanKind` - OpenTelemetry span kind (default: INTERNAL)
|
|
235
193
|
|
|
236
|
-
###
|
|
194
|
+
### Utility Functions
|
|
195
|
+
|
|
196
|
+
- `getTracer(): Tracer` - Get the library's tracer instance
|
|
197
|
+
- `startSpan(name, options?, context?): Span` - Start a new span
|
|
198
|
+
- `withSpan<T>(name, fn, options?): Promise<T>` - Execute function within a span
|
|
199
|
+
- `setSpanAttributes(span, attributes): void` - Set multiple span attributes
|
|
200
|
+
- `createChildSpan(parent, name, options?): Span` - Create child span
|
|
201
|
+
|
|
202
|
+
### Constants
|
|
203
|
+
|
|
204
|
+
- `SpanKind` - OpenTelemetry span kinds
|
|
205
|
+
- `SpanStatusCode` - OpenTelemetry span status codes
|
|
206
|
+
|
|
207
|
+
## Examples
|
|
237
208
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
-
|
|
241
|
-
|
|
209
|
+
### Console Output (Development)
|
|
210
|
+
```bash
|
|
211
|
+
OTEL_SERVICE_NAME=my-service-dev
|
|
212
|
+
OTEL_TRACES_EXPORTER=console
|
|
213
|
+
```
|
|
242
214
|
|
|
243
|
-
###
|
|
215
|
+
### Jaeger (Local)
|
|
216
|
+
```bash
|
|
217
|
+
OTEL_SERVICE_NAME=my-service
|
|
218
|
+
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318
|
|
219
|
+
OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
|
|
220
|
+
```
|
|
244
221
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
-
|
|
222
|
+
### Honeycomb (Production)
|
|
223
|
+
```bash
|
|
224
|
+
OTEL_SERVICE_NAME=my-service
|
|
225
|
+
OTEL_EXPORTER_OTLP_ENDPOINT=https://api.honeycomb.io
|
|
226
|
+
OTEL_EXPORTER_OTLP_HEADERS=x-honeycomb-team=your-api-key
|
|
227
|
+
```
|
package/otel/package.json
CHANGED
package/otel/src/index.ts
CHANGED
|
@@ -1,12 +1,22 @@
|
|
|
1
|
-
// OpenTelemetry
|
|
2
|
-
//
|
|
1
|
+
// OpenTelemetry instrumentation library
|
|
2
|
+
// This library provides instrumentation only - the host application
|
|
3
|
+
// is responsible for initializing the OpenTelemetry SDK
|
|
3
4
|
|
|
4
5
|
// Framework integration exports (internal use only)
|
|
5
6
|
export { createTRPCTracing } from './trpc-middleware';
|
|
6
7
|
export { createProviderInstrumentation } from './provider-instrumentation';
|
|
7
8
|
|
|
8
9
|
// Decorator for tracing functions
|
|
9
|
-
export { traced
|
|
10
|
+
export { traced } from './trace-decorator';
|
|
11
|
+
export type { TracedOptions } from './trace-decorator';
|
|
10
12
|
|
|
11
|
-
//
|
|
12
|
-
export {
|
|
13
|
+
// Utility functions for manual instrumentation
|
|
14
|
+
export {
|
|
15
|
+
getTracer,
|
|
16
|
+
startSpan,
|
|
17
|
+
withSpan,
|
|
18
|
+
setSpanAttributes,
|
|
19
|
+
createChildSpan,
|
|
20
|
+
SpanKind,
|
|
21
|
+
SpanStatusCode
|
|
22
|
+
} from './tracer';
|
package/otel/src/metrics.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { metrics, Meter, Counter, Histogram, UpDownCounter } from '@opentelemetry/api';
|
|
2
|
-
import { isOtelInitialized } from './sdk';
|
|
3
2
|
|
|
4
3
|
const METER_NAME = '@reactionary/otel';
|
|
5
4
|
const METER_VERSION = '0.0.1';
|
|
@@ -8,8 +7,9 @@ let globalMeter: Meter | null = null;
|
|
|
8
7
|
|
|
9
8
|
export function getMeter(): Meter {
|
|
10
9
|
if (!globalMeter) {
|
|
11
|
-
//
|
|
12
|
-
|
|
10
|
+
// Simply get the meter from the API
|
|
11
|
+
// If the SDK is not initialized by the host application,
|
|
12
|
+
// this will return a NoopMeter
|
|
13
13
|
globalMeter = metrics.getMeter(METER_NAME, METER_VERSION);
|
|
14
14
|
}
|
|
15
15
|
return globalMeter;
|