UNPKG

3.94 kBTypeScriptView Raw
1import { Baggage, BaggageObj, HttpHeaderValue, TraceparentData } from '@sentry/types';
2export declare const BAGGAGE_HEADER_NAME = "baggage";
3export declare const SENTRY_BAGGAGE_KEY_PREFIX = "sentry-";
4export declare const SENTRY_BAGGAGE_KEY_PREFIX_REGEX: RegExp;
5/**
6 * Max length of a serialized baggage string
7 *
8 * https://www.w3.org/TR/baggage/#limits
9 */
10export declare const MAX_BAGGAGE_STRING_LENGTH = 8192;
11/** Create an instance of Baggage */
12export declare function createBaggage(initItems: BaggageObj, baggageString?: string, mutable?: boolean): Baggage;
13/** Get a value from baggage */
14export declare function getBaggageValue(baggage: Baggage, key: keyof BaggageObj): BaggageObj[keyof BaggageObj];
15/** Add a value to baggage */
16export declare function setBaggageValue(baggage: Baggage, key: keyof BaggageObj, value: BaggageObj[keyof BaggageObj]): void;
17/** Check if the Sentry part of the passed baggage (i.e. the first element in the tuple) is empty */
18export declare function isSentryBaggageEmpty(baggage: Baggage): boolean;
19/** Returns Sentry specific baggage values */
20export declare function getSentryBaggageItems(baggage: Baggage): BaggageObj;
21/**
22 * Returns 3rd party baggage string of @param baggage
23 * @param baggage
24 */
25export declare function getThirdPartyBaggage(baggage: Baggage): string;
26/**
27 * Checks if baggage is mutable
28 * @param baggage
29 * @returns true if baggage is mutable, else false
30 */
31export declare function isBaggageMutable(baggage: Baggage): boolean;
32/**
33 * Sets the passed baggage immutable
34 * @param baggage
35 */
36export declare function setBaggageImmutable(baggage: Baggage): void;
37/** Serialize a baggage object */
38export declare function serializeBaggage(baggage: Baggage): string;
39/**
40 * Parse a baggage header from a string or a string array and return a Baggage object
41 *
42 * If @param includeThirdPartyEntries is set to true, third party baggage entries are added to the Baggage object
43 * (This is necessary for merging potentially pre-existing baggage headers in outgoing requests with
44 * our `sentry-` values)
45 */
46export declare function parseBaggageHeader(inputBaggageValue: HttpHeaderValue, includeThirdPartyEntries?: boolean): Baggage;
47/**
48 * Merges the baggage header we saved from the incoming request (or meta tag) with
49 * a possibly created or modified baggage header by a third party that's been added
50 * to the outgoing request header.
51 *
52 * In case @param headerBaggageString exists, we can safely add the the 3rd party part of @param headerBaggage
53 * with our @param incomingBaggage. This is possible because if we modified anything beforehand,
54 * it would only affect parts of the sentry baggage (@see Baggage interface).
55 *
56 * @param incomingBaggage the baggage header of the incoming request that might contain sentry entries
57 * @param thirdPartyBaggageHeader possibly existing baggage header string or string[] added from a third
58 * party to the request headers
59 *
60 * @return a merged and serialized baggage string to be propagated with the outgoing request
61 */
62export declare function mergeAndSerializeBaggage(incomingBaggage?: Baggage, thirdPartyBaggageHeader?: HttpHeaderValue): string;
63/**
64 * Helper function that takes a raw baggage string (if available) and the processed sentry-trace header
65 * data (if available), parses the baggage string and creates a Baggage object
66 * If there is no baggage string, it will create an empty Baggage object.
67 * In a second step, this functions determines if the created Baggage object should be set immutable
68 * to prevent mutation of the Sentry data.
69 *
70 * Extracted this logic to a function because it's duplicated in a lot of places.
71 *
72 * @param rawBaggageValue
73 * @param sentryTraceHeader
74 */
75export declare function parseBaggageSetMutability(rawBaggageValue: HttpHeaderValue | false | undefined, sentryTraceHeader: TraceparentData | string | false | undefined | null): Baggage;
76//# sourceMappingURL=baggage.d.ts.map
\No newline at end of file