@interopio/otel 0.1.8 → 0.1.11
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/dist/builder.js +5 -1
- package/dist/builder.js.map +1 -1
- package/dist/container.js +14 -11
- package/dist/container.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/traces/bufferingTracesManager.d.ts +62 -0
- package/dist/traces/bufferingTracesManager.js +300 -0
- package/dist/traces/bufferingTracesManager.js.map +1 -0
- package/dist/traces/bufferingTracingState.d.ts +74 -0
- package/dist/traces/bufferingTracingState.js +120 -0
- package/dist/traces/bufferingTracingState.js.map +1 -0
- package/dist/traces/nullTracesManager.js +2 -2
- package/dist/traces/nullTracesManager.js.map +1 -1
- package/dist/traces/nullTracingState.d.ts +2 -1
- package/dist/traces/nullTracingState.js +2 -1
- package/dist/traces/nullTracingState.js.map +1 -1
- package/dist/traces/traces.d.ts +12 -7
- package/dist/traces/traces.js +48 -1
- package/dist/traces/traces.js.map +1 -1
- package/insights.d.ts +275 -4
- package/package.json +1 -1
package/insights.d.ts
CHANGED
|
@@ -256,11 +256,15 @@ export namespace IOInsights {
|
|
|
256
256
|
|
|
257
257
|
/**
|
|
258
258
|
* Whether to enable automatic collection of platform-level metrics (CPU, memory, etc.).
|
|
259
|
+
* If `true`, the library will initialize all predefined platform metrics automatically.
|
|
260
|
+
* If `only-explicit`, it will not initialize them automatically, but will still allow you to
|
|
261
|
+
* configure your own platform metrics based on the predefined types using the `metrics` config property.
|
|
262
|
+
* If `false`, any platform metrics will be automatically disabled.
|
|
259
263
|
*/
|
|
260
|
-
platformMetricsEnabled?: boolean;
|
|
264
|
+
platformMetricsEnabled?: boolean | "only-explicit";
|
|
261
265
|
|
|
262
266
|
/**
|
|
263
|
-
* Array of
|
|
267
|
+
* Array of custom metric configurations. It allows specifying overrides for both platform and custom metrics.
|
|
264
268
|
*/
|
|
265
269
|
metrics?: MetricSettings[];
|
|
266
270
|
|
|
@@ -1127,6 +1131,7 @@ export namespace IOInsights {
|
|
|
1127
1131
|
endSpan(endTime?: Date, allowDoubleEnd?: boolean): Promise<void>;
|
|
1128
1132
|
context?: Context;
|
|
1129
1133
|
span?: Span;
|
|
1134
|
+
matchingFilter?: SpanFilter | null;
|
|
1130
1135
|
/**
|
|
1131
1136
|
* Gets the propagation info for the current span (see https://www.w3.org/TR/trace-context/#tracestate-field)
|
|
1132
1137
|
* @returns the propagation info, if a span is currently active
|
|
@@ -1189,13 +1194,56 @@ export namespace IOInsights {
|
|
|
1189
1194
|
*
|
|
1190
1195
|
* @default true
|
|
1191
1196
|
*/
|
|
1192
|
-
instrumentRequests?: boolean;
|
|
1197
|
+
instrumentRequests?: boolean | RequestTraceConfig;
|
|
1198
|
+
|
|
1199
|
+
// https://github.com/open-telemetry/opentelemetry-browser/blob/main/packages/instrumentation/README.md#fetch
|
|
1200
|
+
/**
|
|
1201
|
+
* If `true`, uncaught errors and unhandled promise rejections are published as
|
|
1202
|
+
* error spans ("interopio.api.instrumentation.error" / ".unhandledRejection"),
|
|
1203
|
+
* including errors buffered before initialization by the pre-init recorder.
|
|
1204
|
+
* Capped per session to guard against error storms. When enabled, the app
|
|
1205
|
+
* startup trace defers its own error capture to this instrumentation.
|
|
1206
|
+
*
|
|
1207
|
+
* @default true
|
|
1208
|
+
*/
|
|
1209
|
+
instrumentErrors?: boolean;
|
|
1210
|
+
|
|
1211
|
+
/**
|
|
1212
|
+
* If `true`, resource loads (scripts, stylesheets, images, fonts, ...) are
|
|
1213
|
+
* published as spans ("interopio.api.instrumentation.resource") with their real
|
|
1214
|
+
* timings from the resource timing buffer, including resources loaded before
|
|
1215
|
+
* initialization. fetch/XHR resources are excluded (the request instrumentation
|
|
1216
|
+
* covers them in more detail), as are telemetry uploads. When enabled, the app
|
|
1217
|
+
* startup trace defers its slowest-resource child spans to this instrumentation.
|
|
1218
|
+
*
|
|
1219
|
+
* @default true
|
|
1220
|
+
*/
|
|
1221
|
+
instrumentResources?: boolean;
|
|
1222
|
+
|
|
1223
|
+
/**
|
|
1224
|
+
* If `true`, in-page (SPA) navigations - history pushState/replaceState,
|
|
1225
|
+
* popstate and hashchange - are published as spans
|
|
1226
|
+
* ("interopio.api.instrumentation.navigation") with the sanitized from/to URLs.
|
|
1227
|
+
* Same-URL state updates are not reported.
|
|
1228
|
+
*
|
|
1229
|
+
* @default true
|
|
1230
|
+
*/
|
|
1231
|
+
instrumentNavigation?: boolean;
|
|
1232
|
+
|
|
1233
|
+
/**
|
|
1234
|
+
* If `true`, io.Insights will instrument and trace the application startup process
|
|
1235
|
+
* automatically.
|
|
1236
|
+
*
|
|
1237
|
+
* @default true
|
|
1238
|
+
*/
|
|
1239
|
+
instrumentAppStartup?: boolean;
|
|
1193
1240
|
|
|
1194
1241
|
/**
|
|
1195
1242
|
* If `true`, io.Insights will instrument and trace the application loading process
|
|
1196
1243
|
* automatically.
|
|
1197
1244
|
*
|
|
1198
1245
|
* @default true
|
|
1246
|
+
* @deprecated use instrumentAppStartup
|
|
1199
1247
|
*/
|
|
1200
1248
|
instrumentAppLoad?: boolean;
|
|
1201
1249
|
|
|
@@ -1204,6 +1252,7 @@ export namespace IOInsights {
|
|
|
1204
1252
|
* and initialization process automatically
|
|
1205
1253
|
*
|
|
1206
1254
|
* @default true
|
|
1255
|
+
* @deprecated use instrumentAppStartup
|
|
1207
1256
|
*/
|
|
1208
1257
|
instrumentDocumentLoad?: boolean;
|
|
1209
1258
|
|
|
@@ -1505,6 +1554,12 @@ export namespace IOInsights {
|
|
|
1505
1554
|
export interface WithSpanOptions extends Omit<SpanCreationOptions, "sample"> {
|
|
1506
1555
|
defaultFilters?: SpanFilter[];
|
|
1507
1556
|
structure?: "sibling" | "nested";
|
|
1557
|
+
/**
|
|
1558
|
+
* Overrides the name of the exported OTEL span. The `source` remains the identity
|
|
1559
|
+
* used for span filtering, metrics and logging - this only changes the recorded
|
|
1560
|
+
* span name (e.g. to follow a semantic convention).
|
|
1561
|
+
*/
|
|
1562
|
+
spanName?: string;
|
|
1508
1563
|
}
|
|
1509
1564
|
|
|
1510
1565
|
export interface SpanCreationOptions {
|
|
@@ -1658,6 +1713,12 @@ export namespace IOInsights {
|
|
|
1658
1713
|
* @default false
|
|
1659
1714
|
*/
|
|
1660
1715
|
overrideDefaultFilters?: boolean;
|
|
1716
|
+
|
|
1717
|
+
/**
|
|
1718
|
+
* If set, will force the span to have this status code, regardless of anything set explicitly
|
|
1719
|
+
* or any errors caught automatically.
|
|
1720
|
+
*/
|
|
1721
|
+
forceStatus?: SpanStatusCode;
|
|
1661
1722
|
}
|
|
1662
1723
|
|
|
1663
1724
|
/**
|
|
@@ -1684,6 +1745,28 @@ export namespace IOInsights {
|
|
|
1684
1745
|
context?: {
|
|
1685
1746
|
[key: string]: string | number | boolean;
|
|
1686
1747
|
};
|
|
1748
|
+
|
|
1749
|
+
/**
|
|
1750
|
+
* For spans instrumenting HTTP requests, controls automatic injection of the trace
|
|
1751
|
+
* context headers with the current span's context. The headers are produced by the
|
|
1752
|
+
* globally registered propagator (W3C trace context - `traceparent`/`tracestate` -
|
|
1753
|
+
* by default; replaceable via the traces settings' `propagator`, e.g. with B3 or a
|
|
1754
|
+
* composite propagator including baggage).
|
|
1755
|
+
*
|
|
1756
|
+
* `"same-origin"` injects into same-origin requests only: adding a custom header
|
|
1757
|
+
* to a cross-origin request triggers a CORS preflight, and a server that does not
|
|
1758
|
+
* allow the header would fail the request itself. (The legacy value `true` is
|
|
1759
|
+
* treated as `"same-origin"` at runtime.)
|
|
1760
|
+
*
|
|
1761
|
+
* `"all-origins"` injects into every request this filter matches, including
|
|
1762
|
+
* cross-origin ones - use it in filters whose `context.url` matches origins
|
|
1763
|
+
* known to accept the headers (e.g. via Access-Control-Allow-Headers).
|
|
1764
|
+
*
|
|
1765
|
+
* @default false
|
|
1766
|
+
*/
|
|
1767
|
+
injectOTELHeaders?: false | "same-origin" | "all-origins";
|
|
1768
|
+
|
|
1769
|
+
[key: string]: any;
|
|
1687
1770
|
}
|
|
1688
1771
|
|
|
1689
1772
|
/**
|
|
@@ -1766,6 +1849,188 @@ export namespace IOInsights {
|
|
|
1766
1849
|
nestEventListeners?: boolean;
|
|
1767
1850
|
}
|
|
1768
1851
|
|
|
1852
|
+
export interface RequestTraceConfig {
|
|
1853
|
+
/**
|
|
1854
|
+
* Whether fetch and XHR requests will be instrumented with traces automatically.
|
|
1855
|
+
*/
|
|
1856
|
+
enabled: boolean;
|
|
1857
|
+
|
|
1858
|
+
/**
|
|
1859
|
+
* Whether request instrumentation spans can be root spans of new traces. This allows you
|
|
1860
|
+
* to trace requests without any instrumentation in your own code, but may create a large
|
|
1861
|
+
* number of traces. This will not affect metrics.
|
|
1862
|
+
*
|
|
1863
|
+
* @default true
|
|
1864
|
+
*/
|
|
1865
|
+
allowRoot?: boolean;
|
|
1866
|
+
|
|
1867
|
+
/**
|
|
1868
|
+
* If `true`, requests to the OTEL Collector endpoints will not be instrumented.
|
|
1869
|
+
* Recommended to keep `true`, since otherwise the request caused by the auto instrumentation
|
|
1870
|
+
* telemetry will itself cause auto instrumentation to kick in and so on, creating unnecessary
|
|
1871
|
+
* telemetry.
|
|
1872
|
+
*
|
|
1873
|
+
* @default true
|
|
1874
|
+
*/
|
|
1875
|
+
ignoreTelemetryURLs?: boolean;
|
|
1876
|
+
|
|
1877
|
+
/**
|
|
1878
|
+
* Optional regex pattern for URLs that should be excluded from auto instrumentation.
|
|
1879
|
+
*/
|
|
1880
|
+
ignorePattern?: string;
|
|
1881
|
+
|
|
1882
|
+
/**
|
|
1883
|
+
* Optional regex pattern, if specified, only matching URLs will be auto instrumented.
|
|
1884
|
+
*/
|
|
1885
|
+
matchPattern?: string;
|
|
1886
|
+
|
|
1887
|
+
/**
|
|
1888
|
+
* An array of HTTP response status codes to consider as errors. Status code families can be described as 4xx, 5xx, etc.
|
|
1889
|
+
*
|
|
1890
|
+
* @default ["4xx", "5xx"]
|
|
1891
|
+
*/
|
|
1892
|
+
errorStatusCodes?: (string | number)[];
|
|
1893
|
+
|
|
1894
|
+
/**
|
|
1895
|
+
* If `true` or a string, the request's time to first byte (request issued until the
|
|
1896
|
+
* response headers were received) will be published as a histogram metric. If a string
|
|
1897
|
+
* value is specified, this will be the name of the metric. Otherwise, the default
|
|
1898
|
+
* "io.insights.http.client.request.ttfb.duration" is used.
|
|
1899
|
+
*
|
|
1900
|
+
* Deliberately not named after the semantic convention: samples other instrumentations
|
|
1901
|
+
* publish under "http.client.request.duration" cover the full operation, and mixing
|
|
1902
|
+
* time-to-headers samples into that name would skew cross-tool comparisons - the
|
|
1903
|
+
* semconv name is instead the default of requestTotalDurationMetric.
|
|
1904
|
+
*
|
|
1905
|
+
* Cheap and always available: measured for every request (including failures, until
|
|
1906
|
+
* the failure), with no response body observation required.
|
|
1907
|
+
*
|
|
1908
|
+
* @default false
|
|
1909
|
+
*/
|
|
1910
|
+
requestFirstByteDurationMetric?: boolean | string;
|
|
1911
|
+
|
|
1912
|
+
/**
|
|
1913
|
+
* If `true` or a string, the end-to-end request time (request issued until the response
|
|
1914
|
+
* body was fully delivered) will be published as a histogram metric. If a string value
|
|
1915
|
+
* is specified, this will be the name of the metric. Otherwise, the semantic convention
|
|
1916
|
+
* default "http.client.request.duration" is used - the end-to-end measurement matches
|
|
1917
|
+
* what other instrumentations publish under that name.
|
|
1918
|
+
*
|
|
1919
|
+
* Successful requests only. Requests whose body completion cannot be observed (e.g.
|
|
1920
|
+
* streaming responses) contribute no sample, so this metric's sample count is expected
|
|
1921
|
+
* to be lower than requestFirstByteDurationMetric's.
|
|
1922
|
+
*
|
|
1923
|
+
* Cost caveat: when this or requestBodyDownloadDurationMetric is enabled, body delivery of every
|
|
1924
|
+
* non-streaming fetch response is observed by fully reading a clone of the body. As a
|
|
1925
|
+
* side effect, responses the application abandons without reading (e.g. only checking
|
|
1926
|
+
* `response.ok`) are downloaded in full over the network instead of being cancelled by
|
|
1927
|
+
* the browser. Streaming content types (server-sent events etc.) are exempt. Weigh this
|
|
1928
|
+
* before enabling in deployments with large-payload traffic.
|
|
1929
|
+
*
|
|
1930
|
+
* @default false
|
|
1931
|
+
*/
|
|
1932
|
+
requestTotalDurationMetric?: boolean | string;
|
|
1933
|
+
|
|
1934
|
+
/**
|
|
1935
|
+
* If `true` or a string, the download phase (response headers received until the response
|
|
1936
|
+
* body was fully delivered) will be published as a histogram metric. If a string value
|
|
1937
|
+
* is specified, this will be the name of the metric. Otherwise, the default
|
|
1938
|
+
* "io.insights.http.client.response.download.duration" is used (no semantic convention
|
|
1939
|
+
* exists for this metric).
|
|
1940
|
+
*
|
|
1941
|
+
* Same population and cost caveats as requestTotalDurationMetric: successful requests with an
|
|
1942
|
+
* observable body completion only, and enabling it causes abandoned fetch response
|
|
1943
|
+
* bodies to be downloaded in full.
|
|
1944
|
+
*
|
|
1945
|
+
* @default false
|
|
1946
|
+
*/
|
|
1947
|
+
requestBodyDownloadDurationMetric?: boolean | string;
|
|
1948
|
+
|
|
1949
|
+
/**
|
|
1950
|
+
* Explicit histogram bucket boundaries for requestFirstByteDurationMetric, in seconds, ascending.
|
|
1951
|
+
* The default is the semantic-convention-recommended set for HTTP client durations,
|
|
1952
|
+
* which suits time-to-first-byte distributions well.
|
|
1953
|
+
*
|
|
1954
|
+
* @default [0.005, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1, 2.5, 5, 7.5, 10]
|
|
1955
|
+
*/
|
|
1956
|
+
requestFirstByteDurationMetricBuckets?: number[];
|
|
1957
|
+
|
|
1958
|
+
/**
|
|
1959
|
+
* Explicit histogram bucket boundaries for requestTotalDurationMetric, in seconds, ascending.
|
|
1960
|
+
* The default is the semantic-convention-recommended set (this metric carries the
|
|
1961
|
+
* semconv name by default), extended upward to cover long transfers of large payloads;
|
|
1962
|
+
* overriding the sub-10s boundaries trades away comparability with other
|
|
1963
|
+
* instrumentations that use the recommended set.
|
|
1964
|
+
*
|
|
1965
|
+
* @default [0.005, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1, 2.5, 5, 7.5, 10, 30, 60, 120, 240]
|
|
1966
|
+
*/
|
|
1967
|
+
requestTotalDurationMetricBuckets?: number[];
|
|
1968
|
+
|
|
1969
|
+
/**
|
|
1970
|
+
* Explicit histogram bucket boundaries for requestBodyDownloadDurationMetric, in seconds, ascending.
|
|
1971
|
+
*
|
|
1972
|
+
* @default [0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10, 30, 60, 120, 240]
|
|
1973
|
+
*/
|
|
1974
|
+
requestBodyDownloadDurationMetricBuckets?: number[];
|
|
1975
|
+
|
|
1976
|
+
/**
|
|
1977
|
+
* If `true` or a string, the request size in bytes will be published as a histogram metric.
|
|
1978
|
+
* If a string value is specified, this will be the name of the metric. Otherwise, the
|
|
1979
|
+
* semantic convention default "http.client.request.body.size" is used.
|
|
1980
|
+
*
|
|
1981
|
+
* @default false
|
|
1982
|
+
*/
|
|
1983
|
+
requestBytesMetric?: boolean | string;
|
|
1984
|
+
|
|
1985
|
+
/**
|
|
1986
|
+
* If `true` or a string, the request size in bytes will be published as a histogram metric.
|
|
1987
|
+
* If a string value is specified, this will be the name of the metric. Otherwise, the
|
|
1988
|
+
* semantic convention default "http.client.response.body.size" is used.
|
|
1989
|
+
*
|
|
1990
|
+
* @default false
|
|
1991
|
+
*/
|
|
1992
|
+
responseBytesMetric?: boolean | string;
|
|
1993
|
+
|
|
1994
|
+
/**
|
|
1995
|
+
* Controls only the naming of the fetch/XHR request spans.
|
|
1996
|
+
*
|
|
1997
|
+
* "semconv" (default) names the spans by the normalized HTTP request method (e.g. "GET"),
|
|
1998
|
+
* per the OTEL semantic conventions for HTTP client spans. "product" keeps the product
|
|
1999
|
+
* span names ("interopio.api.instrumentation.fetch"/".xhr").
|
|
2000
|
+
*
|
|
2001
|
+
* Everything else is the same in both modes: the spans always carry the semconv
|
|
2002
|
+
* attributes (url.full, http.request.method[_original], http.response.status_code,
|
|
2003
|
+
* http.response.header.*, server.address/server.port, http.request.body.size /
|
|
2004
|
+
* http.response.body.size, error.type), span kind CLIENT, and the semconv status
|
|
2005
|
+
* rules. The filtering identity is also unaffected: span filters match these spans
|
|
2006
|
+
* on source "interopio.api.instrumentation.fetch"/".xhr" and on context.url /
|
|
2007
|
+
* context.method.
|
|
2008
|
+
*
|
|
2009
|
+
* @default "semconv"
|
|
2010
|
+
*/
|
|
2011
|
+
spanNames?: "semconv" | "product";
|
|
2012
|
+
|
|
2013
|
+
/**
|
|
2014
|
+
* Which measurement responseBytesMetric (and the corresponding span data) reports:
|
|
2015
|
+
*
|
|
2016
|
+
* - "content-length" (default): only the value of the content-length response header
|
|
2017
|
+
* (the actual transfer size, after content-encoding). Cheap - the body is never read
|
|
2018
|
+
* for sizing - but responses without the header (e.g. chunked transfer encoding)
|
|
2019
|
+
* contribute no sample.
|
|
2020
|
+
* - "raw": only bytes counted by fully reading a clone of every fetch response body
|
|
2021
|
+
* (the size after the browser removed any content-encoding; for XHR the already
|
|
2022
|
+
* buffered response is measured). Always available, but carries the same cost caveat
|
|
2023
|
+
* as requestTotalDurationMetric: every non-streaming fetch response body is drained,
|
|
2024
|
+
* including ones the application abandons.
|
|
2025
|
+
* - "both": prefers content-length and falls back to the raw count when the header is
|
|
2026
|
+
* absent. Maximizes coverage but mixes the two measurement kinds in one histogram -
|
|
2027
|
+
* use the sizeKind metric attribute to separate them when querying.
|
|
2028
|
+
*
|
|
2029
|
+
* @default "content-length"
|
|
2030
|
+
*/
|
|
2031
|
+
responseBytesMeasurement?: "content-length" | "raw" | "both";
|
|
2032
|
+
}
|
|
2033
|
+
|
|
1769
2034
|
/**
|
|
1770
2035
|
* Configuration for User Journey trace behavior.
|
|
1771
2036
|
* Controls how significant User Journey milestones are tracked throughout the platform session.
|
|
@@ -1812,7 +2077,9 @@ export namespace IOInsights {
|
|
|
1812
2077
|
*/
|
|
1813
2078
|
export type MarkerSpanCallback = (
|
|
1814
2079
|
source: string,
|
|
1815
|
-
data?: DataByVerbosity
|
|
2080
|
+
data?: DataByVerbosity,
|
|
2081
|
+
newTrace?: boolean,
|
|
2082
|
+
parentSpan?: PropagationInfo
|
|
1816
2083
|
) => Promise<PropagationInfo | null> | void;
|
|
1817
2084
|
|
|
1818
2085
|
/**
|
|
@@ -2266,4 +2533,8 @@ export namespace IOInsights {
|
|
|
2266
2533
|
export type DataByVerbosity = {
|
|
2267
2534
|
[level in SpanVerbosity]: any;
|
|
2268
2535
|
}
|
|
2536
|
+
|
|
2537
|
+
export type TracingMap<T> = {
|
|
2538
|
+
[propertyName in keyof Partial<T>]: ({ source: string; decoratorOptions?: IOInsights.WithSpanDecoratorOptions } | string);
|
|
2539
|
+
};
|
|
2269
2540
|
}
|